CToolBarCtrl Class
Provides the functionality of the Windows toolbar common control.
class CToolBarCtrl : public CWnd
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CToolBarCtrl object. |
Public Methods
Name |
Description |
---|---|
Adds one or more bitmap button images to the list of button images available for a toolbar control. |
|
Adds one or more buttons to a toolbar control. |
|
Adds a new string, passed as a resource ID, to the toolbar's internal list of strings. |
|
Adds a new string or strings, passed as a pointer to a buffer of null-separated strings, to the toolbar's internal list of strings. |
|
Resizes a toolbar control. |
|
Changes the bitmap for a button in the current toolbar control. |
|
Checks or clears a given button in a toolbar control. |
|
Retrieves the zero-based index for the button associated with the specified command identifier. |
|
Creates a toolbar control and attaches it to a CToolBarCtrl object. |
|
Creates a toolbar control with the specified Windows extended styles and attaches it to a CToolBarCtrl object. |
|
Displays the Customize Toolbar dialog box. |
|
Deletes a button from the toolbar control. |
|
Enables or disables the specified button in a toolbar control. |
|
Retrieves the anchor highlight setting for a toolbar. |
|
Retrieves the index of the bitmap associated with a button in a toolbar. |
|
Gets flags associated with the toolbar's bitmap. |
|
Retrieves information about the specified button in a toolbar control. |
|
Retrieves a count of the buttons currently in the toolbar control. |
|
Retrieves the information for a button in a toolbar. |
|
Retrieves the current width and height of toolbar buttons, in pixels. |
|
Retrieves the color scheme of the current toolbar control. |
|
Retrieves the image list that a toolbar control uses to display disabled buttons. |
|
Retrieves the IDropTarget interface for a toolbar control. |
|
Retrieves the extended styles for a toolbar control. |
|
Retrieves the image list that a toolbar control uses to display "hot" buttons. A hot button appears highlighted when the mouse pointer is above it. |
|
Retrieves the index of the hot item in a toolbar. |
|
Retrieves the image list that a toolbar control uses to display buttons in their default state. |
|
Retrieves the current insertion mark for the toolbar. |
|
Retrieves the color used to draw the insertion mark for the toolbar. |
|
Retrieves the bounding rectangle of a button in a toolbar control. |
|
Retrieves the total size of all of the visible buttons and separators in the toolbar. |
|
Retrieves the maximum number of text rows displayed on a toolbar button. |
|
Retrieves the metrics of a toolbar control. |
|
Retrieves the horizontal and vertical padding of the current toolbar control. |
|
Retrieves the image list that the current toolbar control uses to represent buttons in the pressed state. |
|
Retrieves the bounding rectangle for a specified toolbar button. |
|
Retrieves the number of rows of buttons currently displayed in the toolbar. |
|
Retrieves information about the state of the specified button in a toolbar control, such as whether it is enabled, pressed, or checked. |
|
Retrieves a toolbar string. |
|
Retrieves the styles currently in use for a toolbar control. |
|
Retrieves the handle of the tool tip control, if any, associated with the toolbar control. |
|
Hides or shows the specified button in a toolbar control. |
|
Determines where a point lies in a toolbar control. |
|
Sets or clears the indeterminate (gray) state of the specified button in a toolbar control. |
|
Inserts a button in a toolbar control. |
|
Retrieves the insertion mark information for a point in a toolbar. |
|
Tells whether the specified button in a toolbar control is checked. |
|
Tells whether the specified button in a toolbar control is enabled. |
|
Tells whether the specified button in a toolbar control is hidden. |
|
Checks the highlight state of the toolbar button. |
|
Tells whether the state of the specified button in a toolbar control is indeterminate (gray). |
|
Tells whether the specified button in a toolbar control is pressed. |
|
Loads bitmaps into a toolbar control's image list. |
|
Maps an accelerator character to a toolbar button. |
|
Sets the highlight state of a given button in a toolbar control. |
|
Moves a button from one index to another. |
|
Presses or releases the specified button in a toolbar control. |
|
Replaces the existing bitmap in the current toolbar control with a new bitmap. |
|
Restores the state of the toolbar control. |
|
Saves the state of the toolbar control. |
|
Sets the anchor highlight setting for a toolbar. |
|
Sets the size of the bitmapped images to be added to a toolbar control. |
|
Sets the information for an existing button in a toolbar. |
|
Sets the size of the buttons to be added to a toolbar control. |
|
Specifies the size of the TBBUTTON structure. |
|
Sets the minimum and maximum button widths in the toolbar control. |
|
Sets the command identifier to be sent to the owner window when the specified button is pressed. |
|
Sets the color scheme of the current toolbar control. |
|
Sets the image list that the toolbar control will use to display disabled buttons. |
|
Sets the flags in the Win32 function DrawText, which is used to draw the text in the specified rectangle, formatted according to how the flags are set. |
|
Sets the extended styles for a toolbar control. |
|
Sets the image list that the toolbar control will use to display "hot" buttons. |
|
Sets the hot item in a toolbar. |
|
Sets the image list that the toolbar will use to display buttons that are in their default state. |
|
Sets the indentation for the first button in a toolbar control. |
|
Sets the current insertion mark for the toolbar. |
|
Sets the color used to draw the insertion mark for the toolbar. |
|
Sets the maximum number of text rows displayed on a toolbar button. |
|
Sets the metrics of a toolbar control. |
|
Sets the window to receive notification messages from the toolbar control. |
|
Sets the horizontal and vertical padding of the current toolbar control. |
|
Sets the image list that the current toolbar control uses to represent buttons in the pressed state. |
|
Sets the number of rows of buttons displayed in the toolbar. |
|
Sets the state for the specified button in a toolbar control. |
|
Sets the styles for a toolbar control. |
|
Associates a tool tip control with the toolbar control. |
|
Sets the visual style of a toolbar control. |
Remarks
This control (and therefore the CToolBarCtrl class) is available only to programs running under Windows 95/98 and Windows NT version 3.51 and later.
A Windows toolbar common control is a rectangular child window that contains one or more buttons. These buttons can display a bitmap image, a string, or both. When the user chooses a button, it sends a command message to the toolbar's owner window. Typically, the buttons in a toolbar correspond to items in the application's menu; they provide a more direct way for the user to access an application's commands.
CToolBarCtrl objects contain several important internal data structures: a list of button image bitmaps or an image list, a list of button label strings, and a list of TBBUTTON structures which associate an image and/or string with the position, style, state, and command ID of the button. Each of the elements of these data structures is referred to by a zero-based index. Before you can use a CToolBarCtrl object, you must set up these data structures. The list of strings can only be used for button labels; you cannot retrieve strings from the toolbar.
To use a CToolBarCtrl object, you will typically follow these steps:
Construct the CToolBarCtrl object.
Call Create to create the Windows toolbar common control and attach it to the CToolBarCtrl object. Indicate the style of toolbar by using styles, such as TBSTYLE_TRANSPARENT for a transparent toolbar or TBSTYLE_DROPDOWN for a toolbar that supports drop-down style buttons.
Identify how you want the buttons on the toolbar displayed:
To use bitmap images for buttons, add the button bitmaps to the toolbar by calling AddBitmap.
To use images displayed from an image list for buttons, specify the image list by calling SetImageList, SetHotImageList, or SetDisabledImageList.
To use string labels for buttons, add the strings to the toolbar by calling AddString and/or AddStrings.
Add button structures to the toolbar by calling AddButtons.
If you want tool tips for a toolbar button in an owner window that is not a CFrameWnd, you need to handle the TTN_NEEDTEXT messages in the toolbar's owner window as described in Handling Tool Tip Notifications. If the parent window of the toolbar is derived from CFrameWnd, tool tips are displayed without any extra effort from you because CFrameWnd provides a default handler.
If you want your user to be able to customize the toolbar, handle customization notification messages in the owner window as described in Handling Customization Notifications.
You can use SaveState to save the current state of a toolbar control in the registry and RestoreState to restore the state based on information previously stored in the registry. In addition to saving the toolbar state between uses of the application, applications typically store the state before the user begins customizing the toolbar in case the user later wants to restore the toolbar to its original state.
Support for Internet Explorer Version 4.0 and Later
To support functionality introduced in Internet Explorer, version 4.0 and later, MFC provides image list support and transparent and flat styles for toolbar controls.
A transparent toolbar allows the client under the toolbar to show through. To create a transparent toolbar, use both TBSTYLE_FLAT and TBSTYLE_TRANSPARENT styles. Transparent toolbars feature hot tracking; that is, when the mouse pointer moves over a hot button on the toolbar, the button's appearance changes. Toolbars created with just the TBSTYLE_FLAT style will contain buttons that are not transparent.
Image list support allows a control greater flexibility for default behavior, hot images, and disabled images. Use GetImageList, GetHotImageList, and GetDisabledImageList with the transparent toolbar to manipulate the image according to its state:
For more information on using CToolBarCtrl, see Controls and Using CToolBarCtrl.
Inheritance Hierarchy
CToolBarCtrl
Requirements
Header: afxcmn.h