回复 3# sky808 #include <GUIListBox.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate("ListBox test", 400, 296)
$hListBox = _GUICtrlListBox_Create($hGUI, "", 2, 2, 396, 296, $LBS_EXTENDEDSEL)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
_GUICtrlListBox_Dir($hListBox, @WindowsDir & "\win*.exe")
_GUICtrlListBox_AddFile($hListBox, @WindowsDir & "\Notepad.exe")
Do
Until GUIGetMsg() = -3
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
If Not IsHWnd($hListBox) Then $hWndListBox = GUICtrlGetHandle($hListBox)
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
$iCode = BitShift($iwParam, 16) ; Hi Word
Switch $hWndFrom
Case $hListBox, $hWndListBox
Switch $iCode
Case $LBN_DBLCLK
$txt = _GUICtrlListBox_GetSelItemsText($hListBox)
If $txt[0] > 0 Then MsgBox(0, '高亮项目', $txt[1])
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
|