Creating a CToolBarCtrl Object

HomeOverviewSample

CToolBarCtrl objects contain several internal data structures — a list of button image bitmaps, a list of button label stings, and a list of TBBUTTON structures — that 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. For a list of the data structures, see Toolbar Controls in the Platform SDK. 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:

To use a CToolBarCtrl object

  1. Construct the CToolBarCtrl object.

  2. Call Create to create the Windows toolbar common control and attach it to the CToolBarCtrl object. If you want bitmap images for buttons, add the button bitmaps to the toolbar by calling AddBitmap. If you want string labels for buttons, add the strings to the toolbar by calling AddString and/or AddStrings.

  3. Add button structures to the toolbar by calling AddButtons.

  4. If you want tool tips, handle TTN_NEEDTEXT messages in the toolbar's owner window as described in CToolBarCtrl: Handling Tool Tip Notifications in the Class Library Reference.

  5. If you want your user to be able to customize the toolbar, handle customization notification messages in the owner window as described in CToolBarCtrl: Handling Customization Notifications in the Class Library Reference.

See Also   Windows Common Controls and MFC Classes