#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <array.au3>
_Main()
Func _Main()
Local $listview, $hImage
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_EX_CHECKBOXES,$LVS_EX_SNAPTOGRID)
GUICreate("ImageList GetBkColor", 800, 600)
$listview = GUICtrlCreateListView("", 2, 2, 794, 568, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(48, 48, 5, 1)
__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($listview, $hImage, 1)
; Add columns
_GUICtrlListView_AddColumn($listview, "Column 1", 200)
_GUICtrlListView_AddColumn($listview, "Column 2", 200)
_GUICtrlListView_AddColumn($listview, "Column 3", 100)
_GUICtrlListView_SetColumnWidth($listview,2,$LVSCW_AUTOSIZE_USEHEADER)
; Add items
_GUICtrlListView_AddItem($listview, "Row 1: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 1, 1)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 1, 2)
_GUICtrlListView_AddItem($listview, "Row 3: Col 1", 2)
_GUICtrlListView_AddItem($listview, "Row 4: Col 1", 3)
_GUICtrlListView_AddItem($listview, "Row 5: Col 1", 4)
_GUICtrlListView_AddSubItem($listview, 4, "Row 5: Col 2", 1, 3)
_GUICtrlListView_AddItem($listview, "Row 6: Col 1", 5)
_GUICtrlListView_AddSubItem($listview, 5, "Row 6: Col 2", 1, 4)
_GUICtrlListView_AddSubItem($listview, 5, "Row 6: Col 3", 2, 3)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func _Icons_Icon_Extract($sIcon, $iIndex, $iWidth, $iHeight)
Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0)
If (@error) Or ($Ret[0] = 0) Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[5]
EndFunc ;==>_Icons_Icon_Extract
Func __GUIImageList_AddIcon($hWnd, $sFile, $iIndex = 0)
Local $iRet
$iRet = _Icons_Icon_Extract($sFile, $iIndex, _GUIImageList_GetIconWidth($hWnd), _GUIImageList_GetIconWidth($hWnd))
If $iRet <= 0 Then Return SetError(-1, $iRet, 0)
Local $hIcon = $iRet
$iRet = _GUIImageList_ReplaceIcon($hWnd, -1, $hIcon)
_WinAPI_DestroyIcon($hIcon)
If $iRet = -1 Then Return SetError(-2, $iRet, 0)
Return $iRet
EndFunc ;==>__GUIImageList_AddIcon
|