函数参考


_GUICtrlButton_SetCheck

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

#include <GuiButton.au3>
_GUICtrlButton_SetCheck($hWnd [, $iState = $BST_CHECKED])

参数

$hWnd 控件的控件ID/句柄
$iState [可选参数] 选取状态.这个参数可能是下列值之一:
$BST_CHECKED - 设置按钮状态为选中.
$BST_INDETERMINATE - 设置按钮状态为灰色, 表明不确定状态.
只有当按钮具有 $BS_3STATE 或 $BS_AUTO3STATE 样式时,此参数有效.
$BST_UNCHECKED - 设置按钮为非选取状态.

返回值

None.

注意/说明

 _GUICtrlButton_SetCheck 对 push buttons 类型按钮没有效果.

相关

_GUICtrlButton_GetCheck, _GUICtrlButton_GetState, _GUICtrlButton_SetState

详情参考

在MSDN中搜索


示例/演示


#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>

Global $iMemo

_Main()

Func _Main()
    Local $rdo, $rdo2, $chk

    GUICreate("Buttons", 400, 400)
    $iMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")

    $rdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)

    $rdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($rdo2)
    _GUICtrlButton_SetFocus($rdo2) ; set focus, shows this doesn't affect _GUICtrlButton_GetCheck

    $chk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($chk, $BST_INDETERMINATE)

    GUISetState()

    MemoWrite("$rdo checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($rdo)) & @CRLF)
    MemoWrite("$rdo2 checked status: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($rdo2)) & @CRLF)
    MemoWrite("$chk checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($chk)) & @CRLF)


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>_Main

; 写入一行到 memo 控件
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func _ExplainCheckState($iState)
    Switch $iState
        Case $BST_CHECKED
            Return "Button is checked."
        Case $BST_INDETERMINATE
            Return "Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style)."
        Case $BST_UNCHECKED
            Return "Button is cleared"
    EndSwitch
EndFunc   ;==>_ExplainCheckState