Partager via


CMFCToolBarsCustomizeDialog::AddButton

Inserts a toolbar button into the list of commands on the Commands page.

void AddButton(
   UINT uiCategoryId,
   const CMFCToolBarButton& button,
   int iInsertBefore=-1 
);
void AddButton(
   LPCTSTR lpszCategory,
   const CMFCToolBarButton& button,
   int iInsertBefore=-1 
);

Parameters

  • [in] uiCategoryId
    Specifies the category ID into which to insert the button.

  • [in] button
    Specifies the button to insert.

  • [in] iInsertBefore
    Specifies the zero-based index of a toolbar button before which the button is inserted.

  • [in] lpszCategory
    Specifies the category string to insert the button.

Remarks

The AddButton method ignores buttons that have the standard command IDs (such as ID_FILE_MRU_FILE1), commands that are not permitted (see CMFCToolBar::IsCommandPermitted) and dummy buttons.

This method creates a new object of the same type as button (usually a CMFCToolBarButton Class) by using the runtime class of the button. It then calls CMFCToolBarButton::CopyFrom to copy the data members of button, and inserts the copy into the specified category.

When the new button is inserted, it receives the OnAddToCustomizePage notification.

If iInsertBefore is -1, the button is appended to the list of categories; otherwise it is inserted before the item with the specified index.

Example

The following example demonstrates how to use the AddButton method of the CMFCToolBarsCustomizeDialog class. This code snippet is part of the Slider sample.

    CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this,
        TRUE /* Automatic menus scaning */);

    CSliderButton btnSlider (ID_SLIDER);
    btnSlider.SetRange (0, 100);

    pDlgCust->AddButton (_T("Edit"), btnSlider);

Requirements

Header: afxToolBarsCustomizeDialog.h

See Also

Reference

CMFCToolBarsCustomizeDialog Class

Hierarchy Chart