函数参考


_GUICtrlButton_SetImage

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

#include <GuiButton.au3>
_GUICtrlButton_SetImage($hWnd, $sImageFile [, $nIconId = -1 [, $fLarge = False]])

参数

$hWnd 控件的控件ID/句柄
$sImageFile 包含图像的文件
$nIconId [可选参数] 基于0开始的图标索引
$fLarge [可选参数] 提取大图标

返回值

成功: 返回 True
失败: 返回 False

注意/说明

None.

相关

_GUICtrlButton_GetImage

详情参考

在MSDN中搜索


示例/演示


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

Global $iMemo

_Main()

Func _Main()
    Local $btn, $chk, $rdo, $Msg
    Local $Wow64 = ""
    If @AutoItX64 Then $Wow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    GUICreate("Buttons", 300, 300)
    $iMemo = GUICtrlCreateEdit("", 2, 60, 296, 236, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    $btn = GUICtrlCreateButton("Button1", 10, 10, 40, 40, $BS_BITMAP)
    _GUICtrlButton_SetImage($btn, $sPath & "\blue.bmp")

    $chk = GUICtrlCreateCheckbox("Check1", 60, 10, 50, 32, $BS_ICON)
    _GUICtrlButton_SetImage($chk, "shell32.dll", 14, True)

    $rdo = GUICtrlCreateRadio("Radio1", 120, 10, 50, 32, $BS_ICON)
    _GUICtrlButton_SetImage($rdo, "shell32.dll", 21, True)

    MemoWrite("Button1 Image Handle: " & _GUICtrlButton_GetImage($btn))
    MemoWrite("Check1 Image Handle: " & _GUICtrlButton_GetImage($chk))
    MemoWrite("Radio1 Image Handle: " & _GUICtrlButton_GetImage($rdo))

    While 1
        $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    Exit
EndFunc   ;==>_Main

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