Document Template 과 Resource String과의 관계
App의 InitInstance를 들여다 보면 다음과 같이 Document Template을 추가하는 코드를 볼 수 있다. AddDocTemplate의 파라미터로,
첫째는 IDR_??? 과 같은 Resource ID,
둘째는 Document 클래스
셋째는 Child Wnd 클래스
넷째는 View 클래스를
넘겨 준다.
//example for CMultiDocTemplate BOOL CMyApp::InitInstance() { // ... // Establish
all of the document types // supported
by the application
AddDocTemplate( new CMultiDocTemplate( IDR_SHEETTYPE,
RUNTIME_CLASS( CSheetDoc ), RUNTIME_CLASS( CMDIChildWnd ),
RUNTIME_CLASS( CSheetView )
) ); // ... } |
위 예제의 경우 IDR_SHEETTYPE 이라는 리소스 아이디를 넘겨주는데, 이 아이디와 연결된 리소스 문자열이 아래와 같다고 하자.
// MYCALC.RC STRINGTABLE PRELOAD DISCARDABLE BEGIN IDR_SHEETTYPE
"\nSheet\nWorksheet\nWorksheets (*.myc)\n.myc\n MyCalcSheet\nMyCalc
Worksheet" END |
‘ \n ’으로 구분된 문자열을 볼 수 있는데, 각각이 뜻하는 바는 CDocTemplate 의 GetDocString() 함수와 관련이 있으며, DocStringIndex 와 관련된 설명이 MSDN에 자세하게 나와있다.
class CDocTemplate { …… enum DocStringIndex { windowTitle,
// default window title docName,
// user visible name for default document fileNewName,
// user visible name for FileNew // for file based documents: filterName,
// user visible name for FileOpen filterExt,
// user visible extension for FileOpen // for file based documents with Shell open support: regFileTypeId,
// REGEDIT visible registered file type
identifier regFileTypeName,
// Shell visible registered file type name }; virtual BOOL GetDocString ( CString& rString, enum
DocStringIndex index ) const; …… }; |
- CDocTemplate::windowTitle Name
that appears in the application window's title bar (for example,
"Microsoft Excel"). Present only in the document template for
SDI applications.
à 디폴트 윈도우 제목
- CDocTemplate::docName Root
for the default document name (for example, "Sheet"). This root,
plus a number, is used for the default name of a new document of this type
whenever the user chooses the New command from the File menu (for example,
"Sheet1" or "Sheet2"). If not specified,
"Untitled" is used as the default.
à 디폴트 다큐먼트 이름
- CDocTemplate::fileNewName Name
of this document type. If the application supports more than one type of
document, this string is displayed in the File New dialog box (for
example, "Worksheet"). If not specified, the document type is
inaccessible using the File New command.
à 여러 문서 타입을 지원할 경우, File New 명령을 위한 다큐먼트 이름. Template이 여러 개일 경우 File New 명령을 호출하면 Template 을 선택할 수 있는 대화상자가 나타난다. 이때 표시되는 이름이며, 만약 이름이 지정되어 있지 않으면 대화상자에 나타나지 않는다.
- CDocTemplate::filterName Description
of the document type and a wildcard filter matching documents of this
type. This string is displayed in the List Files Of Type drop-down list in
the File Open dialog box (for example, "Worksheets (*.xls)"). If
not specified, the document type is inaccessible using the File Open
command.
à 파일 대화상자의 리스트에 표시되는 필터 문자열
- CDocTemplate::filterExt Extension
for documents of this type (for example, ".xls"). If not
specified, the document type is inaccessible using the File Open command.
à 다큐먼트의 확장자
- CDocTemplate::regFileTypeId Identifier
for the document type to be stored in the registration database maintained
by Windows. This string is for internal use only (for example,
"ExcelWorksheet"). If not specified, the document type cannot be
registered with the Windows File Manager.
à 윈도우에서 관리되는 등록 데이터베이스에 저장되는 다큐먼트의 ID. 지정되지 않으면 다큐먼트가 윈도우즈 파일 관리자에 등록될 수 없다.
- CDocTemplate::regFileTypeName Name
of the document type to be stored in the registration database. This
string may be displayed in dialog boxes of applications that access the
registration database (for example, "Microsoft Excel
Worksheet").
à 등록 데이터베이스에 저장되는 다큐먼트의 이름. 이 이름은 등록 데이터 베이스 대화상자에 표시된다.
이와 같이, 각각의 의미를 제대로 이해하고 사용하자.