Udostępnij za pośrednictwem


CMultiDocTemplate::CMultiDocTemplate

Konstrukcje CMultiDocTemplate obiektu.

CMultiDocTemplate(
   UINT nIDResource,
   CRuntimeClass* pDocClass,
   CRuntimeClass* pFrameClass,
   CRuntimeClass* pViewClass 
);

Parametry

  • nIDResource
    Określa identyfikator zasobów używane z typu dokumentu.Może to obejmować menu, ikon, akcelerator tabeli i zasobów ciągu.

    Zasób ciągu składa się z maksymalnie siedem podciągów oddzielone znakiem "\n" (znak "\n" jest potrzebny jako symbol zastępczy, jeśli nie jest włączone; podciągu Jednakże końcowe znaki "\n" nie są konieczne); te podciągów opis typu dokumentu.Informacji na temat podciągów, zobacz CDocTemplate::GetDocString.Ten ciąg zasób znajduje się w pliku zasobu aplikacji.Na przykład:

    // MYCALC.RC

    STRINGTABLE PRELOAD DISCARDABLE

    BEGIN

    IDR_SHEETTYPE "\nSheet\nWorksheet\nWorksheets (*.myc)\n.myc\n MyCalcSheet\nMyCalc Worksheet"

    END

    Należy zauważyć, że ciąg rozpoczyna się od znaków "\n"; jest tak, ponieważ pierwszego podciągu nie jest używany dla aplikacji MDI i tak nie jest włączone.Można edytować ten ciąg, korzystając z Edytora ciągu; cały ciąg jest wyświetlany jako pojedynczy wpis w edytorze ciąg nie jako oddzielne wpisy siedem.

    Aby uzyskać więcej informacji o tych typach zasobów, zobacz Zasobów edytory.

  • pDocClass
    Wskazuje na CRuntimeClass obiektu klasy dokumentu.Ta klasa jest CDocument-klasy zdefiniować do reprezentowania dokumentów.

  • pFrameClass
    Wskazuje na CRuntimeClass obiektu klasy okno ramek.Ta klasa może być CMDIChildWnd-klasy lub może być CMDIChildWnd sobie Jeśli domyślne zachowanie ramki okien dokumentu.

  • pViewClass
    Wskazuje na CRuntimeClass obiektu klasy widoku.Ta klasa jest CView-klasy zdefiniować do wyświetlania dokumentów.

Uwagi

Dynamicznie przydzielić jedną CMultiDocTemplate obiektu dla każdego typu dokumentu, który aplikacja obsługuje i przechodzą na CWinApp::AddDocTemplate z InitInstance funkcji składowej klasy aplikacji.

Przykład

// Code fragment from CMyApp::InitInstance

// Establish all of the document types
// supported by the application

AddDocTemplate(new CMultiDocTemplate(IDR_BRUSHDOCTYPE,
   RUNTIME_CLASS(CBrushDoc),
   RUNTIME_CLASS(CChildFrame),
   RUNTIME_CLASS(CBrushView)));

AddDocTemplate(new CMultiDocTemplate(IDR_DCDOCTYPE,
   RUNTIME_CLASS(CDCDoc),
   RUNTIME_CLASS(CChildFrame),
   RUNTIME_CLASS(CDCView)));

Oto przykład drugiego.

// Code fragment taken from CMyApp::InitInstance

// Normally, an application creates a document 
// template and registers it with MFC as a part
// of its initialization.

// IDR_EXAMPLEDOCTYPE is a resource ID string; see
// the CDocTemplate class overview documentation
// for more information on its format.

// The next three parameters use the RUNTIME_CLASS()
// macro to get runtime type information for the doc,
// frame, and view classes that will be associated
// by the template.

pDocTemplate = new CMultiDocTemplate(IDR_EXAMPLEDOCTYPE,
   RUNTIME_CLASS(CExampleDoc),
   RUNTIME_CLASS(CChildFrame),
   RUNTIME_CLASS(CExampleView));
if (!pDocTemplate)
   return FALSE;

// After the following call, MFC is aware of the doc
// template and will free it when the application is
// shut down. The doc templates known to MFC will
// automatically be used when CWinApp:OnFileOpen()
// or CWinApp::OnFileNew() are called.

AddDocTemplate(pDocTemplate);

Wymagania

Nagłówek: afxwin.h

Zobacz też

Informacje

Klasa CMultiDocTemplate

Wykres hierarchii

CDocTemplate::GetDocString

CWinApp::AddDocTemplate

CWinApp::InitInstance

Struktura CRuntimeClass