做了一个单文档界面,并在菜单中添加了一选项。
当程序启动后,点击该选项,弹出一对话框,当关闭对话框后,单文档的界面将被切分(切分功能已完成)。想知道如何连接这个过程:关闭对话框->切分界面?
求教高手!!!!

解决方案 »

  1.   

    OnMenuYourCommand()
    {
    if(dlg.DoModal()==IDOK)
    {
    切分
    }
    }
      

  2.   

    下面是我的代码,执行有问题:m_userdlg.DoModal();


    if (!m_wndSplitter.CreateStatic(this, 1, 2))
    {
    TRACE0("Failed to create splitter window\n");
    }

    // Get the client rect first for calc left pane size

    CRect rect;
    GetClientRect(&rect); CCreateContext pContext;
             //pContext.m_pNewViewClass=RUNTIME_CLASS(CLeftPaneView);
    pContext.m_pCurrentDoc=((CSdiApp*)AfxGetApp())->m_pDoc;
    pContext.m_pCurrentFrame=this;
    pContext.m_pNewDocTemplate=pContext.m_pCurrentDoc->GetDocTemplate();
    pContext.m_pLastView=(CView*)m_wndSplitter.GetPane(0,0);
    /*
    CCreateContext pContext1;
             pContext1.m_pNewViewClass=RUNTIME_CLASS(CRightPaneFrame);
    pContext1.m_pCurrentDoc=((CSdiApp*)AfxGetApp())->m_pDoc;
    pContext1.m_pCurrentFrame=this;
    pContext1.m_pNewDocTemplate=pContext1.m_pCurrentDoc->GetDocTemplate();
    pContext1.m_pLastView=(CView*)m_wndSplitter.GetPane(0,1);
    */ // create the left tree view first.
    if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftPaneView), CSize(rect.Width()/3, 0), &pContext))
    {
    TRACE0("Failed to create left pane view\n");
    } // The right pane is a frame which and contain several different views.
    // The is can be set to active or non-active
    if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightPaneFrame), CSize(0, 0), &pContext))
    {
    TRACE0("Failed to create right pane frame\n");
    } CLeftPaneView* pLeftPaneView     = (CLeftPaneView*) m_wndSplitter.GetPane(0,0);
    pLeftPaneView->m_pRightPaneFrame = (CRightPaneFrame*) m_wndSplitter.GetPane(0,1);

    // Set the left pane as the active view
    SetActiveView((CView*) m_wndSplitter.GetPane(0, 0));pContext.m_pLastView=(CView*)m_wndSplitter.GetPane(0,0);有问题
    求教是什么原因?
      

  3.   

    放在你的mainframe的OnCreateClient里做切分
    比如说一个简单的左右切分:
    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
        CCreateContext* pContext)
    {
    if (!m_wndSplitter.CreateStatic(this, 1, 2))
        return FALSE;if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(200, 100), pContext) ||
            !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), CSize(100, 100), pContext))
        {
            m_wndSplitter.DestroyWindow();
            return FALSE;
        }
        return TRUE;
    }就这样了……m_wndSplitter是个CSplitterWnd,CLeftView CRightView是你的两个View 
      

  4.   

    同意  CQP(悄悄的我走了,正如我悄悄的来)
      

  5.   

    m_userdlg.DoModal();       
    if(m_userdlg.DoModal==IDOK)   //  add by me
    {
    //Splitter  your  windows
    }
      

  6.   

    关键是对话框关闭后,能否使mainframe的OnCreateClient执行!如果mainframe的OnCreateClient在对话框关闭后才执行那就没问题,如果不是,那就要想办法了切分谁都会。
      

  7.   

    谢谢zhdleo(叮东)帮我讲清楚了