Create different SDI windows

Create different SDI windows
1. BOOL CtestMDIApp::InitInstance()

CMultiDocTemplate* pDocTemplate;
 pDocTemplate = new CMultiDocTemplate(IDR_testMDITYPE,
  RUNTIME_CLASS(CtestMDIDoc),
  RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  RUNTIME_CLASS(CtestMDIView));
 AddDocTemplate(pDocTemplate);

 pDocTemplate = new CMultiDocTemplate(IDR_testMDITYPE, //IDR_View1TYPE,
  RUNTIME_CLASS(CtestMDIDoc),
  RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  RUNTIME_CLASS(CView1));
 AddDocTemplate(pDocTemplate);

2. void CMainFrame::OnHelp1()

static
void OnFileNew(CDocManager* mgr, UINT nIdx)
{
 POSITION pos = mgr->GetFirstDocTemplatePosition();
 CDocTemplate* pTemplate = 0;
 for (UINT i=0; i<=nIdx && pos != NULL; i++)
 {
  pTemplate = mgr->GetNextDocTemplate(pos);
  ASSERT_KINDOF(CDocTemplate, pTemplate);
 }

 if(!pTemplate)
  return;

 ASSERT(pTemplate != NULL);
 ASSERT_KINDOF(CDocTemplate, pTemplate);

 pTemplate->OpenDocumentFile(NULL);
  // if returns NULL, the user has already been alerted
}

// CMainFrame message handlers


void CMainFrame::OnHelp1()
{
 OnFileNew(AfxGetApp()->m_pDocManager, 0);
}

你可能感兴趣的:(windows)