CDocument::OnNewDocument()不知道怎么使用?
最好给点代码?我对视图类了解不多!~

解决方案 »

  1.   

    CWinApp()->OnFileNew();ps,CMainFrame 和 CDocument都不应该翻译为试图类吧
      

  2.   

    CWinApp()->OnFileNew();直接就可以?
    好象不行哦
      

  3.   

    Example
    // The following examples illustrate alternative methods of
    // initializing a document object.// Method 1: In an MDI application, the simplest place to do 
    // initialization is in the document constructor.  The framework 
    // always creates a new document object for File New or File Open.CMyDoc::CMyDoc()
    {
       // Do initialization of MDI document here.
       // ...
    }// Method 2: In an SDI or MDI application, do all initialization 
    // in an override of OnNewDocument, if you are certain that
    // the initialization is effectively saved upon File Save
    // and fully restored upon File Open, via serialization.BOOL CMyDoc::OnNewDocument()
    {
       if (!CDocument::OnNewDocument())
          return FALSE;   // Do initialization of new document here.   return TRUE;
    }// Method 3: If the initialization of your document is not
    // effectively saved and restored by serialization (during File Save
    // and File Open), then implement the initialization in single
    // function (named InitMyDocument in this example).  Call the
    // shared initialization function from overrides of both
    // OnNewDocument and OnOpenDocument.BOOL CMyDoc::OnNewDocument()
    {
       if (!CDocument::OnNewDocument())
          return FALSE;   InitMyDocument(); // call your shared initialization function   // If your new document object requires additional initialization
       // not necessary when the document is deserialized via File Open,
       // then perform that additional initialization here.   return TRUE;
    }
      

  4.   

    CMyDoc::OnNewDocument() 访问不了!~怎么访问Virtual!
    C++没学好!~
      

  5.   

    这个函数一般是不需要你直接去调用的。你先弄清楚一下MFC的视图文档结构。
    一般调文档模板去打开一个文档,会自动调用这个函数,并生成相应的框架类和视图类。
    onnewdocument应该是受保护的,你直接去调当然调不了。