Toolbars

HomeOverviewHow Do ISampleTutorial

Toolbars display a collection of easy-to-use buttons that represent commands. AppWizard makes it easy to add a toolbar to your application. The following are introduced in this article:

Toolbar Buttons

The buttons in a toolbar are analogous to the items in a menu. Both kinds of user-interface objects generate commands, which your program handles by providing handler functions. Often toolbar buttons duplicate the functionality of menu commands, providing an alternative user interface to the same functionality. Such duplication is arranged simply by giving the button and the menu item the same ID.

You can make the buttons in a toolbar appear and behave as pushbuttons, check boxes, or radio buttons. For more information, see class CToolBar.

Docking and Floating Toolbars

An MFC toolbar can:

For more information, see the article Toolbars: Docking and Floating.

Toolbars and Tool Tips

MFC toolbars can also be made to display “tool tips” — tiny popup windows containing a short text description of a toolbar button’s purpose. As the user moves the mouse over a toolbar button, the tool tip window pops up to offer a hint. For more information, see the article Toolbars: Tool Tips.

The CToolBar and CToolBarCtrl Classes

You manage your application’s toolbars via class CToolBar. As of MFC version 4.0, CToolBar has been reimplemented to use the toolbar common control available under Windows 95 and Windows NT version 3.51 or later.

This reimplementation results in less MFC code for toolbars, because MFC makes use of operating system support. The reimplementation also improves capability. You can use CToolBar member functions to manipulate toolbars, or you can obtain a reference to the underlying CToolBarCtrl object and call its member functions for toolbar customization and additional functionality.

Tip   If you have invested heavily in the older MFC implementation of CToolBar, that support is still available. See the article Toolbars: Using Your Old Toolbars.

Also see the MFC General sample DOCKTOOL.

The Toolbar Bitmap

Once constructed, a CToolBar object creates the toolbar image by loading a single bitmap that contains one image for each button. AppWizard creates a standard toolbar bitmap that you can customize with the Visual C++ toolbar editor.

What do you want to know more about?

See Also   Toolbar Editor