다음을 통해 공유


CMultiDocTemplate::CMultiDocTemplate

CMultiDocTemplate 개체를 생성합니다.

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

매개 변수

  • nIDResource
    문서 형식에 사용 되는 리소스의 ID를 지정 합니다. 이 메뉴, 아이콘, 액셀러레이터 테이블 및 문자열 리소스가 포함 될 수 있습니다.

    최대 7 개의 부분 문자열 (부분 문자열 포함 하 고 있으면 '\n' 문자는 자리 표시자로 필요한 '\n' 문자로 구분 된 문자열 리소스 구성 그러나 '\n' 문자 뒤에 오는 필요 하지 않습니다). 이러한 문자열 문서 형식에 설명합니다. 부분 문자열에 대 한 자세한 내용은 CDocTemplate::GetDocString. 응용 프로그램의 리소스 파일에 문자열 리소스를 찾을 수 있습니다. 예를 들면 다음과 같습니다.

    // MYCALC.RC

    STRINGTABLE PRELOAD DISCARDABLE

    BEGIN

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

    END

    문자열 '\n' 문자로 시작 하는 참고. 첫 번째 부분 문자열 MDI 응용 프로그램에 사용 되지 않고 따라서 포함 된 때문입니다. 문자열 편집기를 사용 하 여이 문자열을 편집할 수 있습니다. 전체 문자열 문자열 편집기에서 단일 항목으로 않는 7 가지 별도 항목으로 나타납니다.

    이러한 리소스 종류에 대 한 자세한 내용은 리소스 편집기.

  • pDocClass
    가리키는 있는 CRuntimeClass 문서 클래스의 개체입니다. 이 클래스는 CDocument-사용자 정의 문서를 나타내는 클래스를 파생 합니다.

  • pFrameClass
    가리키는 있는 CRuntimeClass 프레임 창 클래스의 개체입니다. 이 클래스 수는 CMDIChildWnd-클래스에서 파생 된 또는 수 있습니다 CMDIChildWnd 자체 문서 프레임 창에 대 한 기본 동작을 원하는 경우.

  • pViewClass
    가리키는 있는 CRuntimeClass 뷰 클래스의 개체입니다. 이 클래스는 CView-파생 클래스를 정의 하 여 문서를 표시 합니다.

설명

하나를 동적으로 할당 CMultiDocTemplate 개체 응용 프로그램을 지원 하 고 각 배열에 전달 하는 각 문서 형식에 대 한 CWinApp::AddDocTemplate 에서 InitInstance 응용 프로그램 클래스의 멤버 함수입니다.

예제

// 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)));

두 번째 예제는 다음과 같습니다.

// 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);

요구 사항

헤더: afxwin.h

참고 항목

참조

CMultiDocTemplate 클래스

계층 구조 차트

CDocTemplate::GetDocString

CWinApp::AddDocTemplate

CWinApp::InitInstance

CRuntimeClass 구조체