不需要转发,直接在view中加入消息处理函数好了

解决方案 »

  1.   

    得到视图指针,然后SendMessage
      

  2.   

    LRESULT SendMessage(
      HWND hWnd,      // handle of destination window
      UINT Msg,       // message to send
      WPARAM wParam,  // first message parameter
      LPARAM lParam   // second message parameter
    );
    这是api函数,可以选择向感兴趣的窗口发消息,而不像mfc封装的那样死板。
    PostMessage()也有类似的api。
      

  3.   

    可以在View 初始化时,将对象指针存放到MainFrame中,以后用该对象指针发送消息即可。
      

  4.   

    我还有一个小问题了,我怎么在CMainFrame中调用我自己的视图类的函数,我用#include "CMyView"就会出错,那我应该怎么做
      

  5.   

    假设你的程序是多文档
    CMDIFrameWnd *pFrame = 
                 (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;// Get the active MDI child window.
    CMDIChildWnd *pChild = 
                 (CMDIChildWnd *) pFrame->GetActiveFrame();// or CMDIChildWnd *pChild = pFrame->MDIGetActive();// Get the active view attached to the active MDI child
    // window.
    CMyView *pView = (CMyView *) pChild->GetActiveView();如果是单文档:
    CMyChild *child = GetActiveFrame();
    CMyView *view  =  child->GetActiveView();
      

  6.   

    CMyChild *child = GetActiveFrame();
    CMyView *pView  =  child->GetActiveView();
    pView->PostMessage(message,wParam,lParam);