Share via


CMFCToolBarComboBoxButton Class

A toolbar button that contains a combo box control (CComboBox Class).

class CMFCToolBarComboBoxButton : public CMFCToolBarButton

Members

Public Constructors

Name

Description

CMFCToolBarComboBoxButton::CMFCToolBarComboBoxButton

Constructs a CMFCToolBarComboBoxButton.

Public Methods

Name

Description

CMFCToolBarComboBoxButton::AddItem

Adds an item to the end of the combo box list.

CMFCToolBarComboBoxButton::AddSortedItem

Adds an item to the combo box list. The order of items in the list is specified by Compare.

CMFCToolBarComboBoxButton::Compare

Compares two items. Called to sort items that AddSortedItems adds to the combo box list.

CMFCToolBarComboBoxButton::CreateEdit

Creates a new edit control for the combo box button.

CMFCToolBarComboBoxButton::DeleteItem

Deletes an item from the combo box list.

CMFCToolBarComboBoxButton::FindItem

Returns the index of the item that contains a specified string.

CMFCToolBarComboBoxButton::GetByCmd

Returns a pointer to the combo box button with a specified command ID.

CMFCToolBarComboBoxButton::GetComboBox

Returns a pointer to the combo box control that is embedded in the combo box button.

CMFCToolBarComboBoxButton::GetCount

Returns the number of items in the combo box list.

CMFCToolBarComboBoxButton::GetCountAll

Finds the combo box button that has a specified command ID. Returns the number of items in the combo box list of that button.

CMFCToolBarComboBoxButton::GetCurSel

Returns the index of the selected item in the combo box list.

CMFCToolBarComboBoxButton::GetCurSelAll

Finds the combo box button that has a specified command ID, and returns the index of the selected item in the combo box list of that button.

CMFCToolBarComboBoxButton::GetEditCtrl

Returns a pointer to the edit control that is embedded in the combo box button.

CMFCToolBarComboBoxButton::GetItem

Returns the string that is associated with a specified index in the combo box list.

CMFCToolBarComboBoxButton::GetItemAll

Finds the combo box button that has a specified command ID, and returns the string that is associated with an index in the combo box list of that button.

CMFCToolBarComboBoxButton::GetItemData

Returns the 32-bit value that is associated with a specified index in the combo box list.

CMFCToolBarComboBoxButton::GetItemDataAll

Finds the combo box button that has a specified command ID, and returns the 32-bit value that is associated with an index in the combo box list of that button.

CMFCToolBarComboBoxButton::GetItemDataPtrAll

Finds the combo box button that has a specified command ID. Retrieves the 32-bit value that is associated an index in the combo box list of that button, and returns the 32-bit value as a pointer.

CMFCToolBarComboBoxButton::GetText

Returns the text from the edit control of the combo box.

CMFCToolBarComboBoxButton::GetTextAll

Finds the combo box button that has a specified command ID, and returns the text from edit control of that button.

CMFCToolBarComboBoxButton::IsCenterVert

Determines whether combo box buttons in the application are centered or aligned with the top of the toolbar.

CMFCToolBarComboBoxButton::IsFlatMode

Determines whether combo box buttons in the application have a flat appearance.

CMFCToolBarComboBoxButton::RemoveAllItems

Removes all items from the list box and edit control of the combo box.

CMFCToolBarComboBoxButton::SelectItem

Selects an item in the combo box according to its index, 32-bit value, or string, and notifies the combo box control about the selection.

CMFCToolBarComboBoxButton::SelectItemAll

Finds the combo box button that has a specified command ID. Calls SelectItem to select an item in the combo box of that button according to its string, index, or 32-bit value.

CMFCToolBarComboBoxButton::SetCenterVert

Specifies whether combo box buttons in the application are centered vertically or aligned with the top of the toolbar.

CMFCToolBarComboBoxButton::SetDropDownHeight

Sets the height of the drop-down list box.

CMFCToolBarComboBoxButton::SetFlatMode

Specifies whether combo box buttons in the application have a flat appearance.

Remarks

To add a combo box button to a toolbar, follow these steps:

1. Reserve a dummy resource ID for the button in the parent toolbar resource.

2. Construct a CMFCToolBarComboBoxButton object.

3. In the message handler that processes the AFX_WM_RESETTOOLBAR message, replace the dummy button with the new combo box button by using CMFCToolBar::ReplaceButton.

For more information, see Walkthrough: Putting Controls On Toolbars. For an example of a combo box toolbar button, see the example project VisualStudioDemo.

Example

The following example demonstrates how to use various methods in the CMFCToolBarComboBoxButton class. The example shows how to enable the edit and combo boxes, set the vertical position of combo box buttons in the application, set the height of the list box when it is dropped down, set the flat style appearance of combo box buttons in the application, and set the text in the edit box of the combo box button. This code snippet is part of the Visual Studio Demo sample.

            // CObList listButtons
            // POSITION posCombo
            CMFCToolBarComboBoxButton* pCombo = DYNAMIC_DOWNCAST(CMFCToolBarComboBoxButton, listButtons.GetNext(posCombo));


...


                pCombo->EnableWindow(true);
                pCombo->SetCenterVert();
                pCombo->SetDropDownHeight(25);
                pCombo->SetFlatMode();
                pCombo->SetText(_T("this is a combo box"));

Inheritance Hierarchy

CObject

   CMFCToolBarButton

      CMFCToolBarComboBoxButton

Requirements

Header: afxtoolbarcomboboxbutton.h

See Also

Tasks

Walkthrough: Putting Controls On Toolbars

Reference

Hierarchy Chart

CMFCToolBarButton Class

CComboBox Class

CMFCToolBar::ReplaceButton

Other Resources

MFC Classes