Bagikan melalui


CMFCToolBarsCustomizeDialog::AddToolBar

Loads a toolbar from the resources. Then, for each command in the menu calls the CMFCToolBarsCustomizeDialog::AddButton method to insert a button in the list of commands on the Commands page under the specified category.

BOOL AddToolBar(
   UINT uiCategoryId,
   UINT uiToolbarResId 
);
BOOL AddToolBar(
   LPCTSTR lpszCategory,
   UINT uiToolbarResId 
);

Parameters

  • [in] uiCategoryId
    Specifies the resource ID of the category to add the toolbar to.

  • [in] uiToolbarResId
    Specifies the resource ID of a toolbar whose commands are inserted into the list of commands.

  • [in] lpszCategory
    Specifies the name of the category to which to add the toolbar.

Return Value

TRUE if the method is successful; otherwise FALSE.

Example

The following example demonstrates how to use the AddToolBar method in the CMFCToolBarsCustomizeDialog class. This code snippet is part of the Word Pad sample.

    CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this,
        TRUE /* Automatic menus scaning */,
        AFX_CUSTOMIZE_MENU_SHADOWS | AFX_CUSTOMIZE_TEXT_LABELS | 
        AFX_CUSTOMIZE_MENU_ANIMATIONS);

    pDlgCust->AddToolBar (_T("Format"), IDR_FORMATBAR);

Remarks

The control that is used to represent each command is a CMFCToolBarButton Class object. After you add the toolbar, you can replace the button with a control of a derived type by calling CMFCToolBarsCustomizeDialog::ReplaceButton.

Requirements

Header: afxToolBarsCustomizeDialog.h

See Also

Reference

CMFCToolBarsCustomizeDialog Class

Hierarchy Chart