Compartir a través de


CButton::SetButtonStyle

Changes the style of a button.

void SetButtonStyle(
   UINT nStyle,
   BOOL bRedraw = TRUE 
);

Parameters

  • nStyle
    Specifies the button style.

  • bRedraw
    Specifies whether the button is to be redrawn. A nonzero value redraws the button. A 0 value does not redraw the button. The button is redrawn by default.

Remarks

Use the GetButtonStyle member function to retrieve the button style. The low-order word of the complete button style is the button-specific style.

Example

CButton myRadioButton;

// Create a radio button.
myRadioButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 
   CRect(10,10,100,30), pParentWnd, 1);

// Change the button style to use one of the "auto" styles; for
// push button, change to def push button.
UINT uStyle = myRadioButton.GetButtonStyle();
if (uStyle == BS_PUSHBUTTON)
   uStyle = BS_DEFPUSHBUTTON;
else if (uStyle == BS_RADIOBUTTON)
   uStyle = BS_AUTORADIOBUTTON;
else if (uStyle == BS_CHECKBOX)
   uStyle = BS_AUTOCHECKBOX;
else if (uStyle == BS_3STATE)
   uStyle = BS_AUTO3STATE;

// Change the button style to the one wanted.
myRadioButton.SetButtonStyle(uStyle);

Requirements

Header: afxwin.h

See Also

Reference

CButton Class

Hierarchy Chart

CButton::GetButtonStyle

BM_SETSTYLE

Other Resources

CButton Members