你在定义CMydialog dia(this); 时将视图的指针带入dialog 中,然后在dialog 中pParent->GetDocument();就行了

解决方案 »

  1.   

    CDocument* pActiveDocument=
    ((CMDIFrameWnd*)AfxGetMainWnd())
            ->GetActiveFrame()->GetActiveDocument()
      

  2.   

    CDocument* pActiveDocument=((CMDIFrameWnd*)AfxGetMainWnd())
            ->GetActiveFrame()->GetActiveDocument()
      

  3.   

    何必这么累呢,
    在对话框类里加入一个文档指针,在定义对话框对象是把文档指针赋给它
    CMyDlg dlg;
    dlg.m_pMyDoc=pDoc;
    dlg.DoModel();
      

  4.   

    CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
    CDocument* pDoc=pFrame->GetActiveDocument();
    如果要得到你自己的Doc,则
    CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
    CMyDoc* pDoc=(CMyDoc*)pFrame->GetActiveDocument();
    且在对话框上加上#include "MyDoc.h"
      

  5.   

    在view里:
    CXXXDialog* pXXXDlg=NULL;
    if(!pDateDlg)
    {
        pXXXDlg=new CXXXDialog(this);
        ASSERT(pXXXDlg);
    }
    在dialog的构造函数里:
    CXXXDialog::CXXXDialog(CWnd* pParent /*=NULL*/)
    : CDialog(CXXXDialog::IDD, pParent)
    {
        ……
        ……
        m_pView=(CYourView*)pParent;    
        //m_pView的定义:CYourView* m_pView;                           
    }
    doc的指针:
        CYourDoc* pDoc=m_pView->GetDocument();
        return pDoc;