ListBox GetSelText Problem

  • Hi ich hab folgendes Problem:

    ich bekomme nicht den Namen des gewählten List-Items heraus. Code:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #Include <File.au3>
    #Include <Array.au3>
    #include <GuiListBox.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $FileList=_FileListToArray("User\")

    [/autoit] [autoit][/autoit] [autoit]

    GuiCreate("Admin Control",200,100,$WS_EX_CLIENTEDGE)
    GuiSetState()

    [/autoit] [autoit][/autoit] [autoit]

    $AddB=GuiCtrlCreateButton("Add",10,10,50,20)
    $DelB=GuiCtrlCreateButton("Del",10,30,50,20)
    $ConfB=GuiCtrlCreateButton("Conf.",10,70,50,20)

    [/autoit] [autoit][/autoit] [autoit]

    $List=GuiCtrlCreateList("",70,10,120,90)

    [/autoit] [autoit][/autoit] [autoit]

    $count = 0
    Do
    $count = $count + 1
    GUICtrlSetData($List,$FileList[$count])
    Until $count = $FileList[0]

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $Msg = GuiGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    If $Msg=$AddB Then
    $Newuser = InputBox("New User","Username:","","",150,50)
    if $Newuser = "" then
    ;nix
    Else
    AddUser()
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $Msg=$DelB Then
    $Deluser = InputBox("Delete User","Username:","","",150,50)
    if $Deluser = "" then
    ;nix
    Else
    DelUser()
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $Msg=$ConfB Then
    msgbox(0,"",_GUICtrlListBox_GetSelItemsText($List))
    msgbox(0,"",_GUICtrlListBox_GetText($List, 1))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Wend

    [/autoit] [autoit][/autoit] [autoit]

    Func AddUser()
    if FileExists("User\"&$Newuser&".ini") then
    MsgBox(64,"Info","Benutzer '"&$Newuser&"' konnte nicht erstellt werden.")
    Else
    FileWrite("User\"&$Newuser&".ini","")
    MsgBox(64,"Info","Benutzer '"&$Newuser&"' wurde erstellt.")
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func DelUser()
    if FileExists("User\"&$Deluser&".ini") then
    FileDelete("User\"&$Deluser&".ini")
    MsgBox(64,"Info","Benutzer '"&$Deluser&"' wurde gelöscht.")
    Else
    MsgBox(64,"Info","Benutzer '"&$Deluser&"' existiert nicht.")
    EndIf
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von I3iLLiG (9. März 2008 um 17:07)

    • Offizieller Beitrag

    Hi,
    mehrere Fehler:

    [autoit]

    If $Msg=$ConfB Then
    msgbox(0,"",_GUICtrlListBox_GetSelItemsText($List))
    msgbox(0,"",_GUICtrlListBox_GetText($List, 1))
    EndIf

    [/autoit]


    - $List enthält die ID, die Funktionen erfordern aber das Handle (steht so auch in der Hilfe!), also:
    GUICtrlGetHandle($List) statt $List einsetzen
    - _GUICtrlListBox_GetSelItemsText() gibt ein Array zurück!!

  • und wie mache ich das jetzt wenn ich nur das anvisierte Item in der List als String ausgeben will?

    learn by showing ...