我在CMainFrame中定义了些函数,现在想从CFormView中得到数据让CMainFrame中的函数来处理!请问用什么方法调用呀????????谢谢!!!

解决方案 »

  1.   


    #include "MainFrm.h"
    CXXXView::OnXXXXX()
    {
      CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;  .......
      .......
    }
      

  2.   

    怎能在CFormview里定义数据了,应该在CFormDocument里面定义数据吧
      

  3.   

    不行就搞成全局变量,用extern调用。
      

  4.   

    (CMainFrame *)frame = (CMainFrame *)AfxGetMainWnd();
    frame->Func()
      

  5.   

    别的方法也很多,全局变量也可以.就是我想结构上不是很好把.应该尽量少用的.
    MS的Dv模型其实应该让D来进行处理数据运算的,他是核心
      

  6.   

    (CMainFrame *)frame = (CMainFrame *)GetParent();
      

  7.   

    (CMainFrame *)pFrame = (CMainFrame *)GetParent();
    pFrame->OnFun();
      

  8.   

    在视图中可以操作CMainFrame对象,这一点最重要了
    CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;然后你可以在CMainFrame中定义一些public的方法供外部调用
    pFrame->MethodName()
    ....