-
October 6th, 2000, 02:10 PM
#1
Where to put KillTimer() in Dialog
Where is the best place to put the KillTimer()? DestroyWindow or PostNcDestroy()? Will those functions always get called? Someone told me that DestroyWindow() never gets called, which seemed wierd.
-
October 6th, 2000, 02:15 PM
#2
Re: Where to put KillTimer() in Dialog
You can put it in the Destructor function of the dialog class.
~Kareem~
--------------------------------------------
If it is useful to you, you can rate it.....
-
January 30th, 2007, 10:45 AM
#3
Re: Where to put KillTimer() in Dialog
Are you sure?
When I put it into the destructor of a modal dialog, I get an assertion failed when I close the window before timer expired.
Exact error:
Assertion failed in afxwin2.inl row: 181
In this line I see:
_AFXWIN_INLINE CWnd* CWnd::SetActiveWindow()
Someone an idea? Thanks a lot.
-
January 30th, 2007, 10:52 AM
#4
Re: Where to put KillTimer() in Dialog
You cannot put it in destructor, because timer is a resource associated with window, and at the time destructor is execited, window is already destroyed. You should create a handler for WM_DESTROY message and kill timer there.
Cheers,
Hob
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
January 30th, 2007, 10:53 AM
#5
Re: Where to put KillTimer() in Dialog
Put it in the WM_DESTROY message. . before the CDialog:estroy () is called.
-
January 31st, 2007, 12:05 AM
#6
Re: Where to put KillTimer() in Dialog
Simply handle WM_CLOSE Function in your Code and write the Code in your OnClose() method.Because WM_CLOSE internally call DestroyWindow Function to DestroyWindow.
Thanx
-
January 31st, 2007, 03:15 AM
#7
Re: Where to put KillTimer() in Dialog
WM_CLOSE is only called when you use the close button from your systemmenu of your mainwindow.
-
January 31st, 2007, 04:42 AM
#8
Re: Where to put KillTimer() in Dialog
Originally Posted by Skizmo
WM_CLOSE is only called when you use the close button from your systemmenu of your mainwindow.
what else you are expecting .and how you are going to close the app
Thanx
-
January 31st, 2007, 04:56 AM
#9
Re: Where to put KillTimer() in Dialog
Originally Posted by humptydumpty
what else you are expecting .and how you are going to close the app
Thanx
Closing the app. can be done in more then 1 way. For example. . if you don't catch the escape-button. .. it closes the app when you press escape, without sending a WM_CLOSE. Or. .if you have your own 'Close/Exit' button on a Dialog, you can do a 'EndModalLoop ()' and the also the WM_CLOSE is not send.
The WM_DESTROY is always send, because no matter how to close your app. it must always destroy it's resources.
-
January 31st, 2007, 05:21 AM
#10
Re: Where to put KillTimer() in Dialog
Hello,
WM_DESTROY handler is the best place to kill the timer. WM_CLOSE handler is not the proper option since the dialog can be closed without getting WM_CLOSE message sent (like closing with OK or Cancel key). Destructor of the dialog class also is not the proper place since the destructor is called after the window is dismissed with and the timer is associated with the window. That is why an assertion failure occured.
Regards,
Pravin.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|