工程Aaa,最开始的视图是AaaView,后来又打开了多个基于CFormView的视图如:BbbView,CccView,DddView, 假如当前视图是DddView, 请问如何得到AaaView的句柄CView *pView = (CFormView *)GetActiveView();只能得到当前视图

解决方案 »

  1.   

    If you save the handle of the AaaView, you will get the AaaView at anytime. You can save it in the MainFrame.CPP when you open the other view.
      

  2.   

    CDocument类有GetFirstViewPosition()和GetNextView()通过这他们,我们可以获得任何View.
    在CDocument类中添加函数如下:
    CView* CAaaDocumentDoc::GetAnyView(void)
    {
        POSITION pos;
        pos=GetFirstViewPosition();
        CView* pView;
        while(pos!=NULL)
        {
           pView=GetNextView(pos);
    //用此方法同样可以获得其它View.
           if(pView->IsKindOf(RUNTIME_CLASS(CAaaView)))
           {
    break;
           }
         }
    return pView;
    }////FormView中调用((CAaaView*)GetDocument()->GetAnyView())->TestMessageBox();