函数参考


_GUICtrlToolbar_SetDisabledImageList

设置禁用状态图像列表

#Include <GuiToolBar.au3>
_GUICtrlToolbar_SetDisabledImageList($hWnd, $hImageList)

参数

$hWnd 控件句柄
$hImageList 图像列表句柄

返回值

成功: 返回先前显示禁用状态的图像列表句柄
失败: 返回 0

注意/说明

None.

相关

_GUICtrlToolbar_GetDisabledImageList

示例/演示


#include <GuiToolbar.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Debug_TB = False ; 检查传递给函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
Global $iMemo

_Main()

Func _Main()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; 创建 GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $iMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 10, 400, 0, "Courier New")
    GUISetState()

    ; 创建普通图像列表
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)

    ; 创建已禁用的图像列表
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    Local $hPrevImageList = _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)
    MemoWrite("Previous Disabled list handle .: 0x" & Hex($hPrevImageList))
    MemoWrite("IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

    ; 创建热图像列表
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)

    ; 添加按钮
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; 禁用蓝色按钮
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; 显示图像列表句柄
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; 写入消息到 memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite