Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » nID parameter of CExtControlBar Collapse All
Subject Author Date
Eileen Valliere Apr 26, 2004 - 9:51 AM

The nID parameter of the CExtControlBar class is confusing, especially with respect to the CExtMenuControlBar class.


I don’t understand why you pass a different ID in to the create function when the resource you are trying to load is the default menu/toolbar (IDR_MAINFRAME).


What is ID_VIEW_MENUBAR?  This seems to be just an ID given to a menu item within the default menu.  How does this get associated with the default menu’s resource ID?

Technical Support Apr 28, 2004 - 8:54 AM

Dear Eileen,

First of all, please note that the issue does not relate to the number of menus in the SDI/MDI application.

Each control bar in a frame window should have its unique dialog control identifier. This identifier is quite handy, allowing you to use it in the menu as an identifier of the show/hide command associated with the control bar. MFC defines several ready-to-use identifiers like ID_VIEW_TOOLBAR (which is absolutely equal to AFX_IDW_TOOLBAR) or ID_VIEW_STATUSBAR (which is absolutely equal to AFX_IDW_STATUSBAR). The CFrameWnd class handles these pre-defined commands/identifiers automatically.

MFC does not support the menu bar control as a kind of control bar window. That is why you can find the ID_VIEW_MENUBAR constant in the most Prof-UIS samples. It is used both as a menu command identifier and as a dialog control identifier for the CExtMenuControlBar window. The ID_VIEW_MENUBAR constant is local in each sample application. MFC does not know this command corresponds to the control bar. So, we need to add some lines to the frame’s message map to make this command show/hide the menu bar. For example:

 
ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)

The same technique is used for all toolbars but that specified with ID_VIEW_TOOLBAR/AFX_IDW_TOOLBAR.

The ID_VIEW_MENUBAR constant has nothing to do with identifiers of menu resources like IDR_MAINFRAME or IDR_YOURDOCTYPE. The menu bar knows nothing about which menu resource is used for the active child frame in the MDI frame window. The CExtMenuControlBar class just intercepts the event generated when the menu line changes inside the MDI frame, scans the new menu tree for building its buttons, and hides the default menu line of the frame window.

We believe that now, when you know that the ID_VIEW_TOOLBAR value of the menu command is absolutely equal to AFX_IDW_TOOLBAR used for creating a toolbar window, your confusion should disappear.