Advertisement

Windows multimedia timers and MFC

Started by October 11, 1999 06:26 PM
1 comment, last by drstrangeluv 25 years, 2 months ago
I had this problem too. As far as I know, you can't pass a class member function as a callback param. I might be wrong, I don't know, u better make sure, but here's the way I solved it.
I made the member function of a class a friend function, so it wouldn't be a member anymore, but would be able to get to private or protected data, and then passed it as a callback.
I'm having some trouble getting the timeSetEvent to accept a method of a class as the callback parameter, even though I've declared the method as specified in Microsoft's multimedia timer overview (using the CALLBACK keyword). Could someone give me some help with this?
Advertisement
The problem here is the implied this pointer as the first argument to any class method. If you declare it as a static method, then you won't have the problem getting the signatures to line up.

The problem is then that you need a this pointer to be able to access the non static methods and data in the class. That's why callback type functions usually have a "user data" type parameter. Notice the dwUser argument in this particular function. This is where you pass your this pointer and you cast it in your static function to access other methods and members.

Check out this post: http://www.gamedev.net/community/forums/ubb/Forum6/HTML/000170.html
It's actually a very similar situation.

Email me if you need more help...

------------------

-Kentamanos

-Kentamanos

This topic is closed to new replies.

Advertisement