在CMainFrame::OnAppExit()中,调用CFrameWnd::OnClose(),应用程序退不出来?急!!!!!!

xiaohonghong 2005-06-20 08:48:21
求救:我在CMainFrame::OnAppExit()中,调用CFrameWnd::OnClose(),应用程序退不出来,调用::PostQuitMessage(0),也不行,在Debug版本下,程序会出错,提示是:arning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
继续运行,在Call Stack中 会出现:_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::_Release() line 662 + 15 bytes
_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::~_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >() line 262
$E534() + 34 bytes
doexit(int 0, int 0, int 0) line 353
exit(int 0) line 279 + 13 bytes
WinMainCRTStartup() line 345
KERNEL32! 77e8893d()
好象是Ado的_ConnectionPtr没有关闭,而我确实调用了关闭该连接。
我的OnAppExit程序如下:
void CMainFrame::OnAppExit()
{
// TODO: Add your command handler code here

if(g_Started)
{
//AfxMessageBox("请先结束测试,再关闭系统!");
CMsgDlg dlg;
dlg.m_strMsg = "请先结束测试,再关闭系统!";
dlg.DoModal();
return;
}
CMsgDlg dlg;
dlg.m_strMsg = "你真的要退出本系统么?";
dlg.m_bCancelShow = true;

if(dlg.DoModal() == IDCANCEL)
return;
/////////////////////////////
SysLog(CString("关闭软件"));

#if _DEBUG
try
{
m_FileDataOver.Close();
}
catch(...){}
#endif
//
::Shell_NotifyIcon(NIM_DELETE,&m_tnid);
if(m_pMenu)
{
m_pMenu->Detach();
delete m_pMenu;
}
//
////////////////////////////////
POSITION pos;
pos = this->m_EquipInfoMap.GetStartPosition();
for(pos; pos != NULL; )
{
CString strAddr;
CEquipInfo *pPara = NULL;
m_EquipInfoMap.GetNextAssoc(pos,strAddr,(void *&)pPara);
if(pPara)
delete pPara;
m_EquipInfoMap.RemoveKey(strAddr);
}
m_EquipInfoMap.RemoveAll();
//
CThrRecord *pThrRecord = NULL;
int count = this->m_OutThrList.GetCount();
for(int j = 0; j < count; j++)
{
pThrRecord = NULL;
pThrRecord = (CThrRecord *)this->m_OutThrList.RemoveHead();
if(pThrRecord)
delete pThrRecord;
}
//
if(m_pEquipErrListDlg)
{
//m_pEquipErrListDlg->PostNcDestroy();
//m_pEquipErrListDlg->DestroyWindow();
delete m_pEquipErrListDlg;
}
//////////////////////////////////////////
// unregister CrystalCtrl
//this->UnRegCrystalCtrl();
//
this->m_wndTree.DeleteAllItemsEx();
this->m_wndCirTree.DeleteAllItemsEx();

///////////////////////////////////////////////
try
{
g_ConnectPtr->Close();
g_Conn->Close();
::CoUninitialize();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
TRACE("Exception thrown for classes generated by #import");
TRACE("\tCode=%081x\n",e.Error());
TRACE("\tCode meaning=%s\n",e.ErrorMessage());
TRACE("\tSource=%s\n",(LPCTSTR)bstrSource);
TRACE("\tDescription=%s\n",(LPCTSTR)bstrDescription);
}
DWORD dwError = ::GetLastError();


CFrameWnd::OnClose();

dwError = ::GetLastError();
//::PostQuitMessage(0);



}
...全文
432 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2005-06-20
  • 打赏
  • 举报
回复
PostMessage发送WM_CLOSSE消息
goodboyws 2005-06-20
  • 打赏
  • 举报
回复
CThrRecord是从CWinThread继承来的么,如果是
if(pThrRecord)
delete pThrRecord;
改为
if(pThrRecord)]
{
TerminateThread(pThrRecord->m_hThread);
delete pThrRecord;

}
sad_4978 2005-06-20
  • 打赏
  • 举报
回复
如果相退出应用程序:
this->PostMessage(WM_CLOSE, 0, 0);
xiaohonghong 2005-06-20
  • 打赏
  • 举报
回复
继续运行,还会出现如下错误:
MSADO15! 1f436cdb()
_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::~_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >() line 262
$E550() + 34 bytes
doexit(int 0, int 0, int 0) line 353
exit(int 0) line 279 + 13 bytes
WinMainCRTStartup() line 345
KERNEL32! 77e8893d()
godsmile 2005-06-20
  • 打赏
  • 举报
回复
SendMessage(WM_CLOSE);
vcmute 2005-06-20
  • 打赏
  • 举报
回复
PostMessage(WM_CLOSE);
xqk 2005-06-20
  • 打赏
  • 举报
回复
up
Phourm 2005-06-20
  • 打赏
  • 举报
回复
DestroyWindow();
xiaohonghong 2005-06-20
  • 打赏
  • 举报
回复
楼上,不行啊,我这样也试过了
Zhymax 2005-06-20
  • 打赏
  • 举报
回复
第一个提示
m_pEquipErrListDlg->DestroyWindow();
delete m_pEquipErrListDlg;

第二个错误好像有对象没释放,加这个
g_ConnectPtr->Release();

区定所有对象都释放了在调用::CoUninitialize();

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