Posted on 1998-03-11
How can I declare a generic timerProc such that when an object is declared the timer proc would know which object (assuming the objects are instances of the same class) to notify?
My preferred method is to declare a class and declare a timer proc within that class so every object knows its timer proc, and every timer proc knows the object to notify which would be the object it belongs to. However, this is not possible since Windows TimerProc that the timer function uses is written for C and thus does not expect the "this" pointer.
This is an example of what I have in mind:
CALLBACK TimerProc (HWND, ........);
void Animate () ;
SetTimer (NULL, NULL, 100, TimerProc) ;
CALLBACK MovingObjec::TimerProc (HWND.........)
But the above code is invalid and generate a compiler error.
What would be the solution without writing a new timer proc for every new instance of this calss?
(sorry for the lengthy explanation!)