#NoTrayIcon
#include <GUIConstants.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Test", 500, 200)
$ListView1 = GUICtrlCreateListView("A|B|C", 5, 5, 480, 175, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_NOLABELWRAP,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
GUICtrlCreateListViewItem('r1c1|r1c2|r1c3', $ListView1)
GUICtrlCreateListViewItem('r2c1|r2c2|r2c3', $ListView1)
GUICtrlCreateListViewItem('r3c1|r3c2|r3c3', $ListView1)
$status1 = GUICtrlCreateLabel("", 0, 183, 500, 17, $WS_GROUP, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $wParam
Local $NMHDR, $NMLVDISPINFO, $NMLISTVIEW, $event
$NMHDR = DllStructCreate($tagNMHDR, $lParam)
$event = DllStructGetData($NMHDR, 'Code')
If $hWndGUI = $Form1 And $wParam = $ListView1 Then
Select
Case $LVN_ITEMCHANGED
$NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
If BitAND(DllStructGetData($NMLISTVIEW, "Changed"), $LVIF_STATE) = $LVIF_STATE And _
DllStructGetData($NMLISTVIEW, "NewState") <> DllStructGetData($NMLISTVIEW, "OldState") Then OnStateChange()
EndSelect
EndIf
Return $GUI_RUNDEFMSG
EndFunc
Func OnStateChange()
$cur_sel = _GUICtrlListView_GetNextItem($ListView1) ; current selected
$count_sel = _GUICtrlListView_GetSelectedCount($ListView1)
$count = _GUICtrlListView_GetItemCount($ListView1)
GUICtrlSetData($status1, 'Current selected: ' & $cur_sel & ' Total selected: ' & $count_sel & ' Total items: ' & $count)
EndFunc
|