Function Reference


_GUIImageList_Remove

Remove Image(s) from the ImageList

#include <GuiImageList.au3>
_GUIImageList_Remove ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd Handle to the imagelist
$iIndex [optional] The index of the image to remove. If this parameter is -1, the function removes all images

Return Value

Success: True.
Failure: False.

Remarks

When an image is removed, the indexes of the remaining images are adjusted so that the image indexes always range from zero to one less than the number of images in the image list.
For example, if you remove the image at index 0, then image 1 becomes image 0, image 2 becomes image 1, and so on.

Example

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

Example()

Func Example()
        Local $idListview, $hImage
        Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

        GUICreate("ImageList Remove", 400, 300)
        $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
        _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
        GUISetState(@SW_SHOW)

        ; Load images
        $hImage = _GUIImageList_Create(16, 16, 5, 3)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
        _GUICtrlListView_SetImageList($idListview, $hImage, 1)

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

        ; Add items
        _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
        _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
        _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
        _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
        _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
        _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
        _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
        _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
        _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
        _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
        _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
        _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

        MsgBox($MB_SYSTEMMODAL, "Information", "Removing Image Index 0")
        _GUIImageList_Remove($hImage, 0)

        _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))

        ; Add items
        _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
        _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
        _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
        _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
        _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
        _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
        _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
        _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
        _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
        _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
        _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
        _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

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