CMultiDocTemplate::CMultiDocTemplate
CMultiDocTemplate オブジェクトを構築します。
CMultiDocTemplate(
UINT nIDResource,
CRuntimeClass* pDocClass,
CRuntimeClass* pFrameClass,
CRuntimeClass* pViewClass
);
パラメーター
nIDResource
ドキュメントの型に使用するリソース id を指定します。これは、メニュー、アイコン、アクセラレータ テーブルと文字列リソースが含まれる場合があります。The string リソースは「\ n 文字で構成されます (「\ n の区切られた 7 つまでの部分文字列から部分文字列が含まれている場所の所有者として必要です。文字; ただし、末尾に「\ 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-ドキュメントを表示する際に定義した派生クラスです。
解説
動的に、アプリケーションのクラスの InitInstance のメンバー関数からの CWinApp::AddDocTemplate に各ドキュメントの種類の CMultiDocTemplate の 1 種類のオブジェクトを、アプリケーションでサポートする各パスと代入します。
使用例
// 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)));
2 番目の例を次に示します。
// 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