CMFCToolBar Class

The CMFCToolBar class resembles CToolBar Class, but provides additional support for user interface features. These include flat toolbars, toolbars with hot images, large icons, pager buttons, locked toolbars, rebar controls, text under images, background images, and tabbed toolbars. The CMFCToolBar class also contains built-in support for user customization of toolbars and menus, drag-and-drop between toolbars and menus, combo box buttons, edit box buttons, color pickers, and roll-up buttons.

class CMFCToolBar : public CMFCBaseToolBar

Members

Public Constructors

Name

Description

CMFCToolBar::CMFCToolBar

Default constructor.

CMFCToolBar::~CMFCToolBar

Destructor.

Public Methods

Name

Description

CMFCToolBar::AddBasicCommand

Adds a menu command to the list of commands that are always displayed when a user opens a menu.

CMFCToolBar::AddCommandUsage

Increments by one the counter that is associated with the given command.

CMFCToolBar::AddToolBarForImageCollection

Adds images from the user interface resources to the collection of images in the application.

CMFCToolBar::AdjustLayout

Recalculates the size and position of a toolbar. (Overrides CBasePane::AdjustLayout).

CMFCToolBar::AdjustSize

Recalculates the size of the toolbar.

CMFCToolBar::AllowChangeTextLabels

Specifies whether text labels can be shown under images on the toolbar buttons.

CMFCToolBar::AreTextLabels

Specifies whether text labels under images are currently displayed on the toolbar buttons.

CMFCToolBar::AutoGrayInactiveImages

Enable or disables the automatic generation of inactive button images.

CMFCToolBar::ButtonToIndex

Returns the index of a specified CMFCToolBarButton Class object in this toolbar.

CMFCToolBar::CalcFixedLayout

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

CMFCToolBar::CalcSize

Called by the framework as part of the layout calculation process. (Overrides CPane::CalcSize.)

CMFCToolBar::CanHandleSiblings

Determines whether the toolbar and its sibling are positioned on the same pane.

CMFCToolBar::CleanUpImages

Frees the system resources allocated for toolbar images.

CMFCToolBar::CleanUpLockedImages

Frees the system resources allocated for locked toolbar images.

CMFCToolBar::CanBeClosed

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

CMFCToolBar::CanBeRestored

Determines whether the system can restore a toolbar to its original state after customization.

CMFCToolBar::CanFocus

Specifies whether the pane can receive focus. (Overrides CBasePane::CanFocus.)

CMFCToolBar::CanHandleSiblings

Determines whether the toolbar and its sibling are positioned on the same pane.

CMFCToolBar::CommandToIndex

Returns the index of the button in the toolbar with a specified command ID.

CMFCToolBar::Create

Creates a CMFCToolBar object.

CMFCToolBar::CreateEx

Creates a CMFCToolBar object that uses additional style options, such as large icons.

CMFCToolBar::Deactivate

Deactivates the toolbar.

CMFCToolBar::EnableCustomizeButton

Enables or disables the Add or Remove Buttons button that appears on the end of the toolbar.

CMFCToolBar::EnableDocking

Enables docking of the pane to the main frame. (Overrides CBasePane::EnableDocking.)

CMFCToolBar::EnableLargeIcons

Enables or disables large icons on toolbar buttons.

CMFCToolBar::EnableQuickCustomization

Enables or disables the quick customization of toolbars so that the user can press the Alt key and drag a button to a new location.

CMFCToolBar::EnableReflections

Enables or disables command reflection.

CMFCToolBar::EnableTextLabels

Enables or disables text labels under toolbar button images.

CMFCToolBar::FromHandlePermanent

Retrieves a pointer to the CMFCToolBar object that contains the given window handle.

CMFCToolBar::GetAllButtons

Returns a read-only list of buttons in a toolbar.

CMFCToolBar::GetAllToolbars

Returns a read-only list of all toolbars in the application.

CMFCToolBar::GetBasicCommands

Returns a read-only list of the basic commands defined in the application.

CMFCToolBar::GetButton

Returns a pointer to the CMFCToolBarButton object that has a specified toolbar button index.

CMFCToolBar::GetButtonInfo

Returns the command ID, style, and image index of the button at a specified index.

CMFCToolBar::GetButtonSize

Returns the dimensions of each button on the toolbar.

CMFCToolBar::GetButtonStyle

Returns the current style of the toolbar button that is located at the specified index.

CMFCToolBar::GetButtonText

Returns the text label of a button that has a specified index.

CMFCToolBar::GetColdImages

Returns a pointer to the collection of cold toolbar button images in the application.

CMFCToolBar::GetColumnWidth

Returns the width of the toolbar buttons.

CMFCToolBar::GetCommandButtons

Returns a list of buttons that have a specified command ID from all toolbars in the application.

CMFCToolBar::GetCount

Returns the number of buttons and separators on the toolbar.

CMFCToolBar::GetCustomizeButton

Retrieves a pointer to the CMFCCustomizeButton object that is associated with the toolbar.

CMFCToolBar::GetDefaultImage

Returns the index of the default image for a toolbar button with a specified command ID.

CMFCToolBar::GetDisabledImages

Returns a pointer to the collection of images that are used for disabled toolbar buttons in the application.

CMFCToolBar::GetDisabledMenuImages

Returns a pointer to the collection of images that are used for disabled menu buttons in the application.

CMFCToolBar::GetDroppedDownMenu

Retrieves a pointer to the menu button object that is currently displaying its sub-menu.

CMFCToolBar::GetGrayDisabledButtons

Specifies whether the images of disabled buttons are dimmed versions of the regular button images, or taken from the collection of disabled button images.

CMFCToolBar::GetHighlightedButton

Returns a pointer to the toolbar button that is currently highlighted.

CMFCToolBar::GetHotBorder

Determines whether the toolbar buttons are hot-tracked.

CMFCToolBar::GetHotTextColor

Returns the text color of the highlighted toolbar buttons.

CMFCToolBar::GetHwndLastFocus

Returns a handle to the window that had the input focus just before the toolbar did.

CMFCToolBar::GetIgnoreSetText

Specifies whether calls to set button labels are ignored.

CMFCToolBar::GetImageSize

Returns the current size of toolbar button images.

CMFCToolBar::GetImages

Returns a pointer to the collection of default button images in the application.

CMFCToolBar::GetImagesOffset

Returns the index offset used to find the toolbar button images for this toolbar in the global list of toolbar button images.

CMFCToolBar::GetInvalidateItemRect

Retrieves the region of the client area that must be redrawn for the button at the given index.

CMFCToolBar::GetItemID

Returns the command ID of the toolbar button at a specified index.

CMFCToolBar::GetItemRect

Returns the bounding rectangle of the button at a specified index.

CMFCToolBar::GetLargeColdImages

Returns a pointer to the collection of large cold toolbar button images in the application.

CMFCToolBar::GetLargeDisabledImages

Returns a pointer to the collection of large disabled toolbar button images in the application.

CMFCToolBar::GetLargeImages

Returns a pointer to the collection of large toolbar button images in the application.

CMFCToolBar::GetLockedColdImages

Returns a pointer to the collection of locked cold images in the toolbar.

CMFCToolBar::GetLockedDisabledImages

Returns a pointer to the collection of locked disabled images in the toolbar.

CMFCToolBar::GetLockedImages

Returns a pointer to the collection of locked button images in the toolbar.

CMFCToolBar::GetLockedImageSize

Returns the default size of locked toolbar images.

CMFCToolBar::GetLockedMenuImages

Returns a pointer to the collection of locked toolbar menu images in the toolbar.

CMFCToolBar::GetMenuButtonSize

Returns the size of menu buttons in the application.

CMFCToolBar::GetMenuImageSize

Returns the size of menu button images in the application.

CMFCToolBar::GetMenuImages

Returns a pointer to the collection of menu button images in the application.

CMFCToolBar::GetOrigButtons

Retrieves the collection of non-customized buttons of the toolbar.

CMFCToolBar::GetOrigResetButtons

Retrieves the collection of non-customized reset buttons of the toolbar.

CMFCToolBar::GetResourceID

Retrieves the resource ID of the toolbar.

CMFCToolBar::GetRouteCommandsViaFrame

Determines which object, the parent frame or the owner, sends commands to the toolbar.

CMFCToolBar::GetRowHeight

Returns the height of toolbar buttons.

CMFCToolBar::GetShowTooltips

Specifies whether tool tips are displayed for toolbar buttons.

CMFCToolBar::GetSiblingToolBar

Retrieves the sibling of the toolbar.

CMFCToolBar::GetUserImages

Returns a pointer to the collection of user-defined toolbar button images in the application.

CMFCToolBar::HitTest

Returns the index of the toolbar button that is located at the specified position.

CMFCToolBar::InsertButton

Inserts a button into the toolbar.

CMFCToolBar::InsertSeparator

Inserts a separator into the toolbar.

CMFCToolBar::InvalidateButton

Invalidates the client area of the toolbar button that exists at the provided index.

CMFCToolBar::IsAddRemoveQuickCustomize

Determines whether a user can add or remove toolbar buttons by using the Customize menu option.

CMFCToolBar::IsAltCustomizeMode

Specifies whether quick customization is being used to drag a button.

CMFCToolBar::IsAutoGrayInactiveImages

Specifies whether the automatic generation of inactive (non-highlighted) button images is enabled.

CMFCToolBar::IsBasicCommand

Determines whether a command is on the list of basic commands.

CMFCToolBar::IsButtonExtraSizeAvailable

Determines whether the toolbar can display buttons that have extended borders.

CMFCToolBar::IsButtonHighlighted

Determines whether a button on the toolbar is highlighted.

CMFCToolBar::IsCommandPermitted

Determines whether a command is permitted.

CMFCToolBar::IsCommandRarelyUsed

Determines whether a command is rarely used (see CMFCToolBar::SetCommandUsageOptions).

CMFCToolBar::IsCustomizeMode

Specifies whether the toolbar framework is in customization mode.

CMFCToolBar::IsDragButton

Determines whether a toolbar button is being dragged.

CMFCToolBar::IsExistCustomizeButton

Determines whether the toolbar contains the Customize button.

CMFCToolBar::IsFloating

Determines whether the toolbar is floating.

CMFCToolBar::IsLargeIcons

Specifies whether toolbars in the application currently display large icons.

CMFCToolBar::IsLastCommandFromButton

Determines whether the most recently executed command was sent from the specified toolbar button.

CMFCToolBar::IsLocked

Determines whether the toolbar is locked.

CMFCToolBar::IsOneRowWithSibling

Determines whether the toolbar and its sibling toolbar are positioned on the same row.

CMFCToolBar::IsUserDefined

Specifies whether the toolbar is user-defined.

CMFCToolBar::LoadBitmap

Loads toolbar images from application resources.

CMFCToolBar::LoadBitmapEx

Loads toolbar images from application resources. Includes large images.

CMFCToolBar::LoadParameters

Loads global toolbar options from the Windows registry.

CMFCToolBar::LoadState

Loads the toolbar state information from the Windows registry. (Overrides CPane::LoadState.)

CMFCToolBar::LoadToolBar

Loads the toolbar from application resources.

CMFCToolBar::LoadToolBarEx

Loads the toolbar from application resources by using the CMFCToolBarInfo helper class to enable the application to use large images.

CMFCToolBar::OnChangeHot

Called by the framework when a user selects a button on the toolbar.

CMFCToolBar::OnFillBackground

Called by the framework from CBasePane::DoPaint to fill the toolbar background.

CMFCToolBar::OnReset

Restores the toolbar to its original state.

CMFCToolBar::OnSetAccData

 (Overrides CBasePane::OnSetAccData.)

CMFCToolBar::OnSetDefaultButtonText

Restores the text of a toolbar button to its default state.

CMFCToolBar::OnUpdateCmdUI

Used internally.

CMFCToolBar::RemoveAllButtons

Removes all buttons from the toolbar.

CMFCToolBar::RemoveButton

Removes the button with the specified index from the toolbar.

CMFCToolBar::RemoveStateFromRegistry

Deletes the state information for the toolbar from the Windows registry.

CMFCToolBar::ReplaceButton

Replaces a toolbar button with another toolbar button.

CMFCToolBar::ResetAll

Restores all toolbars to their original states.

CMFCToolBar::ResetAllImages

Clears all toolbar image collections in the application.

CMFCToolBar::RestoreOriginalState

Restores the original state of a toolbar.

CMFCToolBar::SaveState

Saves the state information for the toolbar in the Windows registry. (Overrides CPane::SaveState.)

CMFCToolBar::Serialize

 (Overrides CBasePane::Serialize.)

CMFCToolBar::SetBasicCommands

Sets the list of commands that are always displayed when a user opens a menu.

CMFCToolBar::SetButtonInfo

Sets the command ID, style, and image ID of a toolbar button.

CMFCToolBar::SetButtonStyle

Sets the style of the toolbar button at the given index.

CMFCToolBar::SetButtonText

Sets the text label of a toolbar button.

CMFCToolBar::SetButtons

Sets the buttons for the toolbar.

CMFCToolBar::SetCommandUsageOptions

Specifies when rarely used commands do not appear in the menu of the application.

CMFCToolBar::SetCustomizeMode

Enables or disables customization mode for all toolbars in the application.

CMFCToolBar::SetGrayDisabledButtons

Specifies whether the disabled buttons on the toolbar are dimmed or if disabled images are used for the disabled buttons.

CMFCToolBar::SetHeight

