本程序有两个视图,一个是CMyEditView,另一个是CMyScrollView,希望通过对主菜单中两个相应的菜单项("新建MyEditView","新建MyScrollView")的点击,可以分别触发上述两个view.求实现思路和代码.尤其是在MDI环境下.谢谢高手回答!

解决方案 »

  1.   

    你应该在frame中响应相应的代码,通过每次新建一个那个类型的view就可以实现了
      

  2.   

    在主Frame中处理对应的菜单Command 消息;调用对应View的DocTemplate的OpenDocumentFile函数
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_CREATE()
    ON_COMMAND(ID_MENU_EDITFMT, OnMenuEditfmt)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    void CMainFrame::OnMenuEditfmt() 
    {
       CWnApp * pApp = (CWnApp *) AfxGetApp();
       pApp->pFmtDocTemplate->OpenDocumentFile(NULL);
      

  3.   

    已经初步实现,somexing(张星星) 的思路是正确的.谢谢.
    调用CDocTemplate的OpenDocumentFile函数
      

  4.   

    This method opens the file whose pathname is specified by lpszPathName. If lpszPathName is NULL, a new file, containing a document of the type associated with this template, is created.virtual CDocument* OpenDocumentFile(
    LPCTSTR lpszPathName,
    BOOL bMakeVisible = TRUE ) = 0;