| 1 | #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
|
|---|
| 2 | #AutoIt3Wrapper_UseX64=n
|
|---|
| 3 | #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
|
|---|
| 4 | #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
|
|---|
| 5 | #include <GuiConstantsEx.au3>
|
|---|
| 6 | #include <GuiListView.au3>
|
|---|
| 7 | #include <GuiImageList.au3>
|
|---|
| 8 | #include <WindowsConstants.au3>
|
|---|
| 9 |
|
|---|
| 10 | Opt('MustDeclareVars', 1)
|
|---|
| 11 |
|
|---|
| 12 | $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
|
|---|
| 13 |
|
|---|
| 14 | Global $hListView
|
|---|
| 15 |
|
|---|
| 16 | _Main()
|
|---|
| 17 |
|
|---|
| 18 | Func _Main()
|
|---|
| 19 | Local $hImage
|
|---|
| 20 |
|
|---|
| 21 | ; Create GUI
|
|---|
| 22 | GUICreate("ListView Click Item", 400, 300)
|
|---|
| 23 | $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
|
|---|
| 24 | _GUICtrlListView_SetUnicodeFormat($hListView, False)
|
|---|
| 25 | GUISetState()
|
|---|
| 26 |
|
|---|
| 27 | GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
|
|---|
| 28 |
|
|---|
| 29 | ; Load images
|
|---|
| 30 | $hImage = _GUIImageList_Create()
|
|---|
| 31 | _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0xFF0000, 16, 16))
|
|---|
| 32 | _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x00FF00, 16, 16))
|
|---|
| 33 | _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x0000FF, 16, 16))
|
|---|
| 34 | _GUICtrlListView_SetImageList($hListView, $hImage, 1)
|
|---|
| 35 |
|
|---|
| 36 | ; Add columns
|
|---|
| 37 | _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
|
|---|
| 38 | _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
|
|---|
| 39 | _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)
|
|---|
| 40 |
|
|---|
| 41 | ; Add items
|
|---|
| 42 | _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
|
|---|
| 43 | _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
|
|---|
| 44 | _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
|
|---|
| 45 |
|
|---|
| 46 | _GUICtrlListView_ClickItem($hListView, 1, "left", False, 2)
|
|---|
| 47 |
|
|---|
| 48 | ; Loop until user exits
|
|---|
| 49 | Do
|
|---|
| 50 | Until GUIGetMsg() = $GUI_EVENT_CLOSE
|
|---|
| 51 | GUIDelete()
|
|---|
| 52 | EndFunc ;==>_Main
|
|---|
| 53 |
|
|---|
| 54 | Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
|
|---|
| 55 | #forceref $hWnd, $iMsg, $iwParam
|
|---|
| 56 | Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
|
|---|
| 57 | $hWndListView = $hListView
|
|---|
| 58 | If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
|
|---|
| 59 |
|
|---|
| 60 | $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
|
|---|
| 61 | $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
|
|---|
| 62 | $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
|
|---|
| 63 | $iCode = DllStructGetData($tNMHDR, "Code")
|
|---|
| 64 | Switch $hWndFrom
|
|---|
| 65 | Case $hWndListView
|
|---|
| 66 | Switch $iCode
|
|---|
| 67 | Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
|
|---|
| 68 | $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
|
|---|
| 69 | _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
|
|---|
| 70 | "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
|
|---|
| 71 | "-->Code:" & @TAB & $iCode & @LF & _
|
|---|
| 72 | "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
|
|---|
| 73 | "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
|
|---|
| 74 | "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
|
|---|
| 75 | "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
|
|---|
| 76 | "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
|
|---|
| 77 | "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
|
|---|
| 78 | "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
|
|---|
| 79 | "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
|
|---|
| 80 | "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
|
|---|
| 81 | ; No return value
|
|---|
| 82 | Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
|
|---|
| 83 | $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
|
|---|
| 84 | _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
|
|---|
| 85 | "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
|
|---|
| 86 | "-->Code:" & @TAB & $iCode & @LF & _
|
|---|
| 87 | "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
|
|---|
| 88 | "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
|
|---|
| 89 | "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
|
|---|
| 90 | "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
|
|---|
| 91 | "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
|
|---|
| 92 | "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
|
|---|
| 93 | "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
|
|---|
| 94 | "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
|
|---|
| 95 | "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
|
|---|
| 96 | ; No return value
|
|---|
| 97 | Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
|
|---|
| 98 | $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
|
|---|
| 99 | _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
|
|---|
| 100 | "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
|
|---|
| 101 | "-->Code:" & @TAB & $iCode & @LF & _
|
|---|
| 102 | "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
|
|---|
| 103 | "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
|
|---|
| 104 | "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
|
|---|
| 105 | "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
|
|---|
| 106 | "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
|
|---|
| 107 | "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
|
|---|
| 108 | "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
|
|---|
| 109 | "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
|
|---|
| 110 | "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
|
|---|
| 111 | ;Return 1 ; not to allow the default processing
|
|---|
| 112 | Return 0 ; allow the default processing
|
|---|
| 113 | Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
|
|---|
| 114 | $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
|
|---|
| 115 | _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
|
|---|
| 116 | "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
|
|---|
| 117 | "-->Code:" & @TAB & $iCode & @LF & _
|
|---|
| 118 | "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
|
|---|
| 119 | "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
|
|---|
| 120 | "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
|
|---|
| 121 | "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
|
|---|
| 122 | "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
|
|---|
| 123 | "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
|
|---|
| 124 | "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
|
|---|
| 125 | "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
|
|---|
| 126 | "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
|
|---|
| 127 | ; No return value
|
|---|
| 128 | EndSwitch
|
|---|
| 129 | EndSwitch
|
|---|
| 130 | Return $GUI_RUNDEFMSG
|
|---|
| 131 | EndFunc ;==>WM_NOTIFY
|
|---|
| 132 |
|
|---|
| 133 | Func _DebugPrint($s_text, $line = @ScriptLineNumber)
|
|---|
| 134 | ConsoleWrite( _
|
|---|
| 135 | "!===========================================================" & @LF & _
|
|---|
| 136 | "+======================================================" & @LF & _
|
|---|
| 137 | "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
|
|---|
| 138 | "+======================================================" & @LF)
|
|---|
| 139 | EndFunc ;==>_DebugPrint
|
|---|