我的程序在启动时出现登录对话框,如果点击了"取消",需要退出程序,我用
PostQuitMessage(0);退出,结果OnDestroy() 执行不到,各位谁知道怎么解决?
void CManagerView::OnShowWindow(BOOL bShow, UINT nStatus)
{
.........
PostQuitMessage(0);
}
void CManagerView::OnDestroy()
{
CListView::OnDestroy();
if(m_pDB!=NULL)
{
delete m_pDB;
}
if(m_pSnmp!=NULL)
{
delete m_pSnmp;
}
}
PostQuitMessage(0);退出,结果OnDestroy() 执行不到,各位谁知道怎么解决?
void CManagerView::OnShowWindow(BOOL bShow, UINT nStatus)
{
.........
PostQuitMessage(0);
}
void CManagerView::OnDestroy()
{
CListView::OnDestroy();
if(m_pDB!=NULL)
{
delete m_pDB;
}
if(m_pSnmp!=NULL)
{
delete m_pSnmp;
}
}
当然,你得先得到View的指针,
同时,把OnDestroy声明成Public
Warning: destroying CSingleDocTemplate with live document.
在语句
IMPLEMENT_DYNCREATE(CManagerView, CListView)处提示:
J:\snmp\Manager\ManagerView.cpp(28) : {101} client block at 0x003C5B10, subtype 0, 872 bytes long.
a CManagerView object at $003C5B10, 872 bytes long
我问一下,在程序已经初始话完成的时候怎么正常退出,而不会泄漏内存?
{
CListView::OnNcDestroy(); PostQuitMessage(0);
}
// Perform cleanup tasks.
PostQuitMessage(0);
break; The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen.
CWnd::OnDestroy --The framework calls this member function to inform the CWnd object that it is being destroyed.因此,如 enoloo(努力COM) 所说的,“PostQuitMessage直接使消息循环退出了,窗口消息处理的OnDestroy得不到执行。”