CButton::GetState

UINT GetState( ) const;

Return Value

Specifies the current state of the button control. You can use the following masks against the return value to extract information about the state:

Mask Meaning
0x0003 Specifies the check state (radio buttons and check boxes only). A 0 indicates the button is unchecked. A 1 indicates the button is checked. A radio button is checked when it contains a bullet (). A check box is checked when it contains an X. A 2 indicates the check state is indeterminate (three-state check boxes only). The state of a three-state check box is indeterminate when it contains a halftone pattern.
0x0004 Specifies the highlight state. A nonzero value indicates that the button is highlighted. A button is highlighted when the user clicks and holds the left mouse button. The highlighting is removed when the user releases the mouse button.
0x0008 Specifies the focus state. A nonzero value indicates that the button has the focus.

Remarks

Retrieves the state of a radio button or check box.

Example

CButton myButton;

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

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

CButton OverviewClass MembersHierarchy Chart

See Also   CButton::GetCheck, CButton::SetCheck, CButton::SetState, BM_GETSTATE