2016-09-26 14 views
1

CMyApp :: Initintance()でLoadMDIState()を使用して、以前のMDI-Docのウィンドウ位置をロード/復元します。CMDIClientAreaWnd :: EnableMDITabs()のバグ?再帰呼び出し

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ソースでこのバグを調査していクラッシュ再帰呼び出しを参照してください。

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のタブ付きビューのこの問題を解決するにはどうすればよいですか?

答えて

1

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; 
関連する問題