Function Reference


_WinAPI_ShellGetImageList

Retrieves the system image list for small or large icons

#include <WinAPIShPath.au3>
_WinAPI_ShellGetImageList ( [$bSmall = False] )

Parameters

$bSmall [optional] Specifies whether to retrieve an image list for small or large icons, valid values:
    True - The small icons.
    False - The large icons (Default).

Return Value

Success: Handle to the image list.
Failure: 0.

Remarks

The image list retrieved through this function are global system image list; do not destroy it.

To use this function, you must call _WinAPI_FileIconInit() at application launch.

Related

_WinAPI_FileIconInit

See Also

Search Shell_GetImageLists in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIIcons.au3>
#include <WinAPIShPath.au3>

; Initialize system image list
_WinAPI_FileIconInit()

; Retrieve system image list and calculate bitmap size
Local $hImageList = _WinAPI_ShellGetImageList()
If @error Then Exit

Local $iCount = _GUIImageList_GetImageCount($hImageList)
Local $a_iSize = _GUIImageList_GetIconSize($hImageList)
Local $iCX = Sqrt($iCount)
Local $iCY
If $iCX Then
        $iCX = Ceiling($iCX)
        $iCY = Ceiling($iCount / $iCX)
Else
        $iCX = 1
        $iCY = 1
EndIf
Local $W = $iCX * ($a_iSize[0] + 14)
Local $H = $iCY * ($a_iSize[1] + 14)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H)
Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $W, $H)
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Draw all icons from the system image list into bitmap
Local $iIndex = 0
For $y = 1 To $iCY
        For $x = 1 To $iCX
                _GUIImageList_Draw($hImageList, $iIndex, $hMemDC, ($x - 1) * ($a_iSize[0] + 14) + 7, ($y - 1) * ($a_iSize[0] + 14) + 7)
                $iIndex += 1
                If $iIndex >= $iCount Then
                        ExitLoop
                EndIf
        Next
Next

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE