Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
MFC
Styles Used by MFC
 Button Styles

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
MFC Library Reference
Button Styles

Updated: May 2009

  • This section lists general button types. You can (optionally) choose one of the following. If no option is specified, the button style defaults to BS_PUSHBUTTON.

  • BS_3STATE   Creates a check box button with three states: BST_CHECKED, BST_INDETERMINATE, and BST_UNCHECKED. Clicking on the button sends an ON_BN_CLICKED message to the owner window but does not automatically change the state of the button. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style.

  • BS_AUTO3STATE   Creates a check box button with three states: BST_CHECKED, BST_INDETERMINATE, and BST_UNCHECKED. Clicking on the button sends an ON_BN_CLICKED message to the owner window and automatically changes the state of the button. The button states cycle in the order of BST_CHECKED, BST_INDETERMINATE, and BST_UNCHECKED. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style.

  • BS_AUTOCHECKBOX   Creates a check box button with two states: BST_CHECKED and BST_UNCHECKED. Clicking on the button sends an ON_BN_CLICKED message to the owner window and changes the state of the button. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style.

  • BS_AUTORADIOBUTTON   Creates a radio button with two states: BST_CHECKED and BST_UNCHECKED. Radio buttons are usually used in groups, with each group having a maximum of one checked option at any given time. Clicking on the button sends an ON_BN_CLICKED message to the owner window, sets the state of the clicked radio button to BST_CHECKED, and sets the states of all other radio buttons in the button group to BST_UNCHECKED. By default, associated text is displayed to the right of the radio button. To display text to the left of the radio button, use the BS_LEFTTEXT or BS_RIGHTBUTTON style.

  • BS_CHECKBOX   Creates a check box button with two states: BST_CHECKED and BST_UNCHECKED. Clicking on the button sends an ON_BN_CLICKED message to the owner window but does not automatically change the state of the button. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style.

  • BS_COMMANDLINK   Creates a command link button. A command link button is a command button specific to Windows Vista that displays a green arrow to the left of the main text as well as an additional note below the main text. You can set the note text using CButton::SetNote.

  • BS_DEFCOMMANDLINK   Creates a command link button. A command link button is a command button specific to Windows Vista that displays a green arrow to the left of the main text as well as an additional note below the main text. You can set the note text using CButton::SetNote. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style enables the user to quickly select the most likely (default) option.

  • BS_DEFPUSHBUTTON   Creates a command button that has a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style enables the user to quickly select the most likely (default) option.

  • BS_DEFSPLITBUTTON    Creates a split button. A split button is a command button specific to Windows Vista that contains a main button area with a drop-down arrow on the side. When the main button area is clicked, the default action of the button is performed. By default, clicking the drop-down arrow displays a menu of additional actions that are performed when clicked. If the split button is in a dialog box, the user can select the split button by pressing the ENTER key, even when the split button does not have the input focus. This style is useful for enabling the user to quickly select the most likely (default) option.

  • BS_GROUPBOX   Creates a rectangle in which other buttons can be grouped. Text associated with this style is displayed in the rectangle's upper-left corner.

  • BS_OWNERDRAW   Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.

  • BS_PUSHBUTTON   Creates a command button that sends an ON_BN_CLICKED message to the owner window when the user clicks the button.

  • BS_RADIOBUTTON   Creates a radio button with two states: BST_CHECKED and BST_UNCHECKED. Radio buttons are usually used in groups, with each group having a maximum of one checked option at any given time. Clicking on the button sends an ON_BN_CLICKED message to the owner window but does not automatically change the state of any button in the group. By default, associated text is displayed to the right of the radio button. To display text to the left of the radio button, use the BS_LEFTTEXT or BS_RIGHTBUTTON style.

  • BS_SPLITBUTTON   Creates a split button. A split button is a command button specific to Windows Vista that contains a main button area with a drop-down arrow on the side. When the main button area is clicked, the default action of the button is performed. By default, clicking the drop-down arrow displays a menu of additional actions that are performed when clicked.

  • BS_USERBUTTON   Obsolete, but provided for compatibility with 16-bit versions of Windows. Win32-based applications should use BS_OWNERDRAW instead.

  • This section lists styles that are specific to radio buttons and check boxes and are ignored in all other button styles. You can (optionally) choose one or more of the following.

  • BS_LEFTTEXT   When combined with a radio button or check-box style, the text appears on the left side of the radio button or check box.

  • BS_RIGHTBUTTON   When combined with a radio button or check-box style, the text appears on the left side of the radio button or check box.

  • BS_PUSHLIKE   Makes a check box or radio button look and behave like a command button. The button appears pressed when its state is BST_CHECKED, pressed and dimmed when its state is BST_INDETERMINATE, and released when its state is BST_UNCHECKED.

  • This section lists horizontal text alignment options. You can (optionally) choose one of the following.

  • BS_CENTER   Centers text horizontally within the button rectangle.

  • BS_LEFT   Left aligns the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is left aligned on the right side of the check box or radio button.

  • BS_RIGHT   Right aligns the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is right aligned on the right side of the check box or radio button.

  • This section lists vertical text alignment options. You can (optionally) choose one of the following options.

  • BS_BOTTOM   Places text at the bottom of the button rectangle.

  • BS_TOP   Places text at the top of the button rectangle.

  • BS_VCENTER   Centers text vertically within the button rectangle.

  • This section lists button content options. Button styles that only display text ignore these styles. Youc an (optionally) choose one of the following options.

  • BS_BITMAP   Specifies that the button displays a bitmap.

  • BS_ICON   Specifies that the button displays an icon.

  • BS_TEXT   Specifies that the button displays text.

  • This section lists additional options that are not

  • BS_FLAT   Specifies that the button is two-dimensional and is not drawn with default shading to create a 3-D image.

  • BS_MULTILINE   Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.

  • BS_NOTIFY   Enables a button to send BN_DBLCLK, BN_KILLFOCUS, and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether this style is specified.

Date

History

Reason

May 2009

Complete overhaul. Reorganized content by (mostly) related and mutually-exclusive groups. Rewrote content for added clarity.

Information enhancement.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker