本帖最后由 水木子 于 2011-9-13 11:46 编辑
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate('ListBox test', 400, 300)
$Tab1 = GUICtrlCreateTab(5, 5, 390, 290)
$TabSheet1 = GUICtrlCreateTabItem('TabSheet1')
$hListBox = _GUICtrlListBox_Create($hGUI, '', 15, 35, 370, 250, $LBS_EXTENDEDSEL)
GUICtrlCreateTabItem('')
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)
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
|