Function Reference


_GUICtrlListView_SetImageList

Assigns an image list to the control

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

Parameters

$hWnd Control ID/Handle to the control
$hHandle Handle to the image list to assign
$iType [optional] Type of image list:
    0 - Image list with large icons
    1 - Image list with small icons
    2 - Image list with state images

Return Value

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

Remarks

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.

Related

_GUICtrlListView_GetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Image List", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

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

    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Image List Handle: 0x" & Hex($hPrevImageList) & @CRLF & _
            "IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

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

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

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

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