Sets the height of the toolbar.

CMFCToolBar::SetHotBorder

Specifies whether toolbar buttons are hot-tracked.

CMFCToolBar::SetHotTextColor

Sets the text color for hot toolbar buttons.

CMFCToolBar::SetLargeIcons

Specifies whether toolbar buttons display large icons.

CMFCToolBar::SetLockedSizes

Sets the sizes of locked buttons and locked images on the toolbar.

CMFCToolBar::SetMenuSizes

Sets the size of toolbar menu buttons and their images.

CMFCToolBar::SetNonPermittedCommands

Sets the list of commands that cannot be executed by the user.

CMFCToolBar::SetOneRowWithSibling

Positions the toolbar and its sibling on the same row.

CMFCToolBar::SetPermament

Specifies whether a user can close the toolbar.

CMFCToolBar::SetRouteCommandsViaFrame

Specifies whether the parent frame or the owner sends commands to the toolbar.

CMFCToolBar::SetShowTooltips

Specifies whether the framework displays tool tips.

CMFCToolBar::SetSiblingToolBar

Specifies the sibling of the toolbar.

CMFCToolBar::SetSizes

Specifies the sizes of buttons and images on all toolbars.

CMFCToolBar::SetToolBarBtnText

Specifies properties of a button on the toolbar.

CMFCToolBar::SetTwoRowsWithSibling

Positions the toolbar and its sibling on separate rows.

CMFCToolBar::SetUserImages

Sets the collection of user-defined images in the application.

CMFCToolBar::StretchPane

Stretches the toolbar vertically or horizontally. (Overrides CBasePane::StretchPane.)

CMFCToolBar::TranslateChar

Executes a button command if the specified key code corresponds to a valid keyboard shortcut.

CMFCToolBar::UpdateButton

Updates the state of the specified button.

CMFCToolBar::WrapToolBar

Repositions toolbar buttons within the given dimensions.

Protected Methods

Name

Description

CMFCToolBar::AllowShowOnList

Determines whether the toolbar is displayed in the list on the Toolbars pane of the Customize dialog box.

CMFCToolBar::CalcMaxButtonHeight

Calculates the maximum height of a button in the toolbar.

CMFCToolBar::DoPaint

Repaints a toolbar.

CMFCToolBar::DrawButton

Repaints a toolbar button.

CMFCToolBar::DrawSeparator

Repaints a separator on a toolbar.

CMFCToolBar::OnUserToolTip

Called by the framework when the tooltip for a button is about to be displayed.

Data Members

Name

Description

CMFCToolBar::m_bDontScaleImages

Specifies whether to scale or not toolbar images in high DPI mode.

CMFCToolBar::m_dblLargeImageRatio

Specifies the ratio between the dimension (height or width) of large images and the dimension of regular images.

Remarks

To incorporate a CMFCToolBar object into your application, follow these steps:

  1. Add a CMFCToolBar object to the main frame window.

  2. When you process the WM_CREATE message for the main frame window, call either CMFCToolBar::Create or CMFCToolBar::CreateEx to create the toolbar and specify its style.

  3. Call CBasePane::EnableDocking to specify the docking style.

To insert a special button, such as a combo box or drop-down toolbar, reserve a dummy button in the parent resource, and replace the dummy button at runtime by using CMFCToolBar::ReplaceButton. For more information, see Walkthrough: Putting Controls On Toolbars.

CMFCToolBar is the base class for the MFC Library classes CMFCMenuBar Class, CMFCPopupMenuBar Class, and CMFCDropDownToolBar Class.

Example

The following example demonstrates how to use various methods in the CMFCToolBar class. The example shows how to set the text of the window label of the tool bar, set the borders, set the style of the pane, and enable the Add or Remove Buttons button that appears on the end of the toolbar. This code snippet is part of the IE Demo sample.

  CMFCToolBar     m_wndToolBar;


...


    m_wndToolBar.SetWindowText (_T("Standard"));
    m_wndToolBar.SetBorders ();

    //------------------------------------ 
    // Remove toolbar gripper and borders: 
    //------------------------------------
    m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() &
        ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));

    m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));

Requirements

Header: afxtoolbar.h

Inheritance Hierarchy

CObject

   CCmdTarget

      CWnd

         CBasePane

            CPane

               CMFCBaseToolBar

                  CMFCToolBar

See Also

Tasks

Walkthrough: Putting Controls On Toolbars

Reference

Hierarchy Chart

CMFCMenuBar Class

CMFCPopupMenuBar Class

CMFCDropDownToolBar Class

Other Resources

MFC Classes