积极答复者
OnNewWindow2如何关闭所有子窗口

问题
-
单文档程序
chtmlview继承来的,用OnNewWindow2 方法打开子窗口
请问一下,我如何关闭所有的子窗口啊?
(就是说,第一个运行的窗口不关闭,用OnNewWindow2方法打开的窗口都关闭)
感谢感谢~~
自己试了一些多文档程序关闭方法,移植不成功:(
下面一些代码可参考
1.
CMDIChildWnd* pMDIActive = MDIGetActive();
ASSERT(pMDIActive != NULL);
CDocument* pDoc = pMDIActive->GetActiveDocument();
ASSERT(pDoc != NULL);
CView* pView;
POSITION pos = pDoc->GetFirstViewPosition();
while (pos != NULL)
{
pView = pDoc->GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CNewView)))
{
pView->GetParentFrame()->SendMessage(WM_CLOSE);
}
}
2.
CMDIFrameWnd *pMainFrm =(CMDIFrameWnd *)AfxGetMainWnd();
CMDIChildWnd *pChild =pMainFrm->MDIGetActive();
while(pChild)
{
pChild->MDIDestroy();
pMainFrm->MDINext();
pChild =pMainFrm->MDIGetActive();
}
- 已编辑 flyskytoday 2009年7月15日 9:55 系统给我排版太差太差
答案
-
枚举当前文档模板的所有文档,用CDocument::UpdateAllViews通知各个视图关闭自己
Please mark the post answered your question as the answer, and click the chartreuse pyramid floating over nothingness/null to mark other helpful posts as helpful. This posting is provided "AS IS" with no warranties, and confers no rights.
Visual C++ MVP- 已标记为答案 flyskytoday 2009年7月16日 5:40
全部回复
-
枚举当前文档模板的所有文档,用CDocument::UpdateAllViews通知各个视图关闭自己
Please mark the post answered your question as the answer, and click the chartreuse pyramid floating over nothingness/null to mark other helpful posts as helpful. This posting is provided "AS IS" with no warranties, and confers no rights.
Visual C++ MVP- 已标记为答案 flyskytoday 2009年7月16日 5:40