Share via


CMFCDropDownToolBar Class

A toolbar that appears when the user presses and holds a top-level toolbar button.

class CMFCDropDownToolBar : public CMFCToolBar

Members

Public Methods

Name

Description

CMFCDropDownToolBar::AllowShowOnPaneMenu

  (Overrides CPane::AllowShowOnPaneMenu.)

CMFCDropDownToolBar::LoadBitmap

  (Overrides CMFCToolBar::LoadBitmap.)

CMFCDropDownToolBar::LoadToolBar

  (Overrides CMFCToolBar::LoadToolBar.)

CMFCDropDownToolBar::OnLButtonUp

 

CMFCDropDownToolBar::OnMouseMove

 

CMFCDropDownToolBar::OnSendCommand

  (Overrides CMFCToolBar::OnSendCommand.)

CMFCDropDownToolBar::OnUpdateCmdUI

  (Overrides CMFCToolBar::OnUpdateCmdUI.)

Remarks

A CMFCDropDownToolBar object combines the visual appearance of a toolbar with the behavior of a popup menu. When a user presses and holds a drop-down toolbar button (see CMFCDropDownToolbarButton Class), a drop-down toolbar appears, and the user can select a button from the drop-down toolbar by scrolling to it and releasing the mouse button. After the user selects a button in the drop-down toolbar, that button is displayed as the current button on the top-level toolbar.

A drop-down toolbar cannot be customized or docked, and it does not have a tear-off state.

The following illustration shows a CMFCDropDownToolBar object:

CMFCDropDownToolbar screenshot

You create a CMFCDropDownToolBar object the same way you create an ordinary toolbar (see CMFCToolBar Class).

To insert the drop-down toolbar into a parent toolbar:

1. Reserve a dummy resource ID for the button in the parent toolbar resource.

2. Create a CMFCDropDownToolBarButton object that contains the drop-down toolbar (for more information, see CMFCDropDownToolbarButton::CMFCDropDownToolbarButton).

3. Replace the dummy button with the CMFCDropDownToolBarButton object by using CMFCToolBar::ReplaceButton.

For more information about toolbar buttons, see Walkthrough: Putting Controls On Toolbars. For an example of a drop-down toolbar, see the sample project VisualStudioDemo.

Example

The following example demonstrates how to use the Create method in the CMFCDropDownToolBar class. This code snippet is part of the Visual Studio Demo sample.

  CMFCDropDownToolBar m_wndToolbarResource;


...


    // Create Resource toolbar: 
    // The this pointer points to CMainFrame class which extends the CMDIFrameWndEx class 
    if (!m_wndToolbarResource.Create(this, WS_CHILD|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, IDR_TOOLBAR_RESOURCE) || !m_wndToolbarResource.LoadToolBar(IDR_TOOLBAR_RESOURCE))
    {
        TRACE0("Failed to create build toolbar\n");
        return FALSE;      // fail to create
    }

Inheritance Hierarchy

CObject

   CCmdTarget

      CWnd

         CBasePane

            CPane

               CMFCBaseToolBar

                  CMFCToolBar

                     CMFCDropDownToolBar

Requirements

Header: afxdropdowntoolbar.h

See Also

Tasks

Walkthrough: Putting Controls On Toolbars

Reference

Hierarchy Chart

CMFCToolBar Class

CMFCToolBar::Create

CMFCToolBar::ReplaceButton

CMFCDropDownToolbarButton Class

Other Resources

MFC Classes