本帖最后由 maxkingmax 于 2009-11-5 08:48 编辑 #include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <GuiListView.au3>
$FileList = _FileListToArray(@DesktopDir)
if isarray($FileList) then
$Form1 = GUICreate("Form1", 246, 293, -1, -1)
$ListView1 = GUICtrlCreateListView("11111111111111111111111111111", 8, 16, 218, 270, $LVS_SINGLESEL, $LVS_EX_GRIDLINES)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
For $i = 1 To $FileList[0]
GUICtrlCreateListViewItem($FileList[$i], $ListView1)
Next
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
endif
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $Menu
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$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)
Select
Case StringRight($L_Name, 4) = ".lnk"
$exe = FileGetShortcut(@DesktopDir & '\' & $L_Name)
RunWait($exe[0])
Case StringRight($L_Name, 4) = ".exe" Or StringRight($L_Name, 4) = ".com"
$exe = @DesktopDir & '\' & $L_Name
RunWait($exe)
Case Else
ShellExecuteWait(@DesktopDir & '\' & $L_Name)
EndSelect
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
稍微改了下楼上的代码! |