Timers in an MSDI app
-
I have some timers set in an SDI app. At the moment, I have to click a button to kill the timers before I close the app. Does the framework kill the timers if I click on the x in the upper corner to close? Or do I need to kill the timers before I close it? If I have to kill them, what message do I need to catch? WM_CLOSE? Its view is CFormView. Thanks!
-
I have some timers set in an SDI app. At the moment, I have to click a button to kill the timers before I close the app. Does the framework kill the timers if I click on the x in the upper corner to close? Or do I need to kill the timers before I close it? If I have to kill them, what message do I need to catch? WM_CLOSE? Its view is CFormView. Thanks!
Use KillTimer(m_nTimerID); Peter Molnar
-
Use KillTimer(m_nTimerID); Peter Molnar
Thanks for the reply, but that wasnt my question.
-
Thanks for the reply, but that wasnt my question.
SetTimer is CWnd's member function, happens nothing extraordinary (i.e. no memory leak or anything bad) if you don't kill it separately. The framework does this for you when the CWnd object gets destroyed from which you called it regardless whether you called it from your view or framewnd or whatever place. As for handling WM_CLOSE in your mainframe, this is a good place for things to clean up that require clean up. Peter Molnar
-
SetTimer is CWnd's member function, happens nothing extraordinary (i.e. no memory leak or anything bad) if you don't kill it separately. The framework does this for you when the CWnd object gets destroyed from which you called it regardless whether you called it from your view or framewnd or whatever place. As for handling WM_CLOSE in your mainframe, this is a good place for things to clean up that require clean up. Peter Molnar
Thanks! Thats what I needed!
-
I have some timers set in an SDI app. At the moment, I have to click a button to kill the timers before I close the app. Does the framework kill the timers if I click on the x in the upper corner to close? Or do I need to kill the timers before I close it? If I have to kill them, what message do I need to catch? WM_CLOSE? Its view is CFormView. Thanks!
I notice that Peter Molnar gave you the answer, but I consider it a good practice to kill the timers youself instead of depending on the frame work to do it. One of the reasons for this is that you have control and can close it when it is know longer needed, instead of letting it run after its' job is done. The second reason is that unless it is need to run during the life time of the object, it should be killed because it is still generating timer messages and wasting processor time. INTP