|
-
January 21st, 2006, 04:52 AM
#1
timeSetTimer Callback Issues
I have a compilation error I can't figure out. I am calling timeSetTimer from a member function within a class. The callback function is also a member of the class.
When I compile this statement:
timeSetEvent(iDelay, 0, &wait, NULL, TIME_ONESHOT);
I get:
error C2276: '&' : illegal operation on bound member function expression
When I compile this statement:
timeSetEvent(iDelay, 0, &FOO::wait, NULL, TIME_ONESHOT);
I get:
error C2664: 'timeSetEvent' : cannot convert parameter 3 from 'void (__stdcall FOO::*)(unsigned int,unsigned int,unsigned long,unsigned long,unsigned long)' to 'void (__stdcall *)(unsigned
Any ideas?
Thanks!
-
January 21st, 2006, 05:36 AM
#2
Re: timeSetTimer Callback Issues
-
January 21st, 2006, 05:46 AM
#3
Re: timeSetTimer Callback Issues
-
January 21st, 2006, 06:02 AM
#4
Re: timeSetTimer Callback Issues
-
January 21st, 2006, 06:10 PM
#5
Re: timeSetTimer Callback Issues
Ok... I am back with a similar issue. I've decided to place a flag in the callback function that I will clear upon execution. I have the flag as a private member of the class. When I attempt to clear it inside the callback function with:
pulsing=false;
I get:
illegal reference to data member 'FOO: ulsing' in a static member function
The error makes sense because the this pointer is not passed along. I figured declaring the flag as
static bool pulsing;
would solve this issue... but that generates an unresolved external symbol.
Any help?
-
January 21st, 2006, 07:06 PM
#6
Re: timeSetTimer Callback Issues
You basically have two choices here...
- Using a static member. They need to be defined however, thus...
Code:
// .hpp
class foo
{
static bool pulsing;
};
// .cpp
bool foo::pulsing = false;
- 'timeSetEvent()' allows you to pass a user-defined value as a 'DWORD_PTR'. You can use this to pass the 'this' pointer of the class instance you want to access in your callback...
-
January 21st, 2006, 07:33 PM
#7
Re: timeSetTimer Callback Issues
I ended up using the DWORD dwUser parm to pass the pointer this to the function. I couldn't get your first example to work. I had actually tried that. It doesn't seem to like the static bool pulsing declaration. I still get the unresolved external symbol error.
Even though I have it working I would still like to know why declaring the flag as static doesn't work for me.
Thanks!
-
January 22nd, 2006, 05:29 AM
#8
Re: timeSetTimer Callback Issues
 Originally Posted by eeboy
Even though I have it working I would still like to know why declaring the flag as static doesn't work for me.
Well...without seeing the actual you tried it with, it is pretty hard to tell...nevertheless, it should have worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|