怎样得到当前所有已经打开的所有View,并且自动Active其中某一个?
其中VIEW有可能是同一类型,也有可能是不同的类型。

解决方案 »

  1.   

    CDocument 成员函数:
    GetFirstViewPosition
    GetNextView可以得到所有视图CFrameWnd 成员函数:
    SetActiveView 
    GetActiveView 
    取得活动视图 和 激活为活动视图 
    ================================================================
    Country roads, take me home to the place I belong, West
    0AVirginia, Mountain Mama. Take me home, country roads.
    ================================================================
      

  2.   

    利用文档类的成员函数GetFirstViewPosition和GetNextView来遍历每一个view
    POSITION pos=GetFirstViewPosition();
    while(pos)
    {
         CView* pView=GetNextView(pos);
         if(pView满足条件)
         {
             CFrameWnd* pParentFrame=(CFrameWnd*)pView->GetParent();
    pParentFrame->SetActiveView(pView);
         }
    }
      

  3.   

    利用文档类的成员函数GetFirstViewPosition和GetNextView来遍历每一个view
    POSITION pos=GetFirstViewPosition();
    while(pos)
    {
         CView* pView=GetNextView(pos);
         if(pView满足条件)
         {
             CFrameWnd* pParentFrame=(CFrameWnd*)pView->GetParent();
    pParentFrame->SetActiveView(pView);
         }
    }
      

  4.   

    LPTSTR lpSearch = new char[128];
    CString str;
    HWND hWnd = ::GetWindow(AfxGetApp()->m_pMainWnd->m_hWnd,GW_HWNDFIRST);  
         
     //遍历所有窗口以找到子进程的主窗口
    while(hWnd)
    {  
        ::GetWindowText(hWnd,lpSearch,128);  
         str.Format("%s",lpSearch);
        if(str.Find(strWndText,0) >=0 )    
             {
                   // find all
    }
        else
             hWnd = ::GetWindow(hWnd,GW_HWNDNEXT);  
    }
     
    delete[] lpSearch;
      

  5.   

    我怎么只得到一个view呢,我是想得到所有view的对象,不是view类
      

  6.   

    程序如下: POSITION p1;
    p1 = pDocTemplate->GetFirstDocPosition();
    if (p1 != NULL){
    pDocument = pDocTemplate->GetNextDoc(p1);
    POSITION p2;
    p2 = pDocument->GetFirstViewPosition();
    while(p2 != NULL){
    i++;
    pView = pDocument->GetNextView(p2);
    }
    itoa(i, temp, 10);
    AfxMessageBox(temp);
    }怎么总是1呢??
      

  7.   

    比如说我已经打开了10个view,都是相同的类型
    但是我用上面的程序总是得到1请大家在帮帮忙