我建了一个基于SDI的工程,建好以后新建一个对话框,根据这个对话框生成Dialog1.cpp和 Dialog1.h,然后新建一个菜单项,运行的时候单击它就弹出对话框。   我要在Dialog中得到视图的指针,但是★在Dialog1.cpp中嵌入***View.h会报错★,
错误如下:
error C2143: syntax error : missing ';' before '*'
error C2501: 'C***Doc' : missing storage-class or type specifiers
error C2501: 'GetDocument' : missing storage-class or type specifiers   要想在Dialog.cpp中得到视图的指针应该怎样做??

解决方案 »

  1.   

    void CMainFrame::OnButton() 
    {
    CExdlg dlg(this->GetActiveView());
    dlg.DoModal();
    }class CMfcex1View;
    class CExdlg : public CDialog
    {
    // Construction
    public:
    CExdlg(CWnd* pParent = NULL);   // standard constructor CExdlg(CMfcex1View * pView);   // standard constructor
    CEx1View * m_pView;
    ..
    }CExdlg::CExdlg(CMfcex1View *pView)
    : CDialog(CExdlg::IDD, NULL)
    {
    //{{AFX_DATA_INIT(CExdlg)
    m_pView = pView;
    //}}AFX_DATA_INIT
    }
      

  2.   

    少什么头文件?我在Dialog.cpp里加视图的头文件#include "***View.h"怎么报错啊?
      

  3.   

    xlzxlich(阳光) ( ) 信誉:100    
    -----------------------------------
    我在Dialog.cpp里的函数里,用m_pView->Invalidate(TRUE);怎么报错啊?
    错误:
    error C2027: use of undefined type 'CDateJishuView'
    error C2227: left of '->Invalidate' must point to class/struct/union
      

  4.   

    在Dialog.cpp里应该怎么得到视图的指针啊?上面的方法生成的时候是对的,但是调用的时候用它的对象不能调用视图中函数啊??我得到视图的指针就是想调用它的Invalidate()来控制视图的OnDraw()啊!
      

  5.   

    在你对***View.h 文件里面添加#include "XXXXDoc.h"