Diff. between DestroyWindow() and EndDialog()
-
i want to execute some code when a dialog is destroyed, but the code in DeatroyWindow() function doesn't executes when i use EndDialog() but executes when i use DestroyWindow(). What is the diff. between these two and which should be best to use?
-
i want to execute some code when a dialog is destroyed, but the code in DeatroyWindow() function doesn't executes when i use EndDialog() but executes when i use DestroyWindow(). What is the diff. between these two and which should be best to use?
I'd go for
DestroyWindow(), or OnOK, OnCancel
if you are using MFC. I've never done anything withEndDialog().
http://www.readytogiveup.com/[^] - Do something special today. http://www.totalcoaching.ca/[^] - Give me some feedback about this site !
-
i want to execute some code when a dialog is destroyed, but the code in DeatroyWindow() function doesn't executes when i use EndDialog() but executes when i use DestroyWindow(). What is the diff. between these two and which should be best to use?
-
i want to execute some code when a dialog is destroyed, but the code in DeatroyWindow() function doesn't executes when i use EndDialog() but executes when i use DestroyWindow(). What is the diff. between these two and which should be best to use?
Dialog Window Created by DialogBox, DialogBoxIndirect .. should be destroyed using EndDialog. OnOk, OnCancel internally uses EndDialog. And surely OnDestroy() will get called when EndDialog is used. Are u using MFC?
-
i want to execute some code when a dialog is destroyed, but the code in DeatroyWindow() function doesn't executes when i use EndDialog() but executes when i use DestroyWindow(). What is the diff. between these two and which should be best to use?
DestroyWindow is something you call, not something that gets called. In MFC, CWnd::DestroyWindow() is virtual. If you've overridden it, your override will get called at the end of DoModal() but that doesn't make it a good place to do something when a dialog is destroyed. That's a side effect of the way MFC does modal dialogs. I think a better place is any time at or after you receive a WM_NCDESTROY message. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
DestroyWindow is something you call, not something that gets called. In MFC, CWnd::DestroyWindow() is virtual. If you've overridden it, your override will get called at the end of DoModal() but that doesn't make it a good place to do something when a dialog is destroyed. That's a side effect of the way MFC does modal dialogs. I think a better place is any time at or after you receive a WM_NCDESTROY message. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
ya... i'm too thinking that... because i've placed code in overridden DestroyWindow() function but it never gets called if EndDialog() method is used to close the dialog box. :(
-
ya... i'm too thinking that... because i've placed code in overridden DestroyWindow() function but it never gets called if EndDialog() method is used to close the dialog box. :(
Abhijeet Pathak wrote:
but it never gets called if EndDialog() method is used to close the dialog box.
Looking at the source code, that is correct :) Note that when you receive WM_NCDESTROY, child windows (controls etc) have been destroyed. If you need access to the controls before they are destroyed, respond to WM_DESTROY which is sent before WM_NCDESTROY. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: