Delen via


CMFCMenuBar Class

A menu bar that implements docking.

class CMFCMenuBar : public CMFCToolbar

Members

Public Methods

Name

Description

CMFCMenuBar::AdjustLocations

  (Overrides CMFCToolBar::AdjustLocations.)

CMFCMenuBar::AllowChangeTextLabels

Specifies whether text labels can be shown under images on the toolbar buttons. (Overrides CMFCToolBar::AllowChangeTextLabels.)

CMFCMenuBar::AllowShowOnPaneMenu

  (Overrides CPane::AllowShowOnPaneMenu.)

CMFCMenuBar::CalcFixedLayout

Calculates the horizontal size of the toolbar. (Overrides CMFCToolBar::CalcFixedLayout.)

CMFCMenuBar::CalcLayout

  (Overrides CMFCToolBar::CalcLayout.)

CMFCMenuBar::CalcMaxButtonHeight

Calculates the maximum height of buttons in the toolbar. (Overrides CMFCToolBar::CalcMaxButtonHeight.)

CMFCMenuBar::CanBeClosed

Specifies whether a user can close the toolbar. (Overrides CMFCToolBar::CanBeClosed.)

CMFCMenuBar::CanBeRestored

Determines whether the system can restore a toolbar to its original state after customization. (Overrides CMFCToolBar::CanBeRestored.)

CMFCMenuBar::Create

Creates a menu control and attaches it to a CMFCMenuBar object.

CMFCMenuBar::CreateEx

Creates a CMFCMenuBar object with additional style options.

CMFCMenuBar::CreateFromMenu

Initializes a CMFCMenuBar object. Accepts a HMENU parameter that acts as a template for a populated CMFCMenuBar.

CMFCMenuBar::EnableHelpCombobox

Enables a Help combo box that is located on the right side of the menu bar.

CMFCMenuBar::EnableMenuShadows

Specifies whether to display shadows for pop-up menus.

CMFCMenuBar::GetAvailableExpandSize

  (Overrides CPane::GetAvailableExpandSize.)

CMFCMenuBar::GetColumnWidth

Returns the width of the toolbar buttons. (Overrides CMFCToolBar::GetColumnWidth.)

CMFCMenuBar::GetDefaultMenu

Returns a handle to the original menu in the resource file.

CMFCMenuBar::GetDefaultMenuResId

Returns the resource identifier for the original menu in the resource file.

CMFCMenuBar::GetFloatPopupDirection

 

CMFCMenuBar::GetForceDownArrows

 

CMFCMenuBar::GetHelpCombobox

Returns a pointer to the Help combo box.

CMFCMenuBar::GetHMenu

Returns the handle to the menu that is attached to the CMFCMenuBar object.

CMFCMenuBar::GetMenuFont

Returns the current global font for menu objects.

CMFCMenuBar::GetMenuItem

Returns the toolbar button associated with the provided item index.

CMFCMenuBar::GetRowHeight

Returns the height of toolbar buttons. (Overrides CMFCToolBar::GetRowHeight.)

CMFCMenuBar::GetSystemButton

 

CMFCMenuBar::GetSystemButtonsCount

 

CMFCMenuBar::GetSystemMenu

 

CMFCMenuBar::HighlightDisabledItems

Indicates whether disabled menu items are highlighted.

CMFCMenuBar::IsButtonExtraSizeAvailable

Determines whether the toolbar can display buttons that have extended borders. (Overrides CMFCToolBar::IsButtonExtraSizeAvailable.)

CMFCMenuBar::IsHighlightDisabledItems

Indicates whether disabled items are highlighted.

CMFCMenuBar::IsMenuShadows

Indicates whether shadows are drawn for pop-up menus.

CMFCMenuBar::IsRecentlyUsedMenus

Indicates whether recently used menu commands are displayed on the menu bar.

CMFCMenuBar::IsShowAllCommands

Indicates whether pop-up menus display all commands.

CMFCMenuBar::IsShowAllCommandsDelay

Indicates whether menus display all the commands after a short delay.

CMFCMenuBar::LoadState

Loads the state of the CMFCMenuBar object from the registry.

CMFCMenuBar::OnChangeHot

Called by the framework when a user selects a button on the toolbar. (Overrides CMFCToolBar::OnChangeHot.)

CMFCMenuBar::OnDefaultMenuLoaded

Called by the framework when a frame window loads the default menu from the resource file.

CMFCMenuBar::OnSendCommand

  (Overrides CMFCToolBar::OnSendCommand.)

CMFCMenuBar::OnSetDefaultButtonText

Called by the framework when a menu is in customization mode and the user changes a menu item's text.

CMFCMenuBar::OnToolHitTest

  (Overrides CMFCToolBar::OnToolHitTest.)

CMFCMenuBar::PreTranslateMessage

  (Overrides CMFCToolBar::PreTranslateMessage.)

CMFCMenuBar::RestoreOriginalstate

Called by the framework when a menu is in customization mode and the user selects Reset for a menu bar.

CMFCMenuBar::SaveState

Saves the state of the CMFCMenuBar object to the registry.

CMFCMenuBar::SetDefaultMenuResId

Sets the original menu in the resource file.

CMFCMenuBar::SetForceDownArrows

 

CMFCMenuBar::SetMaximizeMode

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.

CMFCMenuBar::SetMenuButtonRTC

Sets the runtime class information that is generated when the user dynamically creates menu buttons.

CMFCMenuBar::SetMenuFont

Sets the font for all menus in the application.

CMFCMenuBar::SetRecentlyUsedMenus

Specifies whether a menu bar displays recently used menu commands.

CMFCMenuBar::SetShowAllCommands

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 IE Demo sample.

 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

CObject

   CCmdTarget

      CWnd

         CBasePane

            CPane

               CMFCBaseToolBar

                  CMFCToolBar

                     CMFCMenuBar

Requirements

Header: afxmenubar.h

See Also

Reference

Hierarchy Chart

CMFCToolBar Class

Other Resources

MFC Classes