How to destroy and delete a modeless Dialog
-
Hello, I use this fonction to close and destroy a modeless dialogbox but it crash my application : m_Dlg* dialogbox CDialog created by new .. if (m_Dlg!=NULL) { m_Dlg->DestroyWindow(); delete m_Dlg; m_Dlg=NULL; } Should i use realy delete after destroy ? It works some time but it crash many time ! Thank you
AutreChien
-
Hello, I use this fonction to close and destroy a modeless dialogbox but it crash my application : m_Dlg* dialogbox CDialog created by new .. if (m_Dlg!=NULL) { m_Dlg->DestroyWindow(); delete m_Dlg; m_Dlg=NULL; } Should i use realy delete after destroy ? It works some time but it crash many time ! Thank you
AutreChien
NorGUI wrote:
f (m_Dlg!=NULL) { m_Dlg->DestroyWindow();
Send WM_QUIT message before deleting the Dialog instead of DestroyWindow!, also check for existence of DialogWindow before cleaning up task!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
Hello, I use this fonction to close and destroy a modeless dialogbox but it crash my application : m_Dlg* dialogbox CDialog created by new .. if (m_Dlg!=NULL) { m_Dlg->DestroyWindow(); delete m_Dlg; m_Dlg=NULL; } Should i use realy delete after destroy ? It works some time but it crash many time ! Thank you
AutreChien
-
NorGUI wrote:
f (m_Dlg!=NULL) { m_Dlg->DestroyWindow();
Send WM_QUIT message before deleting the Dialog instead of DestroyWindow!, also check for existence of DialogWindow before cleaning up task!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
I'm new to VC++. WM_QUIT doc says it will quit app. Should we use it for one window?
---------------------- Mayank Thakore Learning C++ - since 1998 They didn't print my card right; so I resigned.
MayankT wrote:
WM_QUIT doc says it will quit app
A correction, it will stop message loop, not actually quit the window!. if you have put any wait function after the MessageLoop.. your window might get destroyed but your application still visible in running process list! have a look sample app! WinMain(....) { .......... GetMessage(&Msg,0,0,0) { } ......... // WM_QUIT will break above loop but what about WaitForSingleObject written below! WaitForSingleObject(...) }
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
Hello, I use this fonction to close and destroy a modeless dialogbox but it crash my application : m_Dlg* dialogbox CDialog created by new .. if (m_Dlg!=NULL) { m_Dlg->DestroyWindow(); delete m_Dlg; m_Dlg=NULL; } Should i use realy delete after destroy ? It works some time but it crash many time ! Thank you
AutreChien
NorGUI wrote:
if (m_Dlg!=NULL) { m_Dlg->DestroyWindow(); delete m_Dlg; m_Dlg=NULL; }
There should not be any problem with this code. Can you tell, where crash taking you in the code. There must be something other , you are doing wrong.
Prasad Notifier using ATL
-
are you destroying window created by some other thread? in that case DestroyWindow will not work. Did it crash in DestroyWindow or delete?
---------------------- Mayank Thakore Learning C++ - since 1998 They didn't print my card right; so I resigned.
-
NorGUI wrote:
f (m_Dlg!=NULL) { m_Dlg->DestroyWindow();
Send WM_QUIT message before deleting the Dialog instead of DestroyWindow!, also check for existence of DialogWindow before cleaning up task!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
?
WM_QUIT
is used with an app's main window.DestroyWindow()
is the correct way to destroy a modeless dialog.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