Click to See Complete Forum and Search --> : OnAppExit()
Steve McNeese
March 29th, 1999, 09:46 AM
What is the default action for the Application exit? I tried creating a message map for OnAppExit to perform some checking and cleanup. Everything worked except the applicaiton did not exit. So, I added exit(0) to the end of the function. In debug mode, everything works fine but in release mode I get an exception and the program crashes. I disabled the function and message map and the program exists without any problem in release or debug. What should I call to terminate the application when overriding the AppExit()?
Thanks,
Steve
Dazza
March 29th, 1999, 09:58 AM
The CWinApp default handler does:
void CWinApp::OnAppExit()
{
// same as double-clicking on main window close box
ASSERT(m_pMainWnd != NULL);
m_pMainWnd->SendMessage(WM_CLOSE);
}
Explicitly calling this from your overridden handler should work fine, although I might like to suggest that you do your stuff in an override of CWinApp::ExitInstance() or the even the destructor of your Application object.
Dave Lorde
March 29th, 1999, 10:02 AM
Are you calling the base class implementation at the end of your override?
void MyApp::OnAppExit()
{
// do cleanup
...
CWinApp::OnAppExit(); // call base class implementation
}
Dave
sally
March 29th, 1999, 06:47 PM
Do NOT use exit(0) from a Windows application
Sally
March 29th, 1999, 06:47 PM
Do NOT use exit(0) from a Windows application
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.