CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TESTMUTYPE,
RUNTIME_CLASS(CTestMultiAppDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTestMultiAppView));
AddDocTemplate(pDocTemplate);
// CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MENU11,
RUNTIME_CLASS(CTestMultiAppDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMyView));
// pDocTemplate->m_lpszClassName="abcaaron";
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
//
// // Parse command line for standard shell commands, DDE, file open
// CCommandLineInfo cmdInfo;
// ParseCommandLine(cmdInfo);
// cmdInfo.m_nShellCommand=CCommandLineInfo::FileNew;
//
// // Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
CString str;
CDocTemplate *pd;
POSITION pt=GetFirstDocTemplatePosition();
while(pt!=NULL)
{
pd=(CDocTemplate*)GetNextDocTemplate(pt);
pd->GetDocString(str,CDocTemplate::docName);
AfxMessageBox(str);
pd->OpenDocumentFile(NULL);
}
如果刚开始要求建立一个空文档,则在initInstance函数中,将
//
// // Parse command line for standard shell commands, DDE, file open
// CCommandLineInfo cmdInfo;
// ParseCommandLine(cmdInfo);
// cmdInfo.m_nShellCommand=CCommandLineInfo::FileNew;
//
// // Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;
注释掉即OK,此段代码的功效等同于OnFileNew();
以下代码介绍了如何成功的动态的改变工具栏类型
BOOL CFrameWnd::PreTranslateMessage(MSG* pMsg)
{
CWnd *pWnd;
pWnd=this->FromHandle(pMsg->hwnd);
if(pWnd!=NULL)
{
if(pWnd->IsKindOf(RUNTIME_CLASS(C3DSFrame)))
{
AfxMessageBox("Is C3DSChildFrame");
switch(pMsg->message)
{
case WM_MOVE:
{
AfxMessageBox("C3DSChildFrame WM_MOVE");
if(this->m_wndToolBar_3DSView.m_hWnd)
{
this->ShowControlBar(&m_wndToolBar_3DSView,TRUE,FALSE);
}
break;
}
default:
break;
}
}
else
{
if(this->m_wndToolBar_3DSView.m_hWnd)
{
this->ShowControlBar(&m_wndToolBar_3DSView,FALSE,FALSE);
}
}
}
return CMDIFrameWnd::PreTranslateMessage(pMsg);
}
/////////////////////////////
添加上面的代码后,打开一个C3DSChildFrame子窗MDIChildWnd), AfxMessageBox("Is C3DSChildFrame")会执AfxMessageBox("C3DSChildFrame WM_MOVE")不会执行,工具栏没有显示出