CMFCMenuBar Class
A menu bar that implements docking.
class CMFCMenuBar : public CMFCToolbar
Members
Public Methods
Name |
Description |
---|---|
(Overrides CMFCToolBar::AdjustLocations.) |
|
Specifies whether text labels can be shown under images on the toolbar buttons. (Overrides CMFCToolBar::AllowChangeTextLabels.) |
|
(Overrides CPane::AllowShowOnPaneMenu.) |
|
Calculates the horizontal size of the toolbar. (Overrides CMFCToolBar::CalcFixedLayout.) |
|
(Overrides CMFCToolBar::CalcLayout.) |
|
Calculates the maximum height of buttons in the toolbar. (Overrides CMFCToolBar::CalcMaxButtonHeight.) |
|
Specifies whether a user can close the toolbar. (Overrides CMFCToolBar::CanBeClosed.) |
|
Determines whether the system can restore a toolbar to its original state after customization. (Overrides CMFCToolBar::CanBeRestored.) |
|
Creates a menu control and attaches it to a CMFCMenuBar object. |
|
Creates a CMFCMenuBar object with additional style options. |
|
Initializes a CMFCMenuBar object. Accepts a HMENU parameter that acts as a template for a populated CMFCMenuBar. |
|
Enables a Help combo box that is located on the right side of the menu bar. |
|
Specifies whether to display shadows for pop-up menus. |
|
(Overrides CPane::GetAvailableExpandSize.) |
|
Returns the width of the toolbar buttons. (Overrides CMFCToolBar::GetColumnWidth.) |
|
Returns a handle to the original menu in the resource file. |
|
Returns the resource identifier for the original menu in the resource file. |
|
|
|
|
|
Returns a pointer to the Help combo box. |
|
Returns the handle to the menu that is attached to the CMFCMenuBar object. |
|
Returns the current global font for menu objects. |
|
Returns the toolbar button associated with the provided item index. |
|
Returns the height of toolbar buttons. (Overrides CMFCToolBar::GetRowHeight.) |
|
|
|
|
|
|
|
Indicates whether disabled menu items are highlighted. |
|
Determines whether the toolbar can display buttons that have extended borders. (Overrides CMFCToolBar::IsButtonExtraSizeAvailable.) |
|
Indicates whether disabled items are highlighted. |
|
Indicates whether shadows are drawn for pop-up menus. |
|
Indicates whether recently used menu commands are displayed on the menu bar. |
|
Indicates whether pop-up menus display all commands. |
|
Indicates whether menus display all the commands after a short delay. |
|
Loads the state of the CMFCMenuBar object from the registry. |
|
Called by the framework when a user selects a button on the toolbar. (Overrides CMFCToolBar::OnChangeHot.) |
|
Called by the framework when a frame window loads the default menu from the resource file. |
|
(Overrides CMFCToolBar::OnSendCommand.) |
|
Called by the framework when a menu is in customization mode and the user changes a menu item's text. |
|
(Overrides CMFCToolBar::OnToolHitTest.) |
|
(Overrides CMFCToolBar::PreTranslateMessage.) |
|
Called by the framework when a menu is in customization mode and the user selects Reset for a menu bar. |
|
Saves the state of the CMFCMenuBar object to the registry. |
|
Sets the original menu in the resource file. |
|
|
|
Called by the framework when an MDI child window changes its display mode. If the MDI child window is newly maximized or is no longer maximized, this method updates the menu bar. |
|
Sets the runtime class information that is generated when the user dynamically creates menu buttons. |
|
Sets the font for all menus in the application. |
|
Specifies whether a menu bar displays recently used menu commands. |
|
Specifies whether the menu bar shows all commands. |
Remarks
The CMFCMenuBar class is a menu bar that implements docking functionality. It resembles a toolbar, although it cannot be closed - it is always displayed.
CMFCMenuBar supports the option of displaying recently used menu item objects. If this option is enabled, the CMFCMenuBar displays only a subset of the available commands on first viewing. Thereafter, recently used commands are displayed together with the original subset of commands. In addition, the user can always expand the menu to view all available commands. Thus, each available command is configured to display constantly, or to display only if it has been recently selected.
To use a CMFCMenuBar object, embed it in the main window frame object. When processing the WM_CREATE message, call CMFCMenuBar::Create or CMFCMenuBar::CreateEx. Regardless of which create function you use, pass in a pointer to the main frame window. Then enable docking by calling CFrameWndEx::EnableDocking. Dock this menu by calling CFrameWndEx::DockPane.
Example
The following example demonstrates how to use various methods in the CMFCMenuBar class. The example shows how to set the style of the pane, enable the customize button, enable a Help box, enable shadows for pop-up menus, and update the menu bar. This code snippet is part of the IEDemo Sample: MFC Internet Explorer Application.
CMFCMenuBar m_wndMenuBar;
...
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC);
m_wndMenuBar.EnableCustomizeButton (TRUE, -1, _T(""));
// first parameter is the command ID for the button of the Help combo box
// third parameter is the width of the button for the combo box in pixels.
m_wndMenuBar.EnableHelpCombobox(1,_T("enter text here"),30);
m_wndMenuBar.EnableMenuShadows();
m_wndMenuBar.SetMaximizeMode(true);
Inheritance Hierarchy
Requirements
Header: afxmenubar.h