想向一个指定的view发送消息,但是不知道如何才能得到这个的句柄,请赐教!

解决方案 »

  1.   

    CFrameWnd::GetActiveView()得到当前的活动视图
      

  2.   

    // Function fills a list of all views in the application
    void DocUtil::GetAllViews(ViewList_t &Views)
    {
      CWinApp *pApp = AfxGetApp();
      CDocManager *pDocMgr = pApp->m_pDocManager;
      // For all document templates
      for(POSITION TmplPos = pDocMgr->GetFirstDocTemplatePosition();
      TmplPos;)
      {
        CDocTemplate *pTmpl = pDocMgr->GetNextDocTemplate(TmplPos);
        ASSERT_VALID(pTmpl);
        // For All open documents of this document template type.
        for(POSITION Pos = pTmpl->GetFirstDocPosition();Pos;) 
        {
          CDocument *pDoc = pTmpl->GetNextDoc(Pos);      
          // For all views of this document
          POSITION ViewPos = pDoc->GetFirstViewPosition();
          while(ViewPos)
          {
            CView *pView =  pDoc->GetNextView(ViewPos); 
            Views.AddTail(pView);
          }
        }
      }
    }
    http://www.michaelmoser.org/tip3.htm
      

  3.   

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

  4.   

    CMyView *pView = (CMyView *) pChild->GetActiveView();
      

  5.   

    忘了你要的是句柄。得到pView,用GetSafeHwnd()就可得到句柄了