在单文档中,如何实现在MainFrame中访问CDocument中的变量?CMainFrame类和CDocument类谁先被初始化?

解决方案 »

  1.   

    1、在CMainFrm.cpp中
    CView* pView = GetActiveView();
       CXXDoc* pDoc = (CXXDoc*)pView->GetDocument();
    2、先初试化CDocument这个问题其实你可以通过AfxMessageBox()来调试的
      

  2.   

    CDocument *p = GetDocument();
    p->...
      

  3.   

    CXXXDocument *pDoc = GetDocument();文档类先初始化。
      

  4.   

    我在CMainFrm.cpp 中有如下定义:
    inline CXXDoc* CXX::GetDocument()
       { return (CXXDoc*)m_pDocument; }
    用GetDocument(),然后再访问其中的m_pDocument,出错显示:m_pDocument没有定义。why?
      

  5.   

    用GetActiveDocument()不好意思,搞定了