1 | #include <Misc.au3> |
---|
2 | #include <GUIConstantsEx.au3> |
---|
3 | #include <GuiListView.au3> |
---|
4 | #include <WindowsConstants.au3> |
---|
5 | |
---|
6 | Local $hGUI, $hLV, $iIndex |
---|
7 | Local $fUnicode = False |
---|
8 | If _Singleton("TestLV", 1) Then $fUnicode = True |
---|
9 | |
---|
10 | If $fUnicode Then |
---|
11 | $hGUI = GUICreate("TestLV (Unicode)", 400, 400) |
---|
12 | Else |
---|
13 | $hGUI = GUICreate("TestLV (ASCII)", 400, 400) |
---|
14 | EndIf |
---|
15 | $hLV = _GUICtrlListView_Create($hGUI, "Header 1|Header 2|Header 3", 10, 10, 380, 380) |
---|
16 | _GUICtrlListView_SetExtendedListViewStyle($hLV, $LVS_EX_FULLROWSELECT) |
---|
17 | _GUICtrlListView_SetUnicodeFormat($hLV, $fUnicode) |
---|
18 | |
---|
19 | _GUICtrlListView_BeginUpdate($hLV) |
---|
20 | For $i = 0 To 9 |
---|
21 | $iIndex = _GUICtrlListView_InsertItem($hLV, "Item " & $i*3+1) |
---|
22 | For $j = 1 To 2 |
---|
23 | _GUICtrlListView_AddSubItem($hLV, $iIndex, "Item " & $i*3+$j+1, $j) |
---|
24 | Next |
---|
25 | Next |
---|
26 | _GUICtrlListView_EndUpdate($hLV) |
---|
27 | GUISetState() |
---|
28 | GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") |
---|
29 | |
---|
30 | Do |
---|
31 | Until GUIGetMsg() = $GUI_EVENT_CLOSE |
---|
32 | |
---|
33 | _GUICtrlListView_Destroy($hLV) |
---|
34 | GUIDelete() |
---|
35 | |
---|
36 | Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) |
---|
37 | Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView |
---|
38 | Local $tInfo, $iIndex |
---|
39 | |
---|
40 | $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) |
---|
41 | $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) |
---|
42 | $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") |
---|
43 | $iCode = DllStructGetData($tNMHDR, "Code") |
---|
44 | Switch $hWndFrom |
---|
45 | Case $hLV |
---|
46 | Switch $iCode |
---|
47 | Case $NM_CLICK |
---|
48 | $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) |
---|
49 | $iIndex = DllStructGetData($tInfo, "Index") |
---|
50 | |
---|
51 | If $iIndex <> -1 Then _ |
---|
52 | MsgBox(0x40, "Item Text", _GUICtrlListView_GetItemText($hLV, $iIndex)) |
---|
53 | EndSwitch |
---|
54 | EndSwitch |
---|
55 | Return $GUI_RUNDEFMSG |
---|
56 | EndFunc |
---|