#include <GuiListView.au3>
#include <WindowsConstants.au3>
GUICreate('', 400, 300)
$ListView1 = GUICtrlCreateListView('1', 5, 5, 390, 280)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 380)
For $i = 1 To 10
GUICtrlCreateListViewItem('项目 - ' & $i, $ListView1)
Next
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Do
Until GUIGetMsg() = -3
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
$tNMTV = DllStructCreate($tagNMTVDISPINFO, $ilParam)
$iCode = DllStructGetData($tNMTV, "Code")
$iIndex = GUICtrlRead($ListView1)
Switch $iCode
Case $NM_CLICK
If ($iIndex) Then
$ItemText = GUICtrlRead($iIndex)
MsgBox(0, '项目文本:', $ItemText)
EndIf
EndSwitch
$tNMTV = 0
EndFunc ;==>WM_NOTIFY
|