problem mit multiselect listboxen

  • hi,
    ich hab ein problem das mich schon seid 2 tagen beschäftigt. ich hab 2 listboxen und möchte die ausgewählten items hin und her schieben
    klingt erst mal leicht aber ich bekomm das einfach nicht hin :pinch: ich hab schon unzählige möglichkeiten probiert ...
    vielleicht findet jemand von euch den fehler:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListBoxConstants.au3>
    #include <GUIListBox.au3>
    #include <WindowsConstants.au3>
    #Include <Array.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 440, 259, 192, 124)
    $List1 = GUICtrlCreateList("", 8, 8, 161, 240,BitOR ($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUICtrlSetData(-1, "test 1|test 2|test 3|test 4|test 5")
    $List2 = GUICtrlCreateList("", 264, 8, 161, 240,BitOR ($LBS_STANDARD, $LBS_EXTENDEDSEL))
    $Button1 = GUICtrlCreateButton("----->", 184, 8, 67, 33, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("<-----", 184, 56, 67, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $x = _GUICtrlListBox_GetSelItems($List1)
    $i = 0
    If IsArray($x) Then
    While $i < $x[0]
    $x = _GUICtrlListBox_GetSelItems($List1)
    $text = _GUICtrlListBox_GetText($List1,$x[1])
    _GUICtrlListBox_AddString($List2,$text)
    _GUICtrlListBox_DeleteString($List1,$x[1])
    $i += 1
    WEnd
    EndIf
    Case $Button2
    $x = _GUICtrlListBox_GetSelItems($List2)
    $i = 0
    If IsArray($x) Then
    While $i < $x[0]
    $x = _GUICtrlListBox_GetSelItems($List2)
    $text = _GUICtrlListBox_GetText($List2,$x[1])
    _GUICtrlListBox_AddString($List1,$text)
    _GUICtrlListBox_DeleteString($List2,$x[1])
    $i += 1
    WEnd
    EndIf
    EndSwitch
    WEnd

    [/autoit]

    Einmal editiert, zuletzt von M☻x (11. Juni 2010 um 14:56)

  • Also bei mir klappt das, dass wenn ich auf die Pfeile drücke, die Items verschoben werden...

    Spoiler anzeigen

    Grundkenntnisse in: C++, JavaScript
    Sehr gute Kenntnisse: PHP, JAVA, C und näturlich AutoIt


    Klaviatur, Anhang UDF, GDI+ Mühle

    Zitat

    "Wenn einen um 20h der Pizzadienst anruft und fragt, ob man's nur vergessen hat und ob man das gleiche
    möchte wie immer -- dann sollte man sein Bestellverhalten evtl überdenken"

  • ok hab den fehler gefunden er hatte die anzahl der markierten items die in der schleife abgefragt werden auf die abbruchbedingung überragen und da die immer kleiner wird hatte er natürlich nicht alle mitgenommen

    wenns jemand intressiert folgendermassen funzt es:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListBoxConstants.au3>
    #include <GUIListBox.au3>
    #include <WindowsConstants.au3>
    #Include <Array.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 440, 259, 192, 124)
    $List1 = GUICtrlCreateList("", 8, 8, 161, 240,BitOR ($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUICtrlSetData(-1, "test 1|test 2|test 3|test 4|test 5")
    $List2 = GUICtrlCreateList("", 264, 8, 161, 240,BitOR ($LBS_STANDARD, $LBS_EXTENDEDSEL))
    $Button1 = GUICtrlCreateButton("----->", 184, 8, 67, 33, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("<-----", 184, 56, 67, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $x = _GUICtrlListBox_GetSelItems($List1)
    $i = 0
    If IsArray($x) Then
    While $i < $x[0]
    $y = _GUICtrlListBox_GetSelItems($List1)
    $text = _GUICtrlListBox_GetText($List1,$y[1])
    _GUICtrlListBox_AddString($List2,$text)
    _GUICtrlListBox_DeleteString($List1,$y[1])
    $i += 1
    WEnd
    EndIf
    Case $Button2
    $x = _GUICtrlListBox_GetSelItems($List2)
    $i = 0
    If IsArray($x) Then
    While $i < $x[0]
    $y = _GUICtrlListBox_GetSelItems($List2)
    $text = _GUICtrlListBox_GetText($List2,$y[1])
    _GUICtrlListBox_AddString($List1,$text)
    _GUICtrlListBox_DeleteString($List2,$y[1])
    $i += 1
    WEnd
    EndIf
    EndSwitch
    WEnd

    [/autoit]