#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Local $listview1, $button, $item1, $item2, $item3, $msg
GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF) ; will change background color
$listview1 = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview1)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview1)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview1)
GUICtrlCreateInput("", 20, 200, 150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState()
GUICtrlSetData($item2, "ITEM1")
GUICtrlSetData($item3, "||COL33")
GUICtrlDelete($item1)
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)
_GUICtrlListView_SetExtendedListViewStyle($listview1, $exStyles)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $List
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
;ConsoleWrite("ICODE:"&$iCode&@CR)
Switch $iCode
Case -189
MsgBox(0, '', '你拉勾勾了')
Case $NM_RCLICK
ConsoleWrite("Right click at listview")
;ListView_RClick()
Return 0
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$Index = DllStructGetData($tInfo, "Index")
$subitemNR = DllStructGetData($tInfo, "SubItem")
ConsoleWrite("Double click at item index: " & $Index & @CRLF)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY