函数参考

_GUICtrlListView_SetImageList

Assigns an image list to the control

#Include <GuiListView.au3>
_GUICtrlListView_SetImageList($hWnd, $hHandle[, $iType = 0])

 

参数

$hWnd Handle to the control
$hHandle Handle to the image list to assign
$iType [可选参数] Type of image list:
0 - Image list with large icons
1 - Image list with small icons
2 - Image list with state images

 

返回值

Success: The handle to the previous image list
Failure: 0

 

注意/说明

The current image list will be destroyed when the control is destroyed unless you set the $LVS_SHAREIMAGELISTS
style. If you use this message to replace one image list with another your application must explicitly destroy
all image lists other than the current one.

 

相关

_GUICtrlListView_GetImageList

 

示例/演示


#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hImage, $hListView
   
    GUICreate("ListView Set Image List", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Item 1", 0)
    _GUICtrlListView_AddItem($hListView, "Item 2", 1)
    _GUICtrlListView_AddItem($hListView, "Item 3", 2)

    ; Get image list handle
    MsgBox(4160, "Information", "Image List Handle: 0x" & Hex(_GUICtrlListView_GetImageList($hListView, 1)))

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main