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.
class CMFCDropDownToolBar : public CMFCToolBar
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. |
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:
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:
Reserve a dummy resource ID for the button in the parent toolbar resource.
Create a
CMFCDropDownToolBarButton
object that contains the drop-down toolbar (for more information, see CMFCDropDownToolbarButton::CMFCDropDownToolbarButton).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.
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
}
Header: afxdropdowntoolbar.h
virtual BOOL AllowShowOnPaneMenu() const;
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);
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.
Nonzero if the method succeeds; otherwise 0.
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.
virtual BOOL LoadToolBar(
UINT uiResID,
UINT uiColdResID = 0,
UINT uiMenuResID = 0,
BOOL = FALSE,
UINT uiDisabledResID = 0,
UINT uiMenuDisabledResID = 0,
UINT uiHotResID = 0);
[in] uiResID
[in] uiColdResID
[in] uiMenuResID
[in] BOOL
[in] uiDisabledResID
[in] uiMenuDisabledResID
[in] uiHotResID
afx_msg void OnLButtonUp(
UINT nFlags,
CPoint point);
[in] nFlags
[in] point
afx_msg void OnMouseMove(
UINT nFlags,
CPoint point);
[in] nFlags
[in] point
virtual BOOL OnSendCommand(const CMFCToolBarButton* pButton);
[in] pButton
virtual void OnUpdateCmdUI(
CFrameWnd* pTarget,
BOOL bDisableIfNoHndler);
[in] pTarget
[in] bDisableIfNoHndler
Hierarchy Chart
Classes
CMFCToolBar Class
CMFCToolBar::Create
CMFCToolBar::ReplaceButton
CMFCDropDownToolbarButton Class
Walkthrough: Putting Controls On Toolbars