Function Reference


_GUIImageList_GetIcon

Creates an icon from an image and mask in an image list

#include <GuiImageList.au3>
_GUIImageList_GetIcon ( $hWnd, $iIndex [, $iStyle = 0] )

Parameters

$hWnd Handle to the imagelist
$iIndex 0-based index of the image
$iStyle [optional] Drawing style and overlay image:
    1 - Draws the image transparently using the mask, regardless of the background color
    2 - Draws the image, blending 25 percent with the system highlight color
    4 - Draws the image, blending 50 percent with the system highlight color
    8 - Draws the mask

Return Value

Success: the handle to the icon if successful.
Failure: 0.

Remarks

It is the responsibility of the calling application to destroy the icon returned from this function using _GUIImageList_DestroyIcon().

Example

#include <Extras\WM_NOTIFY.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Global $g_hStatus, $g_idMemo

Example()

Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("ImageList Get Icon (v" & @AutoItVersion & ")", 400, 300)
        $g_hStatus = _GUICtrlStatusBar_Create($hGUI)

        ; Create memo control
        $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
        GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
        GUISetState(@SW_SHOW)

        _WM_NOTIFY_Register($g_idMemo)

        ; Set parts
        Local $aParts[4] = [75, 150, 300, 400]
        _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
        _GUICtrlStatusBar_SetText($g_hStatus, "Part 1")
        _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 1)

        ; Load images
        Local $hImage = _GUIImageList_Create(11, 11)
        _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0xFF0000, 11, 11))
        _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0x00FF00, 11, 11))
        _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0x0000FF, 11, 11))

        ; Set icons
        Local $ahIcons[2]
        $ahIcons[0] = _GUIImageList_GetIcon($hImage, 1)
        $ahIcons[1] = _GUIImageList_GetIcon($hImage, 2)
        _GUICtrlStatusBar_SetIcon($g_hStatus, 0, $ahIcons[0])
        _GUICtrlStatusBar_SetIcon($g_hStatus, 1, $ahIcons[1])

        ; Show icon handles
        MemoWrite("Part 1 icon handle .: 0x" & Hex($ahIcons[0]))
        MemoWrite("Part 2 icon handle .: 0x" & Hex($ahIcons[1]))
        MemoWrite("")

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        ; Free icons
        MsgBox($MB_SYSTEMMODAL, "Information", "Icon 1 Destroyed? " & _GUIImageList_DestroyIcon($ahIcons[0]))
        MsgBox($MB_SYSTEMMODAL, "Information", "Icon 2 Destroyed? " & _GUIImageList_DestroyIcon($ahIcons[1]))
        GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
        GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam

        Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        Local $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
        Case $g_hStatus
                        Switch $iCode
                                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                                        _WM_NOTIFY_DebugEvent("$NM_CLICK", $tagNMMOUSE, $lParam, "IDFrom,,ItemSpec,ItemData,X,Y,HitInfo")
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                                        _WM_NOTIFY_DebugEvent("$NM_DBLCLK", $tagNMMOUSE, $lParam, "IDFrom,,ItemSpec,ItemData,X,Y,HitInfo")
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                                        _WM_NOTIFY_DebugEvent("$NM_RCLICK", $tagNMMOUSE, $lParam, "IDFrom,,ItemSpec,ItemData,X,Y,HitInfo")
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                                        _WM_NOTIFY_DebugEvent("$NM_RDBLCLK", $tagNMMOUSE, $lParam, "IDFrom,,ItemSpec,ItemData,X,Y,HitInfo")
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                                        _WM_NOTIFY_DebugEvent("$SBN_SIMPLEMODECHANGE", $tagNMHDR, $lParam, ",hWndFrom,IDFrom")
                                        ; No return value
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY