Article ID: 113257
Article Last Modified on 11/21/2006
class CMyApp : public CWinApp
{
...
public:
CMultiDocTemplate* m_pDocTemplate;
...
}
NOTE: If you plan to use multiple document types, you must create a
CMultiDocTemplate pointer member variable for each document type.
BOOL CMyApp::InitInstance()
{
...
m_pDocTemplate = new CMultiDocTemplate(IDR_TEXTTYPE,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CMyView));
AddDocTemplate(m_pDocTemplate);
...
}
void CMyView::OnNewWindowButtonClicked()
{
CMyApp* pApp = (CMyApp*)AfxGetApp();
pApp->m_pDocTemplate->OpenDocumentFile(NULL);
}
This same technique could be used to create a CSingleDocTemplate based
window in a Single Document Interface (SDI) application. However, it is not
necessary. Because there is only one document template for the application,
calling OnFileNew() will create the new window without prompting the user for
the type of document.Keywords: kbhowto kbinfo kbdocview KB113257