Using a C++ member function as a Timer callback 
Author Message
 Using a C++ member function as a Timer callback

I want to set up a timer inside of a C++ class.  I first tried deriving my
class from CWnd, but I got an assertion at "ASSERT(::IsWindow(m_hWnd)".  In
addition, I wanted to have another member of the class be the TimerProc, but
it requires that the TimerProc be stdcall.  Is there a way to make a member
function be stdcall, or get the SetTimer function to accept my cdecl member
function instead?

Thanks,
Greg Yutani



Sun, 27 Aug 2000 03:00:00 GMT  
 Using a C++ member function as a Timer callback

What I usually do is to call SetTimer in the OnCreate (WM_CREATE) function
because the m_hWnd is set to NULL in the standard constructor.  I also set
the callback function to NULL and use the OnTimer (WM_TIMER) function
because it is a member of the derived class. Don't forget to call KillTimer
in the OnDestroy (WM_DESTROY) function.

Sincerely,
Will McKee.

--
---------------------------------------
William A. McKee

http://www.cjkware.com



Quote:
> I want to set up a timer inside of a C++ class.  I first tried deriving
my
> class from CWnd, but I got an assertion at "ASSERT(::IsWindow(m_hWnd)".
In
> addition, I wanted to have another member of the class be the TimerProc,
but
> it requires that the TimerProc be stdcall.  Is there a way to make a
member
> function be stdcall, or get the SetTimer function to accept my cdecl
member
> function instead?

> Thanks,
> Greg Yutani




Sun, 27 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using a C++ member function as a Timer callback

2. Passing C++ Class Member Function to as a C Callback Function Parameter

3. Calling C++ member function through C function callback

4. How to use member function of a C++ class as a callback function

5. Using Non-Static Callback Functions as member Functions VC5.0

6. Using timer-callback-function

7. Using Non-Static Callbacks as member functions VC 5.0

8. Timer Callback doesn't have access to member data

9. Getting pointer to non-static member function from C callback function

10. Callback functions as member functions

11. class member function as callback function

12. Getting a pointer to object's methods from timer callback function

 

 
Powered by phpBB® Forum Software