关于子线程中销毁主线程窗口的问题
通常销毁或者关闭窗口会用如下函数:
[1] CWnd::DestroyWindow()
[2] CFrameWnd::OnClose()
[3] ::SendMessage(hWnd,WM_SYSCOMMAND,SC_CLOSE,0);
或者::SendMessage(hWnd,WM_CLOSE,NULL,NULL);
之间的关系如下:
After runing the function sendMessage(),thefunction OnClose() will be excuted;
in the function OnClose() , DestroyWindow() will be called in the end
/
// CFrameWnd closing down
void CFrameWnd::OnClose()
{
if (m_lpfnCloseProc != NULL)
{
// if there is a close proc, then defer to it, and return
// after calling it so the frame itself does not close.
(*m_lpfnCloseProc)(this);
return;
}
// Note: only queries the active document
CDocument* pDocument = GetActiveDocument();
if (pDocument != NULL && !pDocument->CanCloseFrame(this))
{
// document can't close right now -- don't close it
return;
}
CWinApp* pApp = AfxGetApp();
if (pApp != NULL &