Mfc CMDIClientAreaWnd::EnableMDITabs()中的错误?递归调用

Mfc CMDIClientAreaWnd::EnableMDITabs()中的错误?递归调用,mfc,docview,Mfc,Docview,我在CMyApp::Initintance()中使用LoadMDIState()来加载/恢复以前MDI文档的窗口位置 if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) { if (!pMainFrame->LoadMDIState(GetRegSectionPath())) { m_pStartDocTemplate->OpenDocumentFile(NULL); // Load

我在CMyApp::Initintance()中使用LoadMDIState()来加载/恢复以前MDI文档的窗口位置

if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
{
    if (!pMainFrame->LoadMDIState(GetRegSectionPath()))
    {
        m_pStartDocTemplate->OpenDocumentFile(NULL);    // Load previous Document
    }
}
如果Serialize()期间的内部状态设置为

CMDIClientAreaWnd::m_bTabIsEnabled = FALSE;
但如果内部状态为

CMDIClientAreaWnd::m_bTabIsEnabled = TRUE;
我已经在MFC源代码中研究了这个bug,并在中看到了递归调用

void CMDIClientAreaWnd::EnableMDITabs(BOOL bEnable, const CMDITabInfo& params)
{
  if (m_bIsMDITabbedGroup)
  {
    EnableMDITabbedGroups(FALSE, params);
  }
  :
}


void CMDIClientAreaWnd::EnableMDITabbedGroups(BOOL bEnable, const CMDITabInfo& mdiTabParams)
{
  if (m_bTabIsEnabled)
  {
    EnableMDITabs(FALSE, mdiTabParams);
  }
  :
}

这是虫子吗?如何解决MDI选项卡式视图的这个问题?

由MFC源代码本身的注释解决

CMDIChildWndEx* CMainFrame::CreateDocumentWindow(LPCTSTR lpcszDocName, CObject* pObj)
{
  return CMDIFrameWndEx::CreateDocumentWindow(lpcszDocName, pObj);
  ASSERT(FALSE);
  TRACE0("If you use save/load state for MDI tabs, you must override this method in a derived class!\n");
  return NULL;
}
我已经在CMainframe中覆盖了这一点,它是有效的

CMDIChildWndEx* CMainFrame::CreateDocumentWindow(LPCTSTR lpcszDocName, CObject* pObj)
{
    CDocument* pDoc = NULL;
    pDoc = AfxGetApp()->OpenDocumentFile(lpcszDocName);

    if (pDoc != NULL)
    {
        POSITION pos = pDoc->GetFirstViewPosition();

        if (pos != NULL)
        {
            CView* pView = pDoc->GetNextView(pos);
            return DYNAMIC_DOWNCAST(CMDIChildWndEx, pView->GetParent());
        }
    }
}

return NULL;