#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Program Files\Autoit3\Aut2Exe\Icons\netscape.ico
#AutoIt3Wrapper_UseAnsi=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListBox.au3>
#Include <GuiListView.au3>
#Include <GuiImageList.au3>
$x = 730
$y = 571
$Form1 = GUICreate("Form1", $x, $y, 193, 125,$WS_OVERLAPPEDWINDOW)
$List1 = GUICtrlCreateListView("", 32, 32, $x-50, $y-40)
$Menu = GUICtrlCreateContextMenu($List1)
$About = GUICtrlCreateMenuItem("执行",$Menu)
$Refresh = GUICtrlCreateMenuItem("刷新",$Menu)
GUICtrlSetStyle($List1,BitOR($LVS_NOCOLUMNHEADER,$LVS_ICON,$LVS_SORTASCENDING,$LVS_SINGLESEL),$LVS_EX_CHECKBOXES)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$Image = _GUIImageList_Create(32,32,5)
For $i = 1 To 50
_GUIImageList_AddIcon($Image,"c:\WINDOWS\system32\shell32.dll",$i,True)
_GUICtrlListView_SetImageList($List1,$Image,0)
_GUICtrlListView_AddItem($List1,"第"&$i&"个",$i-1)
Next
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $About
$Index = _GUICtrlListView_GetSelectedIndices($List1)
If $Index <> "" Then
$L_Name = _GUICtrlListView_GetItemText($List1,Int($Index),0)
MsgBox(0,"鼠标右键",$Index&"你执行的是 "&$L_Name)
EndIf
Case $Refresh
_GUICtrlListView_Arrange($List1,2)
Case $GUI_EVENT_MAXIMIZE
_GUICtrlListView_Arrange($List1,2)
Case $GUI_EVENT_RESTORE
_GUICtrlListView_Arrange($List1,2)
Case $GUI_EVENT_RESIZED
_GUICtrlListView_Arrange($List1,2)
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ,$Menu
$hWndListView = $List1
If Not IsHWnd($List1) Then $hWndListView = GUICtrlGetHandle($List1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK ; 响应 List1 范围内的双击
$Index = _GUICtrlListView_GetSelectedIndices($hWndListView)
If $Index <> "" Then
$L_Name = _GUICtrlListView_GetItemText($hWndListView,$Index)
MsgBox(0,"响应双击","你选择的是 "&$L_Name)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc