Using a Timer in a Subclassed Control
-
I have a question of about the use of a system timer within a class. The class in question is a dialog control class derived from CEdit. What I need to know is when is the appropriate time to allocate and setup the timer via the call to SetTimer(). I also need to know when is the appropriate time when to quit the timer service via the call to KillTimer(). My initial thought was as follows: Call SetTimer() within my class constructor; Call KillTimer() within my class destructor; However I have been thinking if it would be better to add event routines to my class to support the WM_CREATE and WM_DESTROY and place the calls as follows: Call SetTimer() within my class OnCreate() event handler; Call KillTimer() within my class OnDestroy() event handler; For any of you out there that are more experienced than myself I would ask.... Which of these approaches is better or more apt to work better? And if these are neither appropriate then what is the proper implementation? Thank you, Mike
-
I have a question of about the use of a system timer within a class. The class in question is a dialog control class derived from CEdit. What I need to know is when is the appropriate time to allocate and setup the timer via the call to SetTimer(). I also need to know when is the appropriate time when to quit the timer service via the call to KillTimer(). My initial thought was as follows: Call SetTimer() within my class constructor; Call KillTimer() within my class destructor; However I have been thinking if it would be better to add event routines to my class to support the WM_CREATE and WM_DESTROY and place the calls as follows: Call SetTimer() within my class OnCreate() event handler; Call KillTimer() within my class OnDestroy() event handler; For any of you out there that are more experienced than myself I would ask.... Which of these approaches is better or more apt to work better? And if these are neither appropriate then what is the proper implementation? Thank you, Mike
Call
SetTimer
inCYourEdit::OnCreate
. Kill the timer inCYourEdit::OnDestroy
(or alternatively, let the timer be killed by the system upon window destruction). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
Call
SetTimer
inCYourEdit::OnCreate
. Kill the timer inCYourEdit::OnDestroy
(or alternatively, let the timer be killed by the system upon window destruction). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo... and before all that, read this article about timers :) I vote pro drink :beer:
-
I have a question of about the use of a system timer within a class. The class in question is a dialog control class derived from CEdit. What I need to know is when is the appropriate time to allocate and setup the timer via the call to SetTimer(). I also need to know when is the appropriate time when to quit the timer service via the call to KillTimer(). My initial thought was as follows: Call SetTimer() within my class constructor; Call KillTimer() within my class destructor; However I have been thinking if it would be better to add event routines to my class to support the WM_CREATE and WM_DESTROY and place the calls as follows: Call SetTimer() within my class OnCreate() event handler; Call KillTimer() within my class OnDestroy() event handler; For any of you out there that are more experienced than myself I would ask.... Which of these approaches is better or more apt to work better? And if these are neither appropriate then what is the proper implementation? Thank you, Mike
-
... and before all that, read this article about timers :) I vote pro drink :beer: