#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
GUICreate("ListView Column Click", 400, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$hListView = GUICtrlCreateListView("Col1|Col2", 2, 2, 394, 268)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
Sleep(100)
WEnd
Func _Quit()
GUIDelete()
Exit
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
ConsoleWrite("Column Clicked, SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc