CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

我需要关于sdi动态切换视图的代码!

楼主wind_xu(疯子)2002-02-01 21:19:45 在 VC/MFC / 基础类 提问

问题点数:20、回复次数:1Top

1 楼masterz(www.fruitfruit.com)回复于 2002-02-01 23:03:40 得分 20

Adding   multiple   views   to   an   SDI   application  
  1.build   an   normal   SDI   project  
  2.Add   a   new   view   class   derived   from   CView  
  3.Add   debug   and   non   debug   versions   of   the   GetDocument()   function  
  4.Add   a   public   constructor  
  5.make   the   destructor   provided   by   class   wizard   public  
  6.include   the   document   class   header   file   in   the   source   file   of   the   new   view   class  
  7.add   a   handler   for   the   OnDraw   event   of   the   new   view   class  
  8include   the   header   file   of   the   new   view   class   in   MainFrm.cpp  
  9add   two   protected   variables   in   the   CMainFrame   class  
  These   variables   will   be   pointers   to   the   two   view   objects   your   application   uses.   Initialize   these  
  pointers   to   NULL   in   the   constructor   of   CMainFrame,as   shown   in   the   following    
  class   CMainFrame:public   CFrameWnd  
  {  
  ...  
  protected:  
  CItalicsView*   m_pItalicView;  
  CDefaultView*   m_pDefaultView;  
  ...  
  }  
  CMainFrame::CMainFrame()  
  {  
  m_pItalicsView=NULL;  
  m_pDefaultView=NULL;  
  }  
  10.add   two   menu   selection   to   permit   the   application   to   switch   between   the   two   views.  
  11.add   command   handlers   to   CMainFrame   for   the   two   new   menu   items.  
  void   CMainFrame::OnViewItalics()  
  {  
  CDocument*   pDoc=GetActiveDocument();  
  if(NULL==m_pItalicView)  
  {  
  m_pDefaultView=(CDefaultView*)GetActiveView();  
  m_pItalicsView=new   CItalicsView(NULL);  
  m_pItalicsView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW,rectDefault,this,AFX_IDW_PANE_FIRST+1);  
  }  
  pDoc->AddView(m_pItalicsView);  
  m_pItalicsView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);  
  m_pDefaultView->SetDlgCtrlID(AFX_IDW_PANE_FIRST+1);  
  m_pItalicsView->ShowWindow(SW_SHOW);  
  m_pDefaultView->ShowWindow(SW_HIDE);  
  SetActiveView(m_pItalicsView);  
  pDoc->RemoveView(m_pDefaultView);  
  RecalcLayout();  
  }  
   
  void   CMainFrame::OnViewDefault()  
  {  
  CDocument*   pDoc=GetActiveDocument();  
  pDoc->AddView(m_pDefaultView);  
  m_pItalicsView->ShowWindow(SW_HIDE);  
  m_pDefaultView->ShowWindow(SW_SHOW);  
  m_pItalicsView->SetDlgCtrlID(AFX_IDW_PANE_FIRST+1);  
  m_pDefaultView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);  
   
  SetActiveView(m_pDefaultView);  
  pDoc->RemoveView(m_pItalicsView);  
  RecalcLayout();  
  }  
   
   
  Top

相关问题

  • 高分求购视图切换的代码(200)
  • 50分:Dreamweaver4.0 无法切换代码视图!
  • 怎么不能切换到‘代码视图’和‘代码和设计视图’,只能在设计视图里了,昨天还好好的,谢谢了!!!
  • 在SDI中如何进行视图的切换?
  • 视图切换问题
  • ======如何切换视图======
  • 视图切换的问题。
  • 在MDI中想在多个视图间切换,但搞了两天还切换不了,帮帮我,检查一下代码
  • 都是我的错,谁来帮帮我(SDI—分割窗口的视图切换!)up—有分!!..........
  • 关于多视图的切换。

关键词

  • view
  • application
  • null
  • pdefaultview
  • pitalicsview
  • cmainframe
  • setdlgctrlid
  • sdi
  • idw
  • pdoc

得分解答快速导航

  • 帖主:wind_xu
  • masterz

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo