CMFCToolBarButton Class
Provides button functionality to toolbars.
class CMFCToolBarButton : public CObject
Members
Public Constructors
Name |
Description |
---|---|
Constructs and initializes a CMFCToolBarButton object. |
|
CMFCToolBarButton::~CMFCToolBarButton |
Destructor. |
Public Methods
Name |
Description |
---|---|
Specifies whether a user can position a button on a toolbar or menu during customization. |
|
Specifies whether the button can be stored. |
|
Specifies whether a user can stretch the button during customization. |
|
Compares this instance with the provided CMFCToolBarButton object. |
|
Copies the properties of another toolbar button to the current button. |
|
Creates a CMFCToolBarButton object from the provided COleDataObject object. |
|
CMFCToolBarButton::CreateObject |
Used by the framework to create a dynamic instance of this class type. |
Enables or disables mouse and keyboard input. |
|
Copies text from the toolbar button to a menu. |
|
Retrieves the global clipboard format for the application. |
|
Retrieves the window handle that is associated with the toolbar button. |
|
Retrieves the image index of the button. |
|
Retrieves the region of the client area of the button that must be redrawn. |
|
Retrieves the parent window of the button. |
|
Retrieves the list of commands that the user cannot customize. |
|
Retrieves the size of the button text. |
|
Determines whether the button has the current input focus. |
|
Determines whether a border of the button is displayed when a user selects the button. |
|
Determines whether an image is displayed on the button. |
|
Determines whether a text label is displayed on the button. |
|
Determines whether the button displays a submenu. |
|
Determines whether the button can be customized. |
|
Determines whether the button can be displayed with an extended border. |
|
Determines whether the button is in the first position in its button group. |
|
Determines whether the button is hidden. |
|
Determines whether the button is located on a horizontal toolbar. |
|
Specifies whether the button is in the last position in its button group. |
|
Determines whether the button is on a locked (non-customizable) toolbar. |
|
Determines whether the button is the owner of the provided window handle. |
|
Determines whether the toolbar button is visible. |
|
Determines whether the underlying window handle of the button is visible. |
|
Specifies whether the button processes the WM_COMMAND message. |
|
Called by the framework when the button is added to a Customize dialog box. |
|
Specifies whether the button can be dragged. |
|
Specifies whether a user can drop the button onto the target toolbar. |
|
Called by the framework to calculate the size of the button for the specified device context and docking state. |
|
Called by the framework to handle the WM_CANCELMODE message. |
|
Called by the framework when the button is inserted into a new toolbar. |
|
Called by the framework when the user clicks the mouse button. |
|
Called by the framework when the user releases the mouse button. |
|
Called by the framework when the parent toolbar handles a WM_HELPHITTEST message. |
|
Called by the framework when the parent toolbar handles a WM_CTLCOLOR message. |
|
Allows the button to modify the provided menu when the application displays a shortcut menu on the parent toolbar. |
|
Called by the framework when the parent toolbar handles a WM_LBUTTONDBLCLK message. |
|
Called by the framework to draw the button by using the specified styles and options. |
|
Called by the framework to draw the button in the Commands pane of the Customize dialog box. |
|
Called by the framework to retrieve the custom tooltip text for the button. |
|
Called by the framework when the global font has changed. |
|
Called by the framework when the parent toolbar moves. |
|
Called by the framework when the button becomes visible or invisible. |
|
Called by the framework when the parent toolbar changes its size or position and this change requires the button to change size. |
|
Called by the framework when the parent toolbar must determine whether a point is in the bounding rectangle of the button. |
|
Called by the framework when the parent toolbar updates its tooltip text. |
|
Called by the framework when the button is about to perform a drag-and-drop operation. |
|
Retrieves the bounding rectangle of the button. |
|
Sets to the default value the image that is associated with the button. |
|
Saves the state of the toolbar button. |
|
Reads this object from an archive or writes it to an archive. (Overrides CObject::Serialize.) |
|
Populates the provided CAccessibilityData object with accessibility data from the toolbar button. |
|
Renames the global clipboard format. |
|
Sets the image index of the button. |
|
Sets the list of commands that the user cannot customize. |
|
Called by the framework when a button changes its checked state. |
|
Sets the bounding rectangle of the button. |
|
Sets the style of the button. |
|
Specifies whether the button is visible. |
|
Shows or hides the button. |
Data Members
Name |
Description |
---|---|
Specifies whether an image is displayed on the button. |
|
Specifies whether a text label is displayed on the button. |
|
Specifies whether the text label is displayed underneath the image on the button. |
|
Specifies whether the button has a user-defined image. |
|
Specifies whether the button displays its full text label even if it does not fit in the bounding rectangle. |
|
Specifies whether the button next to a separator will be put on the next row. |
|
Specifies whether multi-line text labels are enabled. |
|
The command ID of the button. |
|
The style of the button. |
|
The text label of the button. |
Remarks
A CMFCToolbarButton object is a control that resides on a toolbar. Its behavior resembles that of an ordinary button. You can assign an image and a text label to this object. A toolbar button can also have a command ID. When the user clicks the toolbar button, the framework executes the command that this ID specifies.
Typically, toolbar buttons can be customized: the user can drag buttons from one toolbar to another, and copy, paste, delete, and edit text labels and images. To prevent the user from customizing the toolbar, you can lock the toolbar in one of two ways. Either set the bLocked flag to TRUE when you call CMFCToolBar::LoadToolBar, or add the command ID of an individual button to the global list of protected commands by using the CMFCToolBarButton::SetProtectedCommands method.
CMFCToolBarButton objects display images from the global collections of toolbar images in the application. These collections are maintained by the parent toolbar, CMFCToolBar Class. For more information, see CMFCToolBarImages Class.
When the user clicks a toolbar button, its parent toolbar processes the mouse message and communicates the appropriate actions to the button. If the button has a valid command ID, the parent toolbar sends the WM_COMMAND message to the parent frame.
The CMFCToolBarButton class is the base class for other toolbar button classes, such as CMFCToolBarMenuButton Class, CMFCToolBarEditBoxButton Class, and CMFCToolBarComboBoxButton Class.
Example
The following example demonstrates how to configure a CMFCToolBarButton object by using various methods in the CMFCToolBarButton class. The example illustrates how to enable the mouse and keyboard input, set the image index of the button, set the bounding rectangle of the button, and make the button visible. This code snippet is part of the Tab Control sample.
CMFCToolBarButton* pOffice2007 = NULL;
int nIndex = -1;
for (UINT uiCmd = ID_VIEW_APPLOOK_2007_1; uiCmd <= ID_VIEW_APPLOOK_2007_4; uiCmd++)
{
// CMFCToolBar m_wndToolBarTheme
nIndex = m_wndToolBarTheme.CommandToIndex (uiCmd);
CMFCToolBarButton* pButton = m_wndToolBarTheme.GetButton (nIndex);
if (pButton != NULL)
{
pOffice2007 = pButton;
break;
}
}
...
pOffice2007->EnableWindow();
pOffice2007->SetImage(1);
pOffice2007->SetRect( CRect(1,1,1,1));
pOffice2007->SetVisible();
pOffice2007->Show(true);
Inheritance Hierarchy
Requirements
Header: afxtoolbarbutton.h
See Also
Reference
CMFCToolBarButton::NotifyCommand