Compartilhar via


CButton::GetCheck

Retrieves the check state of a radio button or check box.

int GetCheck( ) const;

Return Value

The return value from a button control created with the BS_AUTOCHECKBOX, BS_AUTORADIOBUTTON, BS_AUTO3STATE, BS_CHECKBOX, BS_RADIOBUTTON, or BS_3STATE style is one of the following values:

Value

Meaning

BST_UNCHECKED

Button state is unchecked.

BST_CHECKED

Button state is checked.

BST_INDETERMINATE

Button state is indeterminate (applies only if the button has the BS_3STATE or BS_AUTO3STATE style).

If the button has any other style, the return value is BST_UNCHECKED.

Example

CButton myA3Button;

// Create an auto 3-state button.
myA3Button.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, 
   CRect(10,10,100,30), pParentWnd, 1);

// Set the check state to the next state  
// (i.e. BST_UNCHECKED changes to BST_CHECKED 
// BST_CHECKED changes to BST_INDETERMINATE 
// BST_INDETERMINATE changes to BST_UNCHECKED).
myA3Button.SetCheck(((myA3Button.GetCheck() + 1 ) % 3));

Requirements

Header: afxwin.h

See Also

Reference

CButton Class

Hierarchy Chart

CButton::GetState

CButton::SetState

CButton::SetCheck

BM_GETCHECK