Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 5: The Document/View Architecture Visual C++ and MFC Fundamentals


// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();

return TRUE;
}

In this case, the user can create and/or open as many text files as the computer memory
would allow.

Another type of MDI application you can create would allow the user to create or open
more than one type of document. To provide this functionality, you must specify a
template for each type. Again, there are various types of techniques you can use. You can
ask the user to select the type of document he or she wants to create when the application
starts:

To do this, you can create a template for each type of document using a
CDocMultiDocTemplate constructor for each:

BOOL CMultiEdit1App::InitInstance()
{
CMultiDocTemplate* pDocEdit;
pDocEdit = new CMultiDocTemplate(
IDR_EDITTYPE,
RUNTIME_CLASS(CMultiEdit1Doc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CEditView));
AddDocTemplate(pDocEdit);

CMultiDocTemplate* pDocForm;
pDocForm = new CMultiDocTemplate(
IDR_FORMTYPE,
RUNTIME_CLASS(CMultiEdit1Doc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CEmplRecords));
AddDocTemplate(pDocForm);

// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;

CCommandLineInfo cmdInfo;
Free download pdf