Article ID: 117320
Article Last Modified on 11/21/2006
void ExitApp()
{
// same as double-clicking on main window close box
ASSERT(AfxGetApp()->m_pMainWnd != NULL);
AfxGetApp()->m_pMainWnd->SendMessage(WM_CLOSE);
}
As you can see, this is implemented as a global function, which can be
called from anywhere in your application. It simply sends a WM_CLOSE
message to your application's mainframe window. This initiates an orderly
shutdown of the application.
void ExitMFCApp()
{
// same as double-clicking on main window close box
ASSERT(AfxGetMainWnd() != NULL);
AfxGetMainWnd()->SendMessage(WM_CLOSE);
}
NOTE: Always call CDocument::SetModifiedFlag() after changing your document
data. This will ensure that the framework prompts the user to save before
shutdown. If you need more extensive control over the shutdown procedure,
you can override CDocument::SaveModified().
Additional query words: kbinf 1.00 1.50 1.51 1.52 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00
Keywords: KB117320