默认情况下多文档好像只有一个子窗口,想实现这样一个功能:
在多文档的主窗口上添加一些菜单项,每点一个菜单项先前的子窗口会被新弹出的窗口覆盖。问题是:
怎样向这个多文档工程添加多个子窗口,谢谢各位啦。

解决方案 »

  1.   

    重载框架的 virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);如:
    加一个成员变量
    CCreateContext m_Context;BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
    {
    // TODO: 在此添加专用代码和/或调用基类
    m_Context.m_pCurrentDoc = pContext->m_pCurrentDoc;
    m_Context.m_pCurrentFrame = pContext->m_pCurrentFrame;
    m_Context.m_pLastView = pContext->m_pLastView;
    m_Context.m_pNewDocTemplate = pContext->m_pNewDocTemplate;
    m_Context.m_pNewViewClass = pContext->m_pNewViewClass; return CFrameWnd::OnCreateClient(lpcs, pContext);
    }//响应菜单命令
    void CMainFrame::OnView1()
    {
          m_Context.m_pNewViewClass= RUNTIME_CLASS(CView1);//CView1是你自己的视图类,如果从CFormView派生,就可以像对话框一样在上面加控件了
          CreateNewView();
    }void CMainFrame::CreateNewView()
    {
    CView * pActiveView= GetActiveView(); CDocument * pDoc= pActiveView->GetDocument(); pDoc->m_bAutoDelete=FALSE;    
    pActiveView->DestroyWindow();
    pDoc->m_bAutoDelete=TRUE;     CView* p = (CView*)CreateView(&m_Context, AFX_IDW_PANE_FIRST); SetActiveView(p);
    p->OnInitialUpdate();
    RecalcLayout();
    }
      

  2.   

    窗口框架当然只能有一个呀  想建另外的框架得重载虚拟函数 OnCreateClient  VIEW可以有N多个  在APP里面建多个模板就可以了
      

  3.   

    你是想一个文档对应多个VIEW?
      

  4.   

    我可以给你个步骤:
    1.建立多个文档模板
    CMultiDocTemplate* GetTestPointDocTemplate(void);
    2.建立多个文档CTestPointView
    3.建立多个视图CTestPointDocm_pTestPointDocTemplate = new CMultiDocTemplate(IDR_EMPTYDOCTYPE,
    RUNTIME_CLASS(CTestPointDoc),
    RUNTIME_CLASS(CChildFrame),
    RUNTIME_CLASS(CTestPointView)); 
    if (!m_pTestPointDocTemplate)
    return FALSE;
    AddDocTemplate(m_pTestPointDocTemplate);
    双击时可以用文档的OpenView函数打开视图
      

  5.   

    刚才写错了
    建立文档模板
    CMultiDocTemplate* m_pTestPointDocTemplate;
    你要实现你的功能要多查资料