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 |
---|---|
Adds a menu command to the list of commands that are always displayed when a user opens a menu. |
|
Increments by one the counter that is associated with the given command. |
|
Adds images from the user interface resources to the collection of images in the application. |
|
Recalculates the size and position of a toolbar. (Overrides CBasePane::AdjustLayout). |
|
Recalculates the size of the toolbar. |
|
Specifies whether text labels can be shown under images on the toolbar buttons. |
|
Specifies whether text labels under images are currently displayed on the toolbar buttons. |
|
Enable or disables the automatic generation of inactive button images. |
|
Returns the index of a specified CMFCToolBarButton Class object in this toolbar. |
|
Calculates the horizontal size of the toolbar. (Overrides CBasePane::CalcFixedLayout.) |
|
Called by the framework as part of the layout calculation process. (Overrides CPane::CalcSize.) |
|
Determines whether the toolbar and its sibling are positioned on the same pane. |
|
Frees the system resources allocated for toolbar images. |
|
Frees the system resources allocated for locked toolbar images. |
|
Specifies whether a user can close the toolbar. (Overrides CBasePane::CanBeClosed.) |
|
Determines whether the system can restore a toolbar to its original state after customization. |
|
Specifies whether the pane can receive focus. (Overrides CBasePane::CanFocus.) |
|
Determines whether the toolbar and its sibling are positioned on the same pane. |
|
Returns the index of the button in the toolbar with a specified command ID. |
|
Creates a CMFCToolBar object. |
|
Creates a CMFCToolBar object that uses additional style options, such as large icons. |
|
Deactivates the toolbar. |
|
Enables or disables the Add or Remove Buttons button that appears on the end of the toolbar. |
|
Enables docking of the pane to the main frame. (Overrides CBasePane::EnableDocking.) |
|
Enables or disables large icons on toolbar buttons. |
|
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. |
|
Enables or disables command reflection. |
|
Enables or disables text labels under toolbar button images. |
|
Retrieves a pointer to the CMFCToolBar object that contains the given window handle. |
|
Returns a read-only list of buttons in a toolbar. |
|
Returns a read-only list of all toolbars in the application. |
|
Returns a read-only list of the basic commands defined in the application. |
|
Returns a pointer to the CMFCToolBarButton object that has a specified toolbar button index. |
|
Returns the command ID, style, and image index of the button at a specified index. |
|
Returns the dimensions of each button on the toolbar. |
|
Returns the current style of the toolbar button that is located at the specified index. |
|
Returns the text label of a button that has a specified index. |
|
Returns a pointer to the collection of cold toolbar button images in the application. |
|
Returns the width of the toolbar buttons. |
|
Returns a list of buttons that have a specified command ID from all toolbars in the application. |
|
Returns the number of buttons and separators on the toolbar. |
|
Retrieves a pointer to the CMFCCustomizeButton object that is associated with the toolbar. |
|
Returns the index of the default image for a toolbar button with a specified command ID. |
|
Returns a pointer to the collection of images that are used for disabled toolbar buttons in the application. |
|
Returns a pointer to the collection of images that are used for disabled menu buttons in the application. |
|
Retrieves a pointer to the menu button object that is currently displaying its sub-menu. |
|
Specifies whether the images of disabled buttons are dimmed versions of the regular button images, or taken from the collection of disabled button images. |
|
Returns a pointer to the toolbar button that is currently highlighted. |
|
Determines whether the toolbar buttons are hot-tracked. |
|
Returns the text color of the highlighted toolbar buttons. |
|
Returns a handle to the window that had the input focus just before the toolbar did. |
|
Specifies whether calls to set button labels are ignored. |
|
Returns the current size of toolbar button images. |
|
Returns a pointer to the collection of default button images in the application. |
|
Returns the index offset used to find the toolbar button images for this toolbar in the global list of toolbar button images. |
|
Retrieves the region of the client area that must be redrawn for the button at the given index. |
|
Returns the command ID of the toolbar button at a specified index. |
|
Returns the bounding rectangle of the button at a specified index. |
|
Returns a pointer to the collection of large cold toolbar button images in the application. |
|
Returns a pointer to the collection of large disabled toolbar button images in the application. |
|
Returns a pointer to the collection of large toolbar button images in the application. |
|
Returns a pointer to the collection of locked cold images in the toolbar. |
|
Returns a pointer to the collection of locked disabled images in the toolbar. |
|
Returns a pointer to the collection of locked button images in the toolbar. |
|
Returns the default size of locked toolbar images. |
|
Returns a pointer to the collection of locked toolbar menu images in the toolbar. |
|
Returns the size of menu buttons in the application. |
|
Returns the size of menu button images in the application. |
|
Returns a pointer to the collection of menu button images in the application. |
|
Retrieves the collection of non-customized buttons of the toolbar. |
|
Retrieves the collection of non-customized reset buttons of the toolbar. |
|
Retrieves the resource ID of the toolbar. |
|
Determines which object, the parent frame or the owner, sends commands to the toolbar. |
|
Returns the height of toolbar buttons. |
|
Specifies whether tool tips are displayed for toolbar buttons. |
|
Retrieves the sibling of the toolbar. |
|
Returns a pointer to the collection of user-defined toolbar button images in the application. |
|
Returns the index of the toolbar button that is located at the specified position. |
|
Inserts a button into the toolbar. |
|
Inserts a separator into the toolbar. |
|
Invalidates the client area of the toolbar button that exists at the provided index. |
|
Determines whether a user can add or remove toolbar buttons by using the Customize menu option. |
|
Specifies whether quick customization is being used to drag a button. |
|
Specifies whether the automatic generation of inactive (non-highlighted) button images is enabled. |
|
Determines whether a command is on the list of basic commands. |
|
Determines whether the toolbar can display buttons that have extended borders. |
|
Determines whether a button on the toolbar is highlighted. |
|
Determines whether a command is permitted. |
|
Determines whether a command is rarely used (see CMFCToolBar::SetCommandUsageOptions). |
|
Specifies whether the toolbar framework is in customization mode. |
|
Determines whether a toolbar button is being dragged. |
|
Determines whether the toolbar contains the Customize button. |
|
Determines whether the toolbar is floating. |
|
Specifies whether toolbars in the application currently display large icons. |
|
Determines whether the most recently executed command was sent from the specified toolbar button. |
|
Determines whether the toolbar is locked. |
|
Determines whether the toolbar and its sibling toolbar are positioned on the same row. |
|
Specifies whether the toolbar is user-defined. |
|
Loads toolbar images from application resources. |
|
Loads toolbar images from application resources. Includes large images. |
|
Loads global toolbar options from the Windows registry. |
|
Loads the toolbar state information from the Windows registry. (Overrides CPane::LoadState.) |
|
Loads the toolbar from application resources. |
|
Loads the toolbar from application resources by using the CMFCToolBarInfo helper class to enable the application to use large images. |
|
Called by the framework when a user selects a button on the toolbar. |
|
Called by the framework from CBasePane::DoPaint to fill the toolbar background. |
|
Restores the toolbar to its original state. |
|
(Overrides CBasePane::OnSetAccData.) |
|
Restores the text of a toolbar button to its default state. |
|
CMFCToolBar::OnUpdateCmdUI |
Used internally. |
Removes all buttons from the toolbar. |
|
Removes the button with the specified index from the toolbar. |
|
Deletes the state information for the toolbar from the Windows registry. |
|
Replaces a toolbar button with another toolbar button. |
|
Restores all toolbars to their original states. |
|
Clears all toolbar image collections in the application. |
|
Restores the original state of a toolbar. |
|
Saves the state information for the toolbar in the Windows registry. (Overrides CPane::SaveState.) |
|
CMFCToolBar::Serialize |
(Overrides CBasePane::Serialize.) |
Sets the list of commands that are always displayed when a user opens a menu. |
|
Sets the command ID, style, and image ID of a toolbar button. |
|
Sets the style of the toolbar button at the given index. |
|
Sets the text label of a toolbar button. |
|
Sets the buttons for the toolbar. |
|
Specifies when rarely used commands do not appear in the menu of the application. |
|
Enables or disables customization mode for all toolbars in the application. |
|
Specifies whether the disabled buttons on the toolbar are dimmed or if disabled images are used for the disabled buttons. |
|
Sets the height of the toolbar. |
|
Specifies whether toolbar buttons are hot-tracked. |
|
Sets the text color for hot toolbar buttons. |
|
Specifies whether toolbar buttons display large icons. |
|
Sets the sizes of locked buttons and locked images on the toolbar. |
|
Sets the size of toolbar menu buttons and their images. |
|
Sets the list of commands that cannot be executed by the user. |
|
Positions the toolbar and its sibling on the same row. |
|
Specifies whether a user can close the toolbar. |
|
Specifies whether the parent frame or the owner sends commands to the toolbar. |
|
Specifies whether the framework displays tool tips. |
|
Specifies the sibling of the toolbar. |
|
Specifies the sizes of buttons and images on all toolbars. |
|
Specifies properties of a button on the toolbar. |
|
Positions the toolbar and its sibling on separate rows. |
|
Sets the collection of user-defined images in the application. |
|
Stretches the toolbar vertically or horizontally. (Overrides CBasePane::StretchPane.) |
|
Executes a button command if the specified key code corresponds to a valid keyboard shortcut. |
|
Updates the state of the specified button. |
|
Repositions toolbar buttons within the given dimensions. |
Protected Methods
Name |
Description |
---|---|
Determines whether the toolbar is displayed in the list on the Toolbars pane of the Customize dialog box. |
|
Calculates the maximum height of a button in the toolbar. |
|
Repaints a toolbar. |
|
Repaints a toolbar button. |
|
Repaints a separator on a toolbar. |
|
Called by the framework when the tooltip for a button is about to be displayed. |
Data Members
Name |
Description |
---|---|
Specifies whether to scale or not toolbar images in high DPI mode. |
|
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:
Add a CMFCToolBar object to the main frame window.
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.
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
See Also
Tasks
Walkthrough: Putting Controls On Toolbars