找回密码
 加入
搜索
查看: 2141|回复: 2

[AU3基础] _GUICtrlListBox_Create 例子的疑问

[复制链接]
发表于 2011-3-11 10:45:24 | 显示全部楼层 |阅读模式
        ;去掉 , $LBS_EXTENDEDSEL 允许多选 不能输出$txt[1]  $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[1]  $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[1])
                                        ; 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
发表于 2011-3-11 12:45:15 | 显示全部楼层
没明白说的什么意思
 楼主| 发表于 2011-3-12 13:57:49 | 显示全部楼层
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 14:22 , Processed in 0.078599 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表