CMDIClientAreaWnd::EnableMDITabs() 中的错误?递归调用
Bug in CMDIClientAreaWnd::EnableMDITabs()? recursive call
我在 CMyApp::Initintance() 中使用 LoadMDIState() 到 load/restore 之前 MDI-Doc 的 window 位置。
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 选项卡式视图的这个问题?
已通过 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;
我在 CMyApp::Initintance() 中使用 LoadMDIState() 到 load/restore 之前 MDI-Doc 的 window 位置。
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 选项卡式视图的这个问题?
已通过 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;