#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Global $hImage,$ListView
_Main()
Func _Main()
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
GUICreate("ImageList AddIcon", 400, 300)
$listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "\mmcndmgr.dll",32)
;_GUIImageList_AddIcon($hImage, @SystemDir & "\imageres.dll",12)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
; Add columns
_GUICtrlListView_AddColumn($listview, "",20)
_GUICtrlListView_AddColumn($listview, "Column 1", 120)
_GUICtrlListView_AddColumn($listview, "Column 2", 100)
_GUICtrlListView_AddColumn($listview, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($listview, "", 0)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 2)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 3)
_GUICtrlListView_AddItem($listview, "", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 2)
_GUICtrlListView_AddItem($listview, "", 2)
_GUICtrlListView_AddSubItem($listview, 2, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 2, "Row 2: Col 2", 2)
;_GUICtrlListView_SetItemImage($listview,1,0)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; Loop until user exits
While 1
$nMsg=GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
_GUIImageList_Destroy($hImage)
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView1, $SelectedID, $selectindex, $LISTVIEWcount,$selecttext,$selectarr
$hWndListView1 =WinGetHandle($ListView)
If Not IsHWnd($ListView) Then $hWndListView1 = GUICtrlGetHandle($ListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView1
Switch $iCode
Case $NM_DBLCLK
MsgBox(0,"","rdblclk")
Case $NM_CLICK
$selectindex= _GUICtrlListView_GetSelectionMark($listview)
$LISTVIEWcount=_GUICtrlListView_GetItemCount($ListView)
For $I=0 To $LISTVIEWcount-1
If $I=$selectindex Then
_GUICtrlListView_SetItemImage($listview,$I,0)
Else
_GUICtrlListView_SetItemImage($listview,$I,1)
EndIf
Next
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY