Code : Tout sélectionner
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Array.au3>
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, -1, $LVS_EX_SUBITEMIMAGES+$LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 200)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 2, 130)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @Autoitexe, 0)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 132)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 138)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
Dim $ligne[3]
$ligne[0] = GUICtrlCreateListViewItem("|" &$array[0][1] & "| ", $listview)
$ligne[1] = GUICtrlCreateListViewItem("|" &$array[1][1] & "|" , $listview)
$ligne[2] = GUICtrlCreateListViewItem("|" &$array[2][1] & "|" , $listview)
_GUICtrlListView_AddSubItem($listview, 0, "(1)", 0, 0)
_GUICtrlListView_AddSubItem($listview, 1, "(2)", 0, 1)
_GUICtrlListView_AddSubItem($listview, 2, "(3)", 0, 2)
_GUICtrlListView_AddSubItem($listview, 0, $array[0][2], 2, 3)
_GUICtrlListView_AddSubItem($listview, 1, $array[1][2], 2, 4)
_GUICtrlListView_AddSubItem($listview, 2, $array[2][2], 2, 5)
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)
ControlListView($gui, "", $listview, "DeSelect", -1)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY