函数参考


_GUICtrlHeader_SetImageList

分配图像列表

#include <GuiHeader.au3>
_GUICtrlHeader_SetImageList($hWnd, $hImage)

参数

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

返回值

成功: 返回控件先前关联的图像列表句柄
失败: 返回 0

注意/说明

None.

相关

_GUICtrlHeader_GetImageList

示例/演示


#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

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

Global $iMemo

_Main()

Func _Main()
    Local $hGUI, $hHeader, $hImage

    ; 创建 GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    $iMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; 创建一个含有图像的图像列表
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    Local $hPrevImageList = _GUICtrlHeader_SetImageList($hHeader, $hImage)

    MemoWrite("Previous Image list handle ....: " & "0x" & Hex($hPrevImageList))
    MemoWrite("IsPtr = " & IsPtr($hPrevImageList) & " IsHwnd = " & IsHWnd($hPrevImageList))

    ; 添加列
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show header information
    MemoWrite("Image list handle ....: " & "0x" & Hex(_GUICtrlHeader_GetImageList($hHeader)))

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

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