Compartilhar via


CButton::GetState

Retrieves the state of a button control.

UINT GetState( ) const;

Return Value

A bit field that contains the combination of values that indicate the current state of a button control. The following table lists possible values.

Button State

Value

Description

BST_UNCHECKED

0x0000

The initial state.

BST_CHECKED

0x0001

The button control is checked.

BST_INDETERMINATE

0x0002

The state is indeterminate (only possible when the button control has three states).

BST_PUSHED

0x0004

The button control is pressed.

BST_FOCUS

0x0008

The button control has the focus.

Remarks

A button control with the BS_3STATE or BS_AUTO3STATE button style creates a check box that has a third state that is named the indeterminate state. The indeterminate state indicates that the check box is neither checked nor unchecked.

Example

CButton myPushButton;

// Create a push button.
myPushButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 
   CRect(10,10,100,30), pParentWnd, 1);

// Invert the highlight state of the button.
myPushButton.SetState(!(myPushButton.GetState() & 0x0004));

Requirements

Header: afxwin.h

See Also

Reference

CButton Class

Hierarchy Chart

CButton::GetCheck

CButton::SetCheck

CButton::SetState

BM_GETSTATE