WTL(3)_control bars

Toolbars and Status Bars in a Frame

CFrameWindowImpl only supports one toolbar  | no equivalent to the MFC system of multiple dockable toolbars

If you need more than one toolbar : 1. hack around in CFrameWindowImpl internals

ToolBar

CreateSimpleToolBar
UIAddToolBar
UISetCheck(ID_VIEW_TOOLBAR,
1)

UIUpdateToolBar()

StatusBar

CreateSimpleStatusBar()
UISetCheck(ID_VIEW_STATUS_BAR,
1)

UI Updating Toolbar Buttons

CMessageLoop::Run() 会在 消息队列 没消息时 调用OnIdle().

UIUpdateToolBar 来更新UI map, 寻找已经被修改了状态的,设置为UPDUI_TOOLBAR的element对象,改变他的状态。

注意 当我们只是更新 弹出菜单时, 不需要这两步,因为CUpdateUI处理WM_INITMENUPOPUP并更新菜单,当消息送出。

如果你查看例子工程, 它会展现如何更新 在Frame的菜单栏中的 顶层菜单。

这里有个按钮来处理 开始 和 结束 按键去控制时钟。

If you check out the sample project, it also shows how to UI update top-level menu items in the frame's menu bar. There is an item that executes theStart and Stop commands to start and stop the clock. While this is not a common (or even recommended) thing to do -- items in the menu bar should always be popups -- I included it for the sake of completeness in covering CUpdateUI. Look for the calls to UIAddMenuBar() andUIUpdateMenuBar

Multi-Pane Status Bars

WTL有另一种 status bar ,在一个bar上有多个panes, 好像MFC的status bar 有CAPS LOCK 和 NUM LOCK。

这个类是: CMultiPaneStatusBarCtrl。 这个类支持有限的 UI updating, 和一个默认pane,他拉伸很长,占据整个bar,当popup menu显示时来展示flyby.

UI updating the panes

为了更新 pane文本, 我们将 进入 update UI map:

第一个参数是 面板的 index , 不是ID。 如果你改变了panes顺序,

如果不是每个 pane 都有一个入口在 UI updating map中, 你需要更新数字来匹配新顺序。

SetPane第三个参数用的false, 所以需要手动更新pane文本, UISetText(1, _T("Running"))

同样第1个参数是pane序号. UISetText是status bars唯一的一个UI update call.

最后, 我们需要添加调用UIUpdateStatusBar()在CMainFrame:OnIdle(),好使得pane在闲散时间里更新。

CUpdateUI有一个bug: 当你用UIUpdateStatusBar(), 

你再使用UISetText(), 在menu项中 文本 没有更新!  ....

但是, 如果你调用UIUpdateStatusBar,UISetText()调用将失效。这个Bug在WTL7.1中仍然存在。 

 

 

posted on 2011-02-28 13:57  oleeceo  阅读(360)  评论(0)    收藏  举报

导航