Bewerken

Delen via


CMFCDropDownToolBar Class

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

For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

Syntax

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:

Example of CMFCDropDownToolbar.

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

CMFCDropDownToolBar::AllowShowOnPaneMenu

virtual BOOL AllowShowOnPaneMenu() const;

Return Value

Remarks

CMFCDropDownToolBar::LoadBitmap

Loads toolbar images from application resources.

virtual BOOL LoadBitmap(
    UINT uiResID,
    UINT uiColdResID=0,
    UINT uiMenuResID=0,
    BOOL bLocked=FALSE,
    UINT uiDisabledResID=0,
    UINT uiMenuDisabledResID=0);

Parameters

uiResID
[in] The resource ID of the bitmap that refers to the hot toolbar images.

uiColdResID
[in] The resource ID of the bitmap that refers to the cold toolbar images.

uiMenuResID
[in] The resource ID of the bitmap that refers to the regular menu images.

bLocked
[in] TRUE to lock the toolbar; otherwise FALSE.

uiDisabledResID
[in] The resource ID of the bitmap that refers to the disabled toolbar images.

uiMenuDisabledResID
[in] The resource ID of the bitmap that refers to the disabled menu images.

Return Value

Nonzero if the method succeeds; otherwise 0.

Remarks

The CMFCToolBar::LoadToolBarEx method calls this method to load the images that are associated with the toolbar. Override this method to perform custom loading of image resources.

Call the LoadBitmapEx method to load additional images after you create the toolbar.

CMFCDropDownToolBar::LoadToolBar

virtual BOOL LoadToolBar(
    UINT uiResID,
    UINT uiColdResID = 0,
    UINT uiMenuResID = 0,
    BOOL = FALSE,
    UINT uiDisabledResID = 0,
    UINT uiMenuDisabledResID = 0,
    UINT uiHotResID = 0);

Parameters

[in] uiResID

[in] uiColdResID

[in] uiMenuResID

[in] BOOL

[in] uiDisabledResID

[in] uiMenuDisabledResID

[in] uiHotResID

Return Value

Remarks

CMFCDropDownToolBar::OnLButtonUp

afx_msg void OnLButtonUp(
    UINT nFlags,
    CPoint point);

Parameters

[in] nFlags

[in] point

Remarks

CMFCDropDownToolBar::OnMouseMove

afx_msg void OnMouseMove(
    UINT nFlags,
    CPoint point);

Parameters

[in] nFlags

[in] point

Remarks

CMFCDropDownToolBar::OnSendCommand

virtual BOOL OnSendCommand(const CMFCToolBarButton* pButton);

Parameters

[in] pButton

Return Value

Remarks

CMFCDropDownToolBar::OnUpdateCmdUI

virtual void OnUpdateCmdUI(
    CFrameWnd* pTarget,
    BOOL bDisableIfNoHndler);

Parameters

[in] pTarget

[in] bDisableIfNoHndler

Remarks

See also

Hierarchy Chart
Classes
CMFCToolBar Class
CMFCToolBar::Create
CMFCToolBar::ReplaceButton
CMFCDropDownToolbarButton Class
Walkthrough: Putting Controls On Toolbars