CMFCToolBarComboBoxButton Class
A toolbar button that contains a combo box control (CComboBox Class).
class CMFCToolBarComboBoxButton : public CMFCToolBarButton
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CMFCToolBarComboBoxButton. |
Public Methods
Name |
Description |
---|---|
Adds an item to the end of the combo box list. |
|
Adds an item to the combo box list. The order of items in the list is specified by Compare. |
|
Compares two items. Called to sort items that AddSortedItems adds to the combo box list. |
|
Creates a new edit control for the combo box button. |
|
Deletes an item from the combo box list. |
|
Returns the index of the item that contains a specified string. |
|
Returns a pointer to the combo box button with a specified command ID. |
|
Returns a pointer to the combo box control that is embedded in the combo box button. |
|
Returns the number of items in the combo box list. |
|
Finds the combo box button that has a specified command ID. Returns the number of items in the combo box list of that button. |
|
Returns the index of the selected item in the combo box list. |
|
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. |
|
Returns a pointer to the edit control that is embedded in the combo box button. |
|
Returns the string that is associated with a specified index in the combo box list. |
|
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. |
|
Returns the 32-bit value that is associated with a specified index in the combo box list. |
|
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. |
|
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. |
|
Returns the text from the edit control of the combo box. |
|
Finds the combo box button that has a specified command ID, and returns the text from edit control of that button. |
|
Determines whether combo box buttons in the application are centered or aligned with the top of the toolbar. |
|
Determines whether combo box buttons in the application have a flat appearance. |
|
Removes all items from the list box and edit control of the combo box. |
|
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. |
|
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. |
|
Specifies whether combo box buttons in the application are centered vertically or aligned with the top of the toolbar. |
|
Sets the height of the drop-down list box. |
|
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 VisualStudioDemo Sample: MFC Visual Studio Application.
// 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
Requirements
Header: afxtoolbarcomboboxbutton.h
See Also
Tasks
Walkthrough: Putting Controls On Toolbars