MDI程序中,要求打开的子窗口被分割成3个部分,该如何处理?是不是在CChildFrame::OnCreateClient()中分割视图啊。

解决方案 »

  1.   

    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if (!m_wndSplitter.CreateStatic(this, 3, 1))
    {
    TRACE0("Failed to Create StaticSplitter\n");
    return FALSE;
    } CRect rect;
    GetClientRect(rect);
    CSize init(rect.Width(), rect.Height()/3); if (!m_wndSplitter.CreateView(0, 0, 
    RUNTIME_CLASS(CView1), init, pContext))
    {
    TRACE0("Failed to create first pane\n");
    return FALSE;
    } if (!m_wndSplitter.CreateView(1, 0, 
    RUNTIME_CLASS(CView2), init, pContext))
    {
    TRACE0("Failed to create second pane\n");
    return FALSE;
    } if (!m_wndSplitter.CreateView(2, 0, 
    RUNTIME_CLASS(CView3), init, pContext))
    {
    TRACE0("Failed to create third pane\n");
    return FALSE;
    }
    SetActiveView((CView*)m_wndSplitter.GetPane(0, 0)); return TRUE;
    }
      

  2.   

    试了一下运行到if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CView1), init, pContext))时出错,CView1的基类这里是CFormView.
      

  3.   

    任意分割:
    http://www.vckbase.com/document/viewdoc/?id=192
      

  4.   

    将CView1的基类改为CView后,程序在
    BOOL CTMOApp::InitInstance()
    {
    .....
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;
    ....
    }
    处出错,在出错的这句前加上
    if(cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew)//MDI启动时不产生子窗口
    cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
    程序运行成功,显示出来的界面确实分割成了3部分,但是点击新建时还是会出错,不知道什么原因.
      

  5.   

    上面的这个例子我看过,讲的是单文档的,我的是多文档,要求打开的子窗口分割成3部分.所以问是不是在CChildFrame::OnCreateClient()中输入代码分割视图.再试一下:)
      

  6.   

    哈哈,成功了,是在CChildFrame::OnCreateClient()中输入代码分割视图,不过当CView1的基类是CFormView时就出错,不知道是什么原因。