FormView所需要的Dialog,已经建立好了,相应的FormView的类也创建了(例如FormTestView)。现在我要通过菜单命令,来创建这个FormView,试了几下不行,特来求教。好像是Template错误。

解决方案 »

  1.   


    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CTestDoc),
    RUNTIME_CLASS(CMainFrame),      
    RUNTIME_CLASS(FormTestView));
    pDocTemplate->CreateNewDocument() ; 
    我的代码在家里,具体我记不清楚了,就是上面的思路
      

  2.   

    //  作为一个WinApp的方法
     pDocTemplate = m_DocTemplate;    // 取得与要创建子窗口关联的文档模板// 做成一个新的文档对象
     CDocument *pDoc = pDocTemplate->CreateNewDocument ();
     ASSERT_VALID (pDoc);
     pDoc->OnNewDocument ();// 做成一个MDI子框架
     CFrameWnd* pNewFrame = pDocTemplate->CreateNewFrame(pDoc, NULL);
     if (pNewFrame == NULL) {  // 失败
       return NULL
     }// 显示
     pDocTemplate->InitialUpdateFrame(pNewFrame, pDoc); pDoc->SetTitle ("Test");
     pDoc->UpdateAllViews (NULL);
      

  3.   

    是用CSingleDocTemplate,不是CMultiDocTemplate?