#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <winapiex.au3>
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hImage, $hListView
GUICreate("ListView Set Outline Color", 800, 600)
$hListView = GUICtrlCreateListView("", 2, 2, 780,580)
GUICtrlSetStyle($hListView, $LVS_ICON)
; Enable extended control styles
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_BORDERSELECT)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(48,48,5,1)
_GUIImageList_Add($hImage, __GUIImageList_AddIcon($hImage,"ico.ico",0))
_GUICtrlListView_SetImageList($hListView, $hImage, 0)
; Add columns
_GUICtrlListView_AddColumn($hListView, "Items")
; Add items
_GUICtrlListView_AddItem($hListView, "A01", 0)
_GUICtrlListView_AddItem($hListView, "A02", 0)
_GUICtrlListView_AddItem($hListView, "A03", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A01", 0)
_GUICtrlListView_AddItem($hListView, "A02", 0)
_GUICtrlListView_AddItem($hListView, "A03", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
; Set outline color
_GUICtrlListView_SetOutlineColor($hListView, 0x0000FF)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func __GUIImageList_AddIcon($hWnd, $sFile, $iIndex = 0)
Local $iRet
$iRet = _WinAPI_ShellExtractIcon($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
|