CToolBar 上不同种类的按钮

Different kinds of buttons on CToolBar

请告诉我如何在同一个 CToolBar 上添加不同类型的按钮(我需要有按钮和单选按钮)。

您需要使用CMFCToolbar::ReplaceButton。

您将常规按钮替换为派生 class 的默认 CMFCToolBarButton 之一或您自己派生的 class。

工具栏需要在要替换按钮的位置有一个 "placeholder" 按钮(空按钮)。

例如,用组合框替换工具栏按钮:

CMFCToolBarComboBoxButton myCombo(IDC_BUTTON_TO_REPLACE, GetCmdMgr()->GetCmdImage(IDC_BUTTON_TO_REPLACE, FALSE), CBS_DROPDOWNLIST, 80);
myCombo.m_strText.LoadString(IDS_MY_STRING);
myToolbar.ReplaceButton(IDC_BUTTON_TO_REPLACE, myCombo);

有几个标准 "buttons" 可用(特别是): CMFCToolBarEditBoxButton 用编辑框替换工具栏按钮。 CMFCToolBarDateTimeCtrlImpl 用日期选择器替换工具栏按钮 CMFCToolBarComboBoxButton 用组合框替换工具栏按钮。

(菜单还有几个,"outlook" 有一个)。

祝你好运。