แก้ไข

แชร์ผ่าน


CMFCToolBarComboBoxButton Class

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

Syntax

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

CMFCToolBarComboBoxButton::AddItem

Appends a unique item to the list box.

virtual INT_PTR AddItem(
    LPCTSTR lpszItem,
    DWORD_PTR dwData=0);

Parameters

lpszItem
[in] The text of the item to add to the list box.

dwData
[in] The data associated with the item to add to the list box.

Return Value

The index of the last item in the list box.

Remarks

Do not use this method when the list box style is sorted.

If the item text is already in the list box, the new data is stored with the existing item. The search for the item is case sensitive.

CMFCToolBarComboBoxButton::AddSortedItem

Adds an item to the list box in the order that is defined by the Compare method.

virtual INT_PTR AddSortedItem(
    LPCTSTR lpszItem,
    DWORD_PTR dwData=0);

Parameters

lpszItem
[in] The text of the item to add to the list box.

dwData
[in] The data associated with the item to add to the list box.

Return Value

Index of the item that was added to the list box.

Remarks

Use this function to add items to the list box in a specific order.

CMFCToolBarComboBoxButton::CanBeStretched

Indicates whether the combo box button size can change.

virtual BOOL CanBeStretched() const;

Return Value

Returns TRUE.

CMFCToolBarComboBoxButton::CMFCToolBarComboBoxButton

Constructs a CMFCToolBarComboBoxButton object.

CMFCToolBarComboBoxButton(
    UINT uiID,
    int iImage,
    DWORD dwStyle=CBS_DROPDOWNLIST,
    int iWidth=0);

Parameters

uiID
[in] The command ID of the new button.

iImage
[in] The image index of the image associated with the new button.

dwStyle
[in] The style of the new button.

iWidth
[in] The width, in pixels, of the new button.

Remarks

The default width is 150 pixels.

For a list of toolbar button styles see ToolBar Control Styles

CMFCToolBarComboBoxButton::ClearData

Deletes user-defined data.

virtual void ClearData();

Remarks

By default this method does nothing. Override this method in a derived class if you want to delete any user-defined data.

CMFCToolBarComboBoxButton::Compare

Compares two strings.

virtual int Compare(
    LPCTSTR lpszItem1,
    LPCTSTR lpszItem2);

Parameters

lpszItem1
[in] The first string to compare.

lpszItem2
[in] The second string to compare.

Return Value

A value that indicates the case-sensitive lexicographic relationship between the strings. The following table lists the possible values:

Value Description
<0 The first string is less than the second.
0 The first string equals the second.
>0 The first string is greater than the second.

Remarks

Override this method to change how items are sorted in the list box.

The comparison is case-sensitive.

This method is called only from the AddSortedItem method.

CMFCToolBarComboBoxButton::CopyFrom

Copies the state of the specified CMFCToolBarComboBoxButton to the current object.

virtual void CopyFrom(const CMFCToolBarButton& src);

Parameters

src
[in] The source CMFCToolBarComboBoxButton object.

CMFCToolBarComboBoxButton::CreateCombo

Creates a new combo box for the combo box button.

virtual CComboBox* CreateCombo(
    CWnd* pWndParent,
    const CRect& rect);

Parameters

pWndParent
[in] A pointer to the parent window of the button.

rect
[in] Bounding rectangle of the combo box.

Return Value

A pointer to the new combo box if the method was successful; otherwise, NULL.

CMFCToolBarComboBoxButton::CreateEdit

Creates a new edit box for the combo box button.

virtual CMFCToolBarComboBoxEdit* CreateEdit(
    CWnd* pWndParent,
    const CRect& rect,
    DWORD dwEditStyle);

Parameters

pWndParent
[in] A pointer to the parent window of the button.

rect
[in] Bounding rectangle of the new edit box.

dwEditStyle
[in] Control style of the new edit box.

Return Value

A pointer to the new edit box if the method was successful; otherwise, NULL.

Remarks

The framework calls this method when it creates a new edit box for a combo box button. Override this method to change how CMFCToolBarComboBoxEdit is created.

CMFCToolBarComboBoxButton::DeleteItem

Deletes a specified item from the list box.

BOOL DeleteItem(int iIndex);
BOOL DeleteItem(DWORD_PTR dwData);
BOOL DeleteItem(LPCTSTR lpszText);

Parameters

iIndex
[in] The zero-based index of the item to be deleted.

dwData
[in] The data associated with the item to be deleted.

lpszText
[in] The text of the item to be deleted. If there are multiple items with the same text, the first item is deleted.

