CButton::SetCheck

设置或重置单选按钮或复选框的复选状态。

void SetCheck(
   int nCheck 
);

参数

  • nCheck
    指定检查状态。 此参数可以是下列值之一:

    含义

    BST_UNCHECKED

    将按钮状态为未选中状态。

    BST_CHECKED

    将按钮状态设置为已选中。

    BST_INDETERMINATE

    将按钮状态为不确定。 此值,仅当按钮具有 BS_3STATEBS_AUTO3STATE 样式,可使用。

备注

此成员函数没有为普通按钮的效果。

示例

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));

要求

Header: afxwin.h

请参见

参考

CButton选件类

层次结构图

CButton::GetCheck

CButton::GetState

CButton::SetState

BM_SETCHECK