Hi all.
I'm working on an application where I need to trap the File/Exit command before I quit the application. When I do this, however, I get the following debug errors:
OnAppExit()
Warning: destroying CSingleDocTemplate with live document.
Detected memory leaks!
(list of dumped objects)
Here's the code that produces this error:
void CFTForm::OnAppExit() //CFTForm is derived from CFormView
{
if (AskSave()==TRUE)
{
OutputDebugString("OnAppExit()\n");
m_FTApp->ExitCheck();
PostQuitMessage(0);
}
}
Can I use PostQuitMessage with MFC? If not, what should I call to get the application to close from here?
Any info would be appreciated.
Thanks.
Mike.
----------------------------------------------------------------
Mike Boone <Mike-...@msn.com> http://boonedocks.simplenet.com
"I've got a Caribbean Soul I can barely control and some
Texas hidden here in my heart..." - Jimmy Buffett
try this code instead
void ExitApp()
{
// same as double clicking on main window close box
ASSERT(AfxGetApp()->m_pMainWnd!=NULL);
AfxGetApp()->m_pMainWnd->SendMessage(WM_CLOSE);
}
I use it all of the time and don't have any problem with it. Here is a sample of one of my calles to it
// other on draw code
if(info.DoModal() !=IDOK ) {
// user has selected cancel
ExitApp();
return;
}
// more on draw code
// end of on draw code
ExitApp();
}
Hope this helps
Joe Love
lo...@cadvision.com
and
lo...@gice.com
www.gice.com/tomas/
You could try calling the CWinApp::CloseAllDocuments() member functions,
but I think a better way
would be to post a WM_CLOSE message to your main window like this>
AfxGetMainWnd()->PostMessage(WM_CLOSE);
HTH
Joe O'
Mike Boone <Mike-...@msn.com> wrote in article
<01bc108b$c832c400$06261fce@bubba>...
Hi all.
----------
Hope this helps.
Troy Ockert & Jim Hewitt
Aditi Corp was formerly known as NetQuest Inc.
CWnd * pWnd = AfxGetMainWnd();
if (pWnd != NULL)
pWnd->PostMessage(WM_CLOSE);
Mike Boone <Mike-...@msn.com> wrote in article
<01bc108b$c832c400$06261fce@bubba>...
Can I use PostQuitMessage with MFC? If not, what should I call to get the
application to close from here?