在MFC中,我创建了三个view类,分别是view,view1,view2 ,文档类只用开始创建MFC工程生成的那个文档,现在要在View1中获得文档类的指针?如何实现?是GetDocument()吗?具体怎么办?
(view1和view2是分割窗口使用的view类)高手救命啊!!快疯了!!谢谢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

解决方案 »

  1.   

    自己写一个,我也是这样做的.public:
    CRegEditSDIDoc* GetDocument(); 定义一个叫GetDocument的函数inline CRegEditSDIDoc* CRegListView::GetDocument()
       { return (CRegEditSDIDoc*)m_pDocument; }这个我是抄着书来做的.原理是这样的.
    CView里面有一个protected的变量m_pDocument保存了对应的文档类的指针,因为是protected的,所以外部不可以直接访问这个m_pDocument,只可以用一个函数来把他取出来.
      

  2.   

    SDI: AfxGetMainWnd()->GetActiveView();
    MDI: AfxGetMainWnd()->GetActiveFrame()->GetActiveView();
         //或者
          AfxGetMainWnd()->MDIGetActive()->GetActiveView();
      

  3.   

    对啊,使用Getdocument就可以啊
    CDocument* pDoc = Getdocument();
    就可以获得文档指针了,有什么问题吗
      

  4.   

    SDI: AfxGetMainWnd()->GetActiveView();
    MDI: AfxGetMainWnd()->GetActiveFrame()->GetActiveView();
         //或者
          AfxGetMainWnd()->MDIGetActive()->GetActiveView();
      

  5.   

    CDocument* pDoc = Getdocument();