函数参考


_GUICtrlButton_GetCheck

得到单选按钮或者复选框选中状态

#include <GuiButton.au3>
_GUICtrlButton_GetCheck($hWnd)

参数

$hWnd 控件的控件ID/句柄

返回值

成功: 具有 $BS_AUTOCHECKBOX, $BS_AUTORADIOBUTTON,
$BS_AUTO3STATE, $BS_CHECKBOX, $BS_RADIOBUTTON, 或 $BS_3STATE 等样式按钮的返回值可以是下列项之一:
$BST_CHECKED - 按钮选中.
$BST_INDETERMINATE - 按钮成灰色,表示不确定的状态 (只应用于有 $BS_3STATE or $BS_AUTO3STATE style).
$BST_UNCHECKED 按钮非选中
失败: 返回 0

注意/说明

如果按钮另有上面列出的那些之外的样式,返回数值将为零.

相关

_GUICtrlButton_GetState, _GUICtrlButton_SetCheck

详情参考

在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) ; 设置焦点, 演示这个不影响 _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

; 自定义函数 MemoWrite 功能动作: 向编辑框写入当前按钮信息
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