Return Value

TRUE if the item was located and successfully deleted; otherwise, FALSE.

Remarks

CMFCToolBarComboBoxButton::DuplicateData

Duplicates user-defined data.

virtual void DuplicateData();

Remarks

By default this method does nothing. Override this method in a derived class if you want to copy any user-defined data.

CMFCToolBarComboBoxButton::EnableWindow

Enables or disables the edit and combo boxes.

virtual void EnableWindow(BOOL bEnable = TRUE);

Parameters

bEnable
[in] TRUE to enable the edit and combo boxes; FALSE to disable the edit and combo boxes.

Remarks

When disabled, the controls cannot become active and cannot accept user input.

CMFCToolBarComboBoxButton::ExportToMenuButton

Copies a string from the application string table to the specified menu using the combo box button command ID.

virtual BOOL ExportToMenuButton(CMFCToolBarMenuButton& menuButton) const;

Parameters

menuButton
[out] Reference to a menu button.

Return Value

Always TRUE.

CMFCToolBarComboBoxButton::FindItem

Returns the index of the first item in the list box that contains a specified string.

int FindItem(LPCTSTR lpszText) const;

Parameters

lpszText
[in] The text for which to search in the list box.

Return Value

The index of the item; or CB_ERR if the item is not found.

Remarks

CMFCToolBarComboBoxButton::GetByCmd

Gets a pointer to the combo box button that has a specified command ID.

static CMFCToolBarComboBoxButton* GetByCmd(
    UINT uiCmd,
    BOOL bIsFocus=FALSE);

Parameters

uiCmd
[in] The command ID of a combo box button.

bIsFocus
[in] TRUE to search only focused buttons; FALSE to search all buttons.

Return Value

A pointer to a combo box button; or NULL if the button is not found.

Remarks

CMFCToolBarComboBoxButton::GetComboBox

Returns a pointer to the combo box in the combo box button.

CComboBox* GetComboBox() const;

Return Value

A pointer to the CComboBox Class object if the method was successful; otherwise NULL.

Remarks

CMFCToolBarComboBoxButton::GetContextMenuID

Gets the shortcut menu resource ID for the combo box button.

UINT GetContextMenuID();

Return Value

The shortcut menu resource ID.

CMFCToolBarComboBoxButton::GetCount

Returns the number of items in the list box.

INT_PTR GetCount() const;

Return Value

The number of items in the list box.

Remarks

CMFCToolBarComboBoxButton::GetCountAll

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

static int GetCountAll(UINT uiCmd);

Parameters

uiCmd
[in] The command ID of a combo box button.

Return Value

The number of items in the list box; otherwise, CB_ERR if the combo box button is not found.

Remarks

CMFCToolBarComboBoxButton::GetCurSel

Gets the index of the currently selected item in the list box.

int GetCurSel() const;

Return Value

The index of the currently selected item in the list box; or CB_ERR if no item is selected.

Remarks

The list box index is zero-based.

CMFCToolBarComboBoxButton::GetCurSelAll

Returns the index of the currently selected item in the list box of a combo box button that has a specified command ID.

static int GetCurSelAll(UINT uiCmd);

Parameters

uiCmd
[in] The command ID of a combo box button.

Return Value

The index of the currently selected item in the list box; otherwise, CB_ERR if no item is selected or a combo box button is not found.

Remarks

The list box index is zero-based.

CMFCToolBarComboBoxButton::GetEditCtrl

Returns a pointer to the edit box in the combo box button.

virtual CEdit* GetEditCtrl();

Return Value

A pointer to the edit box if the method was successful; otherwise, NULL.

Remarks

CMFCToolBarComboBoxButton::GetHwnd

Returns the window handle for the combo box.

virtual HWND GetHwnd();

Return Value

The window handle, or NULL if the combo box is not associated with a window object.

CMFCToolBarComboBoxButton::GetItem

Returns the string associated with an item at a specified index in the list box.

LPCTSTR GetItem(int iIndex=-1) const;

Parameters

iIndex
[in] Zero-based index of an item in the list box.

Return Value

A pointer to the string that is associated with the item; otherwise, NULL if the index parameter is invalid, or if the index parameter is -1 and there is no selected item in the combo box.

Remarks

An index parameter of -1 returns the string of the item that is currently selected.

CMFCToolBarComboBoxButton::GetItemAll

Returns the string associated with an item at a specified index in the list box of a combo box button that has a specified command ID.

static LPCTSTR GetItemAll(
    UINT uiCmd,
    int iIndex=-1);

Parameters

uiCmd
[in] The command ID of a combo box button.

iIndex
[in] The zero-based index of an item in the list box.

Return Value

A pointer to the item's string if the method was successful; otherwise, NULL if the index is invalid, a combo box button is not found, or if index is -1 and there is no selected item in the combo box.

Remarks

An index value of -1 returns the string of the item that is currently selected.

CMFCToolBarComboBoxButton::GetItemData

Returns the data associated with an item at a specific index in the list box.

DWORD_PTR GetItemData(int iIndex=-1) const;

Parameters

iIndex
[in] The zero-based index of an item in the list box.

Return Value

The data associated with the item; or 0 if the item does not exist.

Remarks

An index parameter of -1 returns the data associated with the currently selected item.

CMFCToolBarComboBoxButton::GetItemDataAll

Returns the data associated with an item at a specific index in the list box of a combo box button that has a specific command ID.

static DWORD_PTR GetItemDataAll(
    UINT uiCmd,
    int iIndex=-1);

Parameters

uiCmd
[in] The command ID of a combo box button.

iIndex
[in] The zero-based index of an item in the list box.

Return Value

The data associated with the item if the method was successful; otherwise, 0 if the specified index is not valid, or CB_ERR if the combo box button is not found.

Remarks

An index parameter of -1 returns the data associated with the currently selected item.

CMFCToolBarComboBoxButton::GetItemDataPtrAll

Returns the data associated with an item at a specific index in the list box of a combo box button that has a specific command ID. This data is returned as a pointer.

static void* GetItemDataPtrAll(
    UINT uiCmd,
    int iIndex=-1);

Parameters

uiCmd
[in] The command ID of the combo box button.

iIndex
[in] The zero-based index of an item in the list box.

Return Value

A pointer associated with the item if the method was successful; otherwise, -1 if an error occurs, or NULL if the combo box button is not found.

Remarks

CMFCToolBarComboBoxButton::GetPrompt

Returns the prompt string for the combo box button.

virtual CString GetPrompt() const;

Return Value

The prompt string.

Remarks

This method is currently not implemented.

CMFCToolBarComboBoxButton::GetText

Gets the text in the edit box.

LPCTSTR GetText() const;

Return Value

The text in the edit box.

Remarks

CMFCToolBarComboBoxButton::GetTextAll

Gets the text in the edit box of a combo box button that has a specified command ID.

static LPCTSTR GetTextAll(UINT uiCmd);

Parameters

uiCmd
[in] The command ID of a specific combo box button.

Return Value

The text in the edit box if the method was successful; otherwise, NULL.

Remarks

CMFCToolBarComboBoxButton::HasFocus

Indicates whether the combo box currently has the focus.

virtual BOOL HasFocus() const;

Return Value

TRUE if the combo box currently has the focus; otherwise, FALSE.

Remarks

This method also returns TRUE if any child window of the combo box currently has the focus.

CMFCToolBarComboBoxButton::IsCenterVert

Returns the vertical position of combo box buttons in the application.

static BOOL IsCenterVert();

Return Value

TRUE if the buttons are centered; FALSE if the buttons are aligned at the top.

Remarks

CMFCToolBarComboBoxButton::IsFlatMode

Returns the flat style appearance of combo box buttons in the application.

static BOOL IsFlatMode();

Return Value

TRUE if the buttons have a flat style; otherwise, FALSE.

Remarks

The default flat style for combo box buttons is FALSE.

CMFCToolBarComboBoxButton::IsOwnerOf

Indicates whether the specified handle is associated with the combo box button, or one of its children.

virtual BOOL IsOwnerOf(HWND hwnd);

Parameters

hwnd
[in] A window handle.

Return Value

TRUE if the handle is assocated with the combo box button, or one of its children; otherwise, FALSE.

CMFCToolBarComboBoxButton::IsRibbonButton

Indicates whether the combo box button resides on a ribbon panel.

BOOL IsRibbonButton() const;

Return Value

Always FALSE.

Remarks

By default, this method always returns FALSE, which means the combo box button is never displayed on a ribbon panel.

CMFCToolBarComboBoxButton::IsWindowVisible

Returns the visibility state of the combo box button.

virtual BOOL IsWindowVisible();

Return Value

The visibility state of the combo box button.

CMFCToolBarComboBoxButton::NotifyCommand

Indicates whether the combo box button processes the message.

virtual BOOL NotifyCommand(int iNotifyCode);

Parameters

iNotifyCode
[in] The notification message that is associated with the command.

Return Value

Whether the combo box button processes the message.

