Obtient la liste d'images du syst�me pour les petites ou grandes ic�nes
#include <WinAPIShPath.au3>
_WinAPI_ShellGetImageList ( [$bSmall = False] )
$bSmall | [optionnel] Indique si vous souhaitez obtenir la liste d'images pour les petites ou pour les grandes ic�nes, les valeurs possibles sont: True - Les petites ic�nes. False - Les grandes ic�nes (par d�faut). |
Succ�s: | Retourne le handle de la liste d'images. |
�chec: | Retourne 0. |
Les listes d'images obtenues par cette fonction sont des listes globales d'images du syst�me; ne les d�truisez pas.
Pour utiliser cette fonction, vous devez appeler _WinAPI_FileIconInit() au lancement de l'application.
Consultez Shell_GetImageLists dans la librairie MSDN.
#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> ; Initialise les listes d'images syst�me _WinAPI_FileIconInit() ; Obtient la liste d'image syst�me et calcule la taille des bitmaps 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) ; Cr�e une GUI Local $hForm = GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), $W, $H) Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H) Local $hPic = GUICtrlGetHandle($idPic) ; Cr�e un bitmap Local $hDC = _WinAPI_GetDC($hPic) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $W, $H) Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap) ; Dessine toutes les ic�nes de la liste d'images syst�me dans le 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 ; Lib�re les objets _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hMemDC, $hMemSv) _WinAPI_DeleteDC($hMemDC) ; D�finit le bitmap dans lepour contr�le _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf ; Affiche la GUI GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE