AutoIT Bug Listview?

  • Hey ich habe folgenden Code:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUILISTVIEW.au3>
    #Region ### START Koda GUI section ### Form=
    $iExListViewStyle = BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)
    Dim $variable
    $Form1 = GUICreate("Test GUI", 397, 284, 192, 114)
    $hListView = GUICtrlCreateListView("Column 0|Column 1|Column 3", 56, 16, 266, 150)
    _GUICtrlListView_SetExtendedListViewStyle($hListview, $iExListViewStyle)
    _GUICtrlListView_RegisterSortCallBack($hListview)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 70)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 70)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 70)
    $Button1 = GUICtrlCreateButton("Add sample 1", 24, 192, 155, 73, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Add sample 2", 200, 192, 155, 73, $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

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

    Case $hListview ; Sortieren
    _GUICtrlListView_SimpleSort ($hListView, $variable, GUICtrlGetState($hListView))
    _GUICtrlListView_SortItems ($hListview, GUICtrlGetState($hListView))

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

    Case $Button1
    $indexhandle = GUICtrlCreateListViewItem ("Sample1", $hListView)
    GUICtrlSetImage ($indexhandle, "sample1.ico")
    $tmpindex = _GUICtrlListView_GetItemCount($hListview) - 1
    _GUICtrlListView_SetItem ($hListView, "sample1", $tmpindex, 1)
    _GUICtrlListView_SetItem ($hListView, "sample1", $tmpindex, 2)

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

    Case $Button2
    $indexhandle = GUICtrlCreateListViewItem ("Sample2", $hListView)
    GUICtrlSetImage ($indexhandle, "sample2.ico")
    $tmpindex = _GUICtrlListView_GetItemCount($hListview) - 1
    _GUICtrlListView_SetItem ($hListView, "sample2", $tmpindex, 1)
    _GUICtrlListView_SetItem ($hListView, "sample2", $tmpindex, 2)
    EndSwitch
    WEnd

    [/autoit]

    Die Icons könnt ihr beliebig auswählen.
    Nehmt doch bitte einfach mal 2 x beliebige Icons und nennt sie in sample1.ico und ein anderes in sample2.ico um und startet das Script. Sobald ich jetzt die Listview sortieren möchte, bleiben die Icons stehen und bleiben nicht an dem richtigen hängen. Gibt es eine Lösung dafür?
    Danke im Voraus

    Gruß Snify

    Einmal editiert, zuletzt von snify (4. Januar 2010 um 14:47)

  • Hey!

    Wenn ich

    [autoit]

    _GUICtrlListView_SimpleSort ($hListView, $variable, GUICtrlGetState($hListView))

    [/autoit]

    weglasse, funktioniert es bei mir. Aber komisch finde ich das schon.

    lG,

    Lenny

    Jaja, Moo does the Cow!

    • Offizieller Beitrag

    Das Zitat :

    Zitat

    Dies ist eine Grundlagensortierfunktion. Für ein erweitertes Sortieren siehe GUICtrlRegisterListViewSort


    Ist aber falsch, _GUICtrlListView_RegisterSortCallBack ist die Richtige Funktion, wenn man schon die UDF Funktionen benutzt..
    Die snify übrigens schon im Script benutzt.

    @snify, warum führst du überhauüt die Funktionen _GUICtrlListView_SimpleSort und _GUICtrlListView_SortItems hintereinander aus?

  • das simplesort sorgt für das eigentliche sortieren.
    Das normale sortieren sorgt dafür, dass man die Pfeile in den Columns sieht.
    Danke für eure Hilfe.

    Gruß Snify

    EDIT: Es hat vorher nicht funktioniert mit nur _GUICtrlListView_SortItems
    Danke ;)