CMFCToolBarComboBoxButton::OnAddToCustomizePage

Called by the framework when the button is added to the Customize dialog box.

virtual void OnAddToCustomizePage();

CMFCToolBarComboBoxButton::OnCalculateSize

Called by the framework to calculate the size of the button.

virtual SIZE OnCalculateSize(
    CDC* pDC,
    const CSize& sizeDefault,
    BOOL bHorz);

Parameters

pDC
[in] The device context that displays the combo box button.

sizeDefault
[in] The default size of the combo box button.

bHorz
[in] The dock state of the parent toolbar. TRUE when the toolbar is docked horizontally and FALSE when the toolbar is docked vertically.

Return Value

A SIZE structure that contains the dimensions of the combo box button, in pixels.

CMFCToolBarComboBoxButton::OnChangeParentWnd

Called by the framework when the combo box button is inserted into a new toolbar.

virtual void OnChangeParentWnd(CWnd* pWndParent);

Parameters

pWndParent
[in] Pointer to the new parent toolbar.

CMFCToolBarComboBoxButton::OnClick

Called by the framework when the user clicks the combo box button.

virtual BOOL OnClick(
    CWnd* pWnd,
    BOOL bDelay = TRUE);

Parameters

pWnd
[in] Pointer to the parent window of the combo box button.

bDelay
[in] Reserved for use in a derived class.

Return Value

TRUE if the method handles the event; otherwise, FALSE.

CMFCToolBarComboBoxButton::OnCtlColor

Called by the framework when the user changes the parent toolbar color to set the combo box button color.

virtual HBRUSH OnCtlColor(
    CDC* pDC,
    UINT nCtlColor);

Parameters

pDC
[in] The device context that displays the combo box button.

nCtlColor
[in] Unused.

Return Value

Handle to the brush that the framework uses to paint the background of the combo box button.

Remarks

This method also sets the combo box button text color.

CMFCToolBarComboBoxButton::OnDraw

Called by the framework to draw the combo box button by using the specified styles and options.

virtual void OnDraw(
    CDC* pDC,
    const CRect& rect,
    CMFCToolBarImages* pImages,
    BOOL bHorz = TRUE,
    BOOL bCustomizeMode = FALSE,
    BOOL bHighlight = FALSE,
    BOOL bDrawBorder = TRUE,
    BOOL bGrayDisabledButtons = TRUE);

Parameters

Pdc
[in] The device context that displays the button.

rect
[in] The bounding rectangle of the button.

pImages
[in] The collection of images that is associated with the button.

bHorz
[in] The dock state of the parent toolbar. TRUE when the toolbar is docked horizontally and FALSE when the toolbar is docked vertically.

bCustomizeMode
[in] Whether the application is in customization mode.

bHighlight
[in] Whether to draw the combo box button highlighted.

bDrawBorder
[in] Whether to draw the combo box button with a border.

bGrayDisabledButtons
[in] TRUE to draw shaded disabled buttons; FALSE to use the disabled images collection.

CMFCToolBarComboBoxButton::OnDrawOnCustomizeList

Called by the framework to draw the combo box button in the Commands pane of the Customize dialog box.

virtual int OnDrawOnCustomizeList(
    CDC* pDC,
    const CRect& rect,
    BOOL bSelected);

Parameters

pDC
[in] The device context that displays the combo box button.

rect
[in] The bounding rectangle of the combo box button.

bSelected
[in] TRUE if the combo box button is selected; otherwise, FALSE.

Return Value

The width, in pixels, of the combo box button.

CMFCToolBarComboBoxButton::OnGlobalFontsChanged

Called by the framework to set the combo box button font when the application font changes.

virtual void OnGlobalFontsChanged();

CMFCToolBarComboBoxButton::OnMove

Called by the framework to change the location of the combo box button when the parent toolbar moves.

virtual void OnMove();

CMFCToolBarComboBoxButton::OnShow

Called by the framework when the combo box button is hidden or displayed.

virtual void OnShow(BOOL bShow);

Parameters

bShow
[in] Whether to hide or display the combo box button.

CMFCToolBarComboBoxButton::OnSize

Called by the framework to change the size of the combo box button when the parent toolbar changes size.

virtual void OnSize(int iSize);

Parameters

iSize
[in] The new width of the combo box button.

CMFCToolBarComboBoxButton::OnUpdateToolTip

Called by the framework when the user changes the tool tip for the combo box button.

virtual BOOL OnUpdateToolTip(
    CWnd* pWndParent,
    int iButtonIndex,
    CToolTipCtrl& wndToolTip,
    CString& str);

