Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 2.44 KB

using-drop-down-buttons-in-a-toolbar-control.md

File metadata and controls

41 lines (26 loc) · 2.44 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Using Drop-Down Buttons in a Toolbar Control
Using Drop-Down Buttons in a Toolbar Control
11/04/2016
TBN_DROPDOWN
TBSTYLE_EX_DRAWDDARROWS
CToolBarCtrl class [MFC], drop-down buttons
toolbars [MFC], drop-down buttons
drop-down buttons in toolbars
TBSTYLE_EX_DRAWDDARROWS
TBN_DROPDOWN notification [MFC]
b859f758-d2f6-40d9-9c26-0ff61993b9b2

Using Drop-Down Buttons in a Toolbar Control

In addition to standard push buttons, a toolbar can also have drop-down buttons. A drop-down button is usually indicated by the presence of an attached down arrow.

Note

The attached down arrow will appear only if the TBSTYLE_EX_DRAWDDARROWS extended style has been set.

When the user clicks on this arrow (or the button itself, if no arrow is present), a TBN_DROPDOWN notification message is sent to the parent of the toolbar control. You can then handle this notification and display a pop-up menu; similar to the behavior of Internet Explorer.

The following procedure illustrates how to implement a drop-down toolbar button with a pop-up menu:

To implement a drop-down button

  1. Once your CToolBarCtrl object has been created, set the TBSTYLE_EX_DRAWDDARROWS style, using the following code:

    [!code-cppNVC_MFCControlLadenDialog#36]

  2. Set the TBSTYLE_DROPDOWN style for any new (InsertButton or AddButtons) or existing (SetButtonInfo) buttons that will be drop-down buttons. The following example demonstrates modifying an existing button in a CToolBarCtrl object:

    [!code-cppNVC_MFCControlLadenDialog#37]

  3. Add a TBN_DROPDOWN handler to the parent class of the toolbar object.

    [!code-cppNVC_MFCControlLadenDialog#38]

  4. In the new handler, display the appropriate popup menu. The following code demonstrates one method:

    [!code-cppNVC_MFCControlLadenDialog#39]

See also

Using CToolBarCtrl
Controls