Jump to content
  • Advertisement
Sign in to follow this  
likeregularchickens

TIMECALLBACK

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've had a long break from programming but i need to get back into it for a bit. I'm trying to setup the timer from this tutorial: http://www.gamedev.net/reference/articles/article710.asp but i've got a problem. The tutorial uses TIMERCALLBACK to hold function pointers but that isnt recognised in my version of visual c++, so i'm using TIMECALLBACK.
header:
class Timer
{
public:
	Timer();

	BOOL Create(UINT period, UINT res, DWORD userVal, TIMECALLBACK pfnCallback);
}

code:

BOOL Timer::Create(UINT period, UINT res, DWORD userVal,TIMECALLBACK pfnCallback)
{
	m_timerPeriod = period;
	m_timerRes = res;
	m_userVal = userVal;
	m_pfnCallback = pfnCallback;
}

and that's all i've done so far. I'm getting this error: error C2511: 'Create' : overloaded member function 'int (unsigned int,unsigned int,unsigned long,void (__stdcall *)(unsigned int,unsigned int,unsigned long,unsigned long,unsigned long))' not found in 'Timer' c:\audio\kjyy\timer.h(5) : see declaration of 'Timer' as if the function i've written is different to the function in the header... but it's not. I'm very sketchy on my programming so i think it must be something simple i'm missing...? Thanks for any help, --likeregularchickens.

Share this post


Link to post
Share on other sites
Advertisement
Only thing I can think of is that you have different headers that define something in your function declaration differently.

Your code compiled fine for me only including windows.h and mmsystem.h (where TIMECALLBACK is defined.).

Share this post


Link to post
Share on other sites
hmm i cant get it...

i went on a bit anyway and noticed that the function pointer is called later but with only 1 variable, whereas TIMECALLBACK has 5.
I cant find a link to download the code so i cant be sure but i think TIMERCALLBACK is something the author has defined himself...

i've defined this:

typedef void (CALLBACK TIMERCALLBACK)(DWORD userVal);

and that sorts the 1 parameter problem but i've still got the weird problem from before.........

a shot in the dark but maybe there's some keyword or something i need to put in the above bit to sort this out?

Thanks for your reply.

Share this post


Link to post
Share on other sites
typedef void (CALLBACK TIMECALLBACK)(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);

typedef TIMECALLBACK FAR *LPTIMECALLBACK;

thats what the callbacks *should* look like.

HOWEVER, there seem to be a class System::Timers::Timer in .net. Maybe your getting a collision of some sort.

Share this post


Link to post
Share on other sites
yeah i'm not using .net though so i dont think it'd be that. TIMECALLBACK is defined the way you wrote, but i dont think TIMECALLBACK is what i need to use. In the tutorial he is using TIMERCALLBACK, which takes only 1 parameter, so i think i need to figure out how it's defined since there's no code to download.
I just really need to know why it's not letting me define a function pointer type, use it in a class function definition, and then implement it.
I'll have a readup on callbacks.....

Share this post


Link to post
Share on other sites
well i've got it compile... whether it works or not i dont know yet...

the article was written in 96 for dx2, so i think just the use of CALLBACK is out of date, so i went the traditional function pointer way and it's ok now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!