(1)在MFC中的多文档工程中得到当前文档
CMDIFrameWnd  *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; 
CMDIChildWnd  *pChild = (CMDIChildWnd   *)pFrame->GetActiveFrame();   
CView   *pV = (CView*)pChild->GetActiveView();
CDocument* pDoc = pV->GetDocument();
(2)在MFC中的多文档工程中遍历所有文档
POSITION pos = theApp.GetFirstDocTemplatePosition();
while (pos != NULL)
{
 CDocTemplate *p = theApp.GetNextDocTemplate(pos);
 POSITION posdoc = p->GetFirstDocPosition();
 while (posdoc != NULL)
 {
  CDocument* pDoc = p->GetNextDoc(posdoc);
       if (pDoc != NULL)
      {
           POSITION posview = pDoc->GetFirstViewPosition();
          if (posview != NULL)
          {
              CView* pV = pDoc->GetNextView(posview);
          }
      }
   }
}
(3)关闭某个文档

      pDoc->OnCloseDocument();

相关文章:

  • 2021-07-13
  • 2022-12-23
  • 2021-06-16
  • 2021-07-28
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
猜你喜欢
  • 2021-07-27
  • 2020-04-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案