haodd 发表于 2011-3-11 10:45:24

_GUICtrlListBox_Create 例子的疑问

        ;去掉 , $LBS_EXTENDEDSEL 允许多选 不能输出$txt$txt = ;__GUICtrlListBox_GetSelItemsText()
如何不允许多选 又能读取ItemsText
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work
Global $txt
Global $hListBox

_Main()

Func _Main()
        Local $hGUI

        ; Create GUI
        $hGUI = GUICreate("(UDF Created) List Box Create", 400, 296)
        $hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 2, 2, 396, 296, $LBS_EXTENDEDSEL)
        ;去掉 , $LBS_EXTENDEDSEL 允许多选 不能输出$txt$txt = ;__GUICtrlListBox_GetSelItemsText()
        GUISetState()

        MsgBox(4160, "Information", "Adding Items")
       
        GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

        ; Add files
        _GUICtrlListBox_BeginUpdate($hListBox)
        _GUICtrlListBox_ResetContent($hListBox)
        _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
        _GUICtrlListBox_Dir($hListBox, @WindowsDir & "\win*.exe")
        _GUICtrlListBox_AddFile($hListBox, @WindowsDir & "\Notepad.exe")
        _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES)
        _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES, False)
        _GUICtrlListBox_EndUpdate($hListBox)

        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

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_SELCHANGE ; Sent when the selection in a list box has changed
                                        _DebugPrint("$LBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                                                        "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                                                        "-->Code:" & @TAB & $iCode)
                                                       $txt = _GUICtrlListBox_GetSelItemsText($hListBox)
                                                       MsgBox(0,0,$txt)
                                        ; no return value
                        EndSwitch
        EndSwitch
        ; Proceed the default Autoit3 internal message commands.
        ; You also can complete let the line out.
        ; !!! But only 'Return' (without any value) will not proceed
        ; the default Autoit3-message in the future !!!
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

netegg 发表于 2011-3-11 12:45:15

没明白说的什么意思

haodd 发表于 2011-3-12 13:57:49

{:face (229):}
页: [1]
查看完整版本: _GUICtrlListBox_Create 例子的疑问