不知道题目说明白没有。我的程序有点像Outlook:
Outlook点击左面的OutlookBar的按纽可以在右面的框架中切换视图,比如点击Outlook Today,右面会显示单一的视图,但是如果点击邮件夹Index,右面就会显示切分窗口,上面是ListView,下面是个CView,也就是说我想在运行时动态创建切分视图和动态切换视图。我知道有一个CMainFrame::SwitchToView的例子,但是那个只能切换单一的视,不能把视图1换成由视图2和视图3组成的切分窗口或换回来。请首长指示。

解决方案 »

  1.   

    我倒是作过这种界面,也不是太难,就是要动态切分窗口。
    例如你的切分窗口是
    CSplitterWnd m_Dynwnd;
    你在ChildFrame的OnCreateClient里不要用m_Dynwnd.CreateStatic和m_Dynwnd.CreateView,
    而要用Create,因为需要动态切分。在你要切分的地方用SplitColumn或者SplitRow来动态切分。不过好像最多只能
    动态切分成4个窗口。
      

  2.   

    对了,别忘了最后调用RecalcLayout()重绘。
      

  3.   

    fireant25, 你说的是动态切分把,我的问题是界面的动态切换。即把界面在单视图CView1(如Outlook的Today视图)和CView2(如Outlook的收件箱视图)、CView3(如Outlook的邮件预览视图)组成的上下静态切分窗间的切换。
      

  4.   

    我要的是类似这种效果:
    http://61.133.87.165/bbs/attachment.php?s=&postid=432958
      

  5.   

    就是切换视图吧,一个文档对象,对应多个视,在CFramWnd里可以处理
    给你一段代码,这个例子说明了如何在两个视之间切换
    BOOL CMainFrame::OnViewChange(UINT nCmdID)
    // There is an ON_COMMAND_RANGE message map entry associated with
    // OnViewChange:
    // ON_COMMAND_RANGE( ID_VIEW_VIEW1, ID_VIEW_VIEW2, OnViewChange)
    {
     CView* pViewAdd;
     CView* pViewRemove;
     CDocument* pDoc = GetActiveDocument(); if((nCmdID == ID_VIEW_VIEW1) && (m_currentView == 1))
        return;
     if((nCmdID == ID_VIEW_VIEW2) && (m_currentView == 2))
       return; if (nCmdID == ID_VIEW_VIEW2)
     {
      if (m_pView2 == NULL)
      {
       m_pView1 = GetActiveView();
       m_pView2 = new CMyView2;//Note that if OnSize has been overridden in CMyView2 
    //and GetDocument() is used in this override it can 
    //cause assertions and, if the assertions are ignored,
    //cause access violation.
      
       m_pView2->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
          rectDefault, this, AFX_IDW_PANE_FIRST + 1, NULL);
      }
       pViewAdd = m_pView2;
       pViewRemove = m_pView1;
       m_currentView= 2;
     }
     else
     {
      pViewAdd = m_pView1;
      pViewRemove = m_pView2;
      m_currentView= 1;
     }
         
    // Set the child i.d. of the active view to AFX_IDW_PANE_FIRST,
    // so that CFrameWnd::RecalcLayout will allocate to this 
    // "first pane" that portion of   the frame window's client area 
    // not allocated to control   bars.  Set the child i.d. of the 
    // other view to anything other than AFX_IDW_PANE_FIRST; this
    // examples switches the child id's of the two views. int nSwitchChildID = pViewAdd->GetDlgCtrlID();
     pViewAdd->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
     pViewRemove->SetDlgCtrlID(nSwitchChildID); // Show the newly active view and hide the inactive view. pViewAdd->ShowWindow(SW_SHOW);
     pViewRemove->ShowWindow(SW_HIDE); // Connect the newly active view to the document, and
     // disconnect the inactive view.
     pDoc->AddView(pViewAdd);
     pDoc->RemoveView(pViewRemove); SetActiveView(pViewAdd);
     RecalcLayout();
    }
      

  6.   

    myheart8541_cn(i++),我已经说过了不是切换两个单一视图,而是切换单一视图和切分窗口界面.
      

  7.   

    那应该是切换两个CChildFrame对么?
      

  8.   

    你给我的例子我看了,感觉就是动态切分啊。我这里有个例子,带源码的。你留下email
      

  9.   

    fireant25,我收到你的例子了, 不过这个似乎无法解决我的问题. 你这个例子的思路是建立一个左右拆分的窗口,然后在右面继续拆分. 换句话说, 整个界面至少要分成两个View才可以.但是我的程序要求最少只有一个View.
      

  10.   

    我找到类似的答案了,谢谢各位:
    http://www.codeguru.com/mfc/comments/7113.shtml