CMFCToolBarsCustomizeDialog::AddButton
插入工具栏按钮。命令中列出在 命令 页。
void AddButton(
UINT uiCategoryId,
const CMFCToolBarButton& button,
int iInsertBefore=-1
);
void AddButton(
LPCTSTR lpszCategory,
const CMFCToolBarButton& button,
int iInsertBefore=-1
);
参数
[in] uiCategoryId
指定插入按钮的类别ID。[in] button
指定按钮插入。[in] iInsertBefore
指定预先按钮插入工具栏按钮的从零开始的索引。[in] lpszCategory
指定类别字符串插入按钮。
备注
AddButton 方法忽略具有标准命令ID的按钮(如ID_FILE_MRU_FILE1),不允许的命令(请参见 CMFCToolBar::IsCommandPermitted)和虚假的按钮。
此方法创建类型的对象和 button (通常 CMFCToolBarButton选件类)所使用按钮的运行时选件类。 然后调用 CMFCToolBarButton::CopyFrom 复制按钮和插入的数据成员该复制到指定类别中。
在插入时新按钮,它接受 OnAddToCustomizePage 通知。
如果 iInsertBefore 为-1,按钮会追加到类别列表;否则它在具有指定索引的项目前插入。
示例
下面的示例演示如何使用 CMFCToolBarsCustomizeDialog 选件类的 AddButton 方法。 此代码段是 slider示例的一部分。
CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this,
TRUE /* Automatic menus scaning */);
CSliderButton btnSlider (ID_SLIDER);
btnSlider.SetRange (0, 100);
pDlgCust->AddButton (_T("Edit"), btnSlider);
要求
标头: afxToolBarsCustomizeDialog.h