Code : Tout sélectionner
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ListviewConstants.au3>
#include <Array.au3>
Global Const $tagNMHDR = "struct; hwnd hWndFrom;uint_ptr IDFrom;INT Code; endstruct"
Global Const $tagNMITEMACTIVATE = $tagNMHDR & ";int Index;int SubItem;int NewState;int OldState;" & _
"int Changed;int X;int Y;int lParam;int KeyFlags"
Dim $array[3][3]
$array[0][1] = @Autoitexe
$array[0][2] = FileGetVersion(@Autoitexe)
$array[1][1] = "ligne 2, colonne 1"
$array[1][2] = "ligne 2, colonne 2"
$array[2][1] = "ligne 3, colonne 1"
$array[2][2] = "ligne 3, colonne 2"
$gui = GUICreate("listview items", 420, 180, 100, 200, -1)
$listview = GUICtrlCreateListView("icone|colonne 1|colonne 2 ", 10, 10, 400, 130)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 80)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 200)
Dim $ligne[3]
$ligne[0] = GUICtrlCreateListViewItem("(1)|" &$array[0][1] & "|" & $array[0][2], $listview)
GUICtrlSetImage(-1, @Autoitexe, -1)
$ligne[1] = GUICtrlCreateListViewItem("(2)|" &$array[1][1] & "|" & $array[1][2], $listview)
GUICtrlSetImage(-1, @SystemDir & "\shell32.dll", -132)
$ligne[2] = GUICtrlCreateListViewItem("(3)|" &$array[2][1] & "|" & $array[2][2], $listview)
GUICtrlSetImage(-1, @SystemDir & "\shell32.dll", -138)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = GUICtrlGetHandle($listView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$index = DllStructGetData($tInfo, "Index")
For $i = 0 to 2
GuiCtrlSetColor($ligne[$i], 0x000000)
Next
GuiCtrlSetColor($ligne[$index], 0xff0000)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY