Function Reference


Adds an image or images to an image list, generating a mask from the specified bitmap

#include <GuiImageList.au3>
_GUIImageList_AddMasked ( $hWnd, $hImage [, $iMask = 0] )


$hWnd Handle to the imagelist
$hImage Handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap.
$iMask [optional] Color used to generate the mask. Each pixel of this color in the specified bitmap is changed to black, and the corresponding bit in the mask is set to 1.

Return Value

Success: the index of the first new image.
Failure: -1.


This function copies the bitmap to an internal data structure.
Be sure to use the _WinAPI_DeleteObject() function to delete $hImage after the function returns.
Bitmaps with color depth greater than 8 bpp are not supported.


_GUIImageList_Add, _WinAPI_DeleteObject


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


Func Example()
    Local $idListview, $hImage

    GUICreate("ImageList AddMasked", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))

    ; Load images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_AddMasked($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 11, 11))
    _GUIImageList_AddMasked($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 11, 11))
    _GUIImageList_AddMasked($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 11, 11))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

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

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