shamantou blog site

shamantou@gmail.com

导航

VC++多文档编程

 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")不会执行,工具栏没有显示出

<< 关于vtkPlaneWidget的讨论有关于vtkWin32OpenGLRenderWindow的讨论 >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206 Copyright 2006-2009 | ooplab.org | shamantou@gmail.com | 沪ICP备08011244号 | Some Rights Reserved.