How to get close event of form view in MFC
-
Hi developers, I requires to handle OnClose handle of a form view. I am building a heavy tree on it( based on thread ), and while doing that if i closed that form, application was getting crash, because that tree control has been destroyed. So that I have to capture it's close event so that I can prevent this event to proceed, i.e. to close that form. Thanks In Advance. Amrit Agrawal Software Developer
-
Hi developers, I requires to handle OnClose handle of a form view. I am building a heavy tree on it( based on thread ), and while doing that if i closed that form, application was getting crash, because that tree control has been destroyed. So that I have to capture it's close event so that I can prevent this event to proceed, i.e. to close that form. Thanks In Advance. Amrit Agrawal Software Developer
When you close that form, the syst will call its destructor so if you wanna handle the prob go to the
YourFormClass()::~YourFormClass( )
{
//Type Code Here
}"The Ultimate Limit Is Only Your Imagination."
-
Hi developers, I requires to handle OnClose handle of a form view. I am building a heavy tree on it( based on thread ), and while doing that if i closed that form, application was getting crash, because that tree control has been destroyed. So that I have to capture it's close event so that I can prevent this event to proceed, i.e. to close that form. Thanks In Advance. Amrit Agrawal Software Developer
Use
OnClose();
void CmyApp::OnClose()
{
DestroyWindow();
}Article containing an example of [ OnClose()] MSDN Docs:[CWnd::OnClose ] MSDN Docs:[CWnd::DestroyWindow ]
-
Use
OnClose();
void CmyApp::OnClose()
{
DestroyWindow();
}Article containing an example of [ OnClose()] MSDN Docs:[CWnd::OnClose ] MSDN Docs:[CWnd::DestroyWindow ]
I totaly agree with u in case the user is running an SDI application but what if it is a MDI application ?
"The Ultimate Limit Is Only Your Imagination."
-
I totaly agree with u in case the user is running an SDI application but what if it is a MDI application ?
"The Ultimate Limit Is Only Your Imagination."
Yes, [MSDN] says: "To destroy an MDI Child window; use the virtual member function
CWnd::DestroyWindow
. Do not call the global::DestroyWindow
API to destroy an MDI Child window." It goes on to say: "In the case of C++ Windows objects that do perform auto-cleanup, you must call DestroyWindow. If you use operator delete directly, the MFC diagnostic memory allocator will alert you that you are freeing memory twice (the first call to delete as well as the indirect call to "delete this" in the auto-cleanup implementation of PostNcDestroy)." -
Yes, [MSDN] says: "To destroy an MDI Child window; use the virtual member function
CWnd::DestroyWindow
. Do not call the global::DestroyWindow
API to destroy an MDI Child window." It goes on to say: "In the case of C++ Windows objects that do perform auto-cleanup, you must call DestroyWindow. If you use operator delete directly, the MFC diagnostic memory allocator will alert you that you are freeing memory twice (the first call to delete as well as the indirect call to "delete this" in the auto-cleanup implementation of PostNcDestroy)."You scored Hight :thumbsup: .
"The Ultimate Limit Is Only Your Imagination."