我有个问题,找了好久了:在MFC中多文档的程序中,有多个视图,我通过什么代码来激活某个视图呢?????????????????????谢谢了

解决方案 »

  1.   

    CChildFrame *pChild = (CChildFrame *) ((CMainFrame*)theApp.GetMainWnd())->GetActiveFrame();
    CMyDoc* pDoc = NULL;
    pDoc = (CMyDoc*)pChild->GetActiveDocument();
    CView* pView;
    if(pDoc!=NULL)
    {
    POSITION pos=pDoc->GetFirstViewPosition();
    while(pos!=NULL){
    pView=pDoc->GetNextView(pos);
    if(pView->IsKindOf(RUNTIME_CLASS(CMyView)))
    {
    break;
    }
    }
    if(pView->IsKindOf(RUNTIME_CLASS(CMyView)))
    {

    CChildFrame *pChild = (CChildFrame*)pView->GetParentFrame();//获得该view的父窗口
    pChild->MDIActivate();//激活该父窗口

    }
    }
      

  2.   

    pChild->MDIActivate();对没错,谢谢了!!!!