Parameters

pWndParent
[in] Pointer to the parent window for the combo box button.

iButtonIndex
[in] ID of the combo box button.

wndToolTip
[in] The tool tip to associate with the combo box button.

str
[in] The tool tip text.

Return Value

TRUE if the method handles the event; otherwise, FALSE.

CMFCToolBarComboBoxButton::RemoveAllItems

Deletes all items from the list and edit boxes.

void RemoveAllItems();

Remarks

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

CMFCToolBarComboBoxButton::SelectItem

Selects an item in the list box.

BOOL SelectItem(
    int iIndex,
    BOOL bNotify=TRUE);

BOOL SelectItem(DWORD_PTR dwData);
BOOL SelectItem(LPCTSTR lpszText);

Parameters

iIndex
[in] The zero-based index of an item in the list box.

bNotify
[in] TRUE to notify the combo box button of the selection; otherwise FALSE.

dwData
[in] The data associated with an item in the list box.

lpszText
[in] The text of an item in the list box.

Return Value

TRUE if the method was successful; otherwise FALSE.

Remarks

CMFCToolBarComboBoxButton::SelectItemAll

Selects an item in the list box of a combo box button that has a specified command ID.

static BOOL SelectItemAll(
    UINT uiCmd,
    int iIndex);

static BOOL SelectItemAll(
    UINT uiCmd,
    DWORD_PTR dwData);

static BOOL SelectItemAll(
    UINT uiCmd,
    LPCTSTR lpszText);

Parameters

uiCmd
[in] The command ID of the combo box button that contains the list box.

iIndex
[in] The zero-based index of the item in the list box. A value of -1 removes any current selection in the list box and clears the edit box.

dwData
[in] The data of an item in the list box.

lpszText
[in] The text of an item in the list box.

Return Value

TRUE if the method was successful; otherwise FALSE.

Remarks

CMFCToolBarComboBoxButton::Serialize

Reads this object from an archive or writes it to an archive.

virtual void Serialize(CArchive& ar);

Parameters

ar
[in, out] The CArchive object to serialize.

Remarks

Settings in the CArchive object determine whether this method reads or writes to the archive.

CMFCToolBarComboBoxButton::SetACCData

Populates the specified CAccessibilityData object by using accessibility data from the combo box button.

virtual BOOL SetACCData(
    CWnd* pParent,
    CAccessibilityData& data);

Parameters

pParent
[in] The parent window of the combo box button.

data
[out] A CAccessibilityData object that receives the accessibility data from the combo box button.

Return Value

TRUE if the method was successful; otherwise FALSE.

CMFCToolBarComboBoxButton::SetCenterVert

Sets the vertical position of combo box buttons in the application.

static void SetCenterVert(BOOL bCenterVert=TRUE);

Parameters

bCenterVert
[in] TRUE to center the combo box button in the toolbar; FALSE to align the combo box button to the top of the toolbar.

Remarks

By default, combo box buttons are aligned to the top.

CMFCToolBarComboBoxButton::SetContextMenuID

Sets the shortcut menu resource ID for the combo box button.

void SetContextMenuID(UINT uiResID);

Parameters

uiResID
[in] The shortcut menu resource ID.

CMFCToolBarComboBoxButton::SetDropDownHeight

Sets the height of the list box when it is dropped down.

void SetDropDownHeight(int nHeight);

Parameters

nHeight
[in] The height, in pixels, of the list box.

Remarks

The default height is 150 pixels.

CMFCToolBarComboBoxButton::SetFlatMode

Sets the flat style appearance of combo box buttons in the application.

static void SetFlatMode(BOOL bFlat=TRUE);

Parameters

bFlat
[in] TRUE for a flat style appearance; otherwise FALSE.

Remarks

The default flat style for combo box buttons is FALSE.

CMFCToolBarComboBoxButton::SetStyle

Sets the specified style for the combo box button and redraws the control if it is not disabled.

virtual void SetStyle(UINT nStyle);

Parameters

nStyle
[in] A bitwise combination (OR) of toolbar styles.

Remarks

For a list of toolbar button styles see ToolBar Control Styles

CMFCToolBarComboBoxButton::SetText

Sets the text in the edit box of the combo box button.

void SetText(LPCTSTR lpszText);

Parameters

lpszText
[in] Pointer to a string that contains the text for the edit box.

See also

Hierarchy Chart
Classes
CMFCToolBarButton Class
CComboBox Class
CMFCToolBar::ReplaceButton
Walkthrough: Putting Controls On Toolbars