goodking
goodking

Reputation: 145

Different kinds of buttons on CToolBar

Give me a tip please how to add different kinds of buttons (I need to have pushbuttons and radio buttons) on the same CToolBar.

Upvotes: 0

Views: 545

Answers (1)

Max
Max

Reputation: 3190

You need to use CMFCToolbar::ReplaceButton.

You replace the regular button with either one of the default CMFCToolBarButton derived classed or with one of your own derived class.

The toolbar need to have a "placeholder" button (empty button) at the position you want to replace the button.

for example to replace a toolbar button with a combo box:

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);

There are a couple of standard "buttons" available (in particular): CMFCToolBarEditBoxButton to replace a toolbar button with an edit box. CMFCToolBarDateTimeCtrlImpl to replace a toolbar button with a date picker CMFCToolBarComboBoxButton to replace a toolbar button with a combo box.

(there are a couple more for menus and one for "outlook" ).

Good luck.

Upvotes: 1

Related Questions