MDI程序系统框架单文档对应多视图 切换 创建实现过程。

1。原来系统采用了创建多个文档模板,当切换不同的视图显示的时候 ,调用响应的文档模板指针,来生成视图。

切换的时候,首先得到当前的视图,判断是否是要切换的视图,如果不是,则销毁掉该视图,创建新的视图。

存在的问题:系统实际只是一个文档,而系统框架的菜单实际上是一样的,因此虽然在生成文档模板的时候 采用的是同一个菜单,切换视图的,引起菜单的闪烁。因此改为:只创建一个文档模板,切换的时候,动态修改文档对应的视图。

参考文章

(1)http://www.codeproject.com/docview/inplacereplacingview.asp 切换视图

 
<P nd="1">To fully understand what follows, some previous knowledge is required,
namely how MFC creates documents, frame windows and views using document
templates and how their relationship is maintained in the program. A <A
href="http://www.codeproject.com/docview/ReplacingView.asp">previous article</A>
showing how to replace views in non-OLE applications is a recommended
reading.</P>
<P nd="2">First of all, let's understand how the framework creates OLE frames.
When a <A class=iAs
style="FONT-WEIGHT: normal; FONT-SIZE: 100%; PADDING-BOTTOM: 1px; COLOR: darkgreen; BORDER-BOTTOM: darkgreen 0.07em solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline"
href="#" target=_blank itxtdid="3675733">server</A> object is inserted in a
container, a document, a frame window and a view contained within it (or
multiple views, if it is a splitter) are first constructed, following common
document-template procedures. After that, in response to the <CODE
nd="3">OLEIVERB_SHOW</CODE> OLE verb, the <CODE
nd="4">COleServerDoc::ActivateInPlace</CODE> function is called. If there is no
previous OLE frame (i.e. it is the first time it will be activated), the OLE
frame is created, calling the <CODE
nd="5">COleServerDoc::CreateInPlaceFrame</CODE> function. Here, not only the OLE
frame is created (using the <CODE nd="6">CDocTemplate::CreateOleFrame</CODE>
function), but also the view in the previously constructed frame window is
"connected" to the newly created OLE frame. If the original frame was a
splitter, then the view in the first pane is used. The "connection" process
consists on changing the view's parent window to the new frame. It is performed
calling the <CODE nd="7">COleServerDoc::ConnectView</CODE> function. The active
view on the original frame window is kept (using the <CODE
nd="8">m_pActiveView</CODE> member), because some controls continue to send
notification messages to their original parent window. These notification
messages should be handled in the original frame window. Once the OLE frame is
created and a view is "connected" to it, then it is activated.</P>
<P nd="9">Now, if we want to replace a view in an OLE frame, we have to replace
it in 2 frame windows: the OLE frame and the original frame. The current active
view should be destroyed, a new view should be created within the original frame
and be later connected to the OLE frame. The active views should be set to <CODE
nd="10">NULL</CODE> first, so no Windows message could be sent by the framework
to a non-valid view stored in the <CODE

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值