请问如何在CView的代码片断中访问CMainFrame中的变量.
比如,CMainFrame中有一个m_wndToolBar,我如何在CView中访问它??

解决方案 »

  1.   

    CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;
      

  2.   

    CMainFrame *pMain=(CMaimFrame *)AfxGetApp()->m_pMainWnd;
      

  3.   

    pMain就是你要的CMainFrame指针然后pMain->m_wndToolBar   就可以访问CMainFrame的变量了
      

  4.   

    不行阿,编译的时候抱错:
    --------------------Configuration: try - Win32 Debug--------------------
    Compiling...
    tryView.cpp
    E:\try\tryView.cpp(65) : error C2065: 'CMainFrame' : undeclared identifier
    E:\try\tryView.cpp(65) : error C2065: 'pMain' : undeclared identifier
    E:\try\tryView.cpp(65) : error C2065: 'CMainFreme' : undeclared identifier
    E:\try\tryView.cpp(65) : error C2059: syntax error : ')'
    Error executing cl.exe.try.exe - 4 error(s), 0 warning(s)
      

  5.   

    你还没有在View中加include"mainfrm.h"啊。
      

  6.   

    nodC***View.cpp文件头部加入include"mainfrm.h"