ListView - SubItem einzeln färben/formatieren, Finale Version! (v1.3)

  • Hey Leute,
    ich habe ein Problem beim erstellen von items.

    hier mein code:

    Spoiler anzeigen
    [autoit]


    #include <GuiListView.au3>
    #include <EditConstants.au3>
    #include 'LV_Format_include.au3'
    #include <GuiButton.au3>

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

    Global $hLV,$GUI

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

    $GUI = GUICreate('')
    $lv = GUICtrlCreateListView("Test1|Test2", 10, 10, 300, 150)
    $btn_hinzu = _GUICtrlButton_Create($GUI, "hinzufügen", 10, 200, 90, 50)
    $btn_loesch = _GUICtrlButton_Create($GUI, "lösche", 10, 250, 90, 50)

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

    $hLV = GUICtrlGetHandle($lv)

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

    $GUI_Format =GUICreate("Hinzüfgen", 239, 196, 331, 468)
    $Label1 = GUICtrlCreateLabel("1. Busfahrt", 8, 40, 55, 17)
    $Label5 = GUICtrlCreateLabel("Telekom", 8, 72, 45, 17)
    $Label9 = GUICtrlCreateLabel("2. Busfahrt", 8, 104, 55, 17)
    $chb_urlaub = GUICtrlCreateCheckbox("Urlaub", 8, 160, 65, 25)
    $Label2 = GUICtrlCreateLabel("Datum", 8, 136, 35, 17)
    $Start = GUICtrlCreateLabel("Start Zeit:", 80, 8, 50, 17)
    $Label3 = GUICtrlCreateLabel("End Zeit", 152, 8, 44, 17)
    $txt_bus1_start = GUICtrlCreateInput("06:00", 72, 32, 65, 21)
    $txt_bus1_ende = GUICtrlCreateInput("06:30", 152, 32, 65, 21)
    $txt_telekom_start = GUICtrlCreateInput("09:00", 72, 64, 65, 21)
    $txt_telekm_ende = GUICtrlCreateInput("16:00", 152, 64, 65, 21)
    $txt_bus2_start = GUICtrlCreateInput("17:00", 72, 96, 65, 21)
    $txt_bus2_ende = GUICtrlCreateInput("20:00", 152, 96, 65, 21)
    $txt_datum = GUICtrlCreateInput("1.1.2012", 72, 128, 145, 21)
    $bt_hinzufoegen_ = GUICtrlCreateButton("Hinzufügen", 72, 160, 145, 25)

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

    ;das hier geht
    _GUICtrlListView_Formatting_Startup($GUI, $hLV)
    _GUICtrlListView_AddOrIns_Item($hLV, 'Test0|Test1')
    _GUICtrlListView_FormattingCell($hLV, 0, 0, 0xff0000, -1, -1, 600, 'Times New Roman')
    ;das hier geht

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

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState(@SW_SHOW, $GUI)

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

    While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
    Case $GUI
    If $msg[0] = -3 Then ExitLoop
    Case $GUI_Format
    If $msg[0] = -3 Then
    GUISetState(@SW_HIDE, $GUI_Format)
    ;_setFormat()
    EndIf
    EndSwitch
    WEnd

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

    func _bt_click_hinzufuegen()
    GUISetState(@SW_SHOW, $GUI_Format)
    EndFunc

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

    func _test()
    _GUICtrlListView_Formatting_Startup($GUI, $hLV)
    _GUICtrlListView_AddOrIns_Item($hLV, 'Test0|Test1')
    _GUICtrlListView_FormattingCell($hLV, 0, 0, 0xff0000, -1, -1, 600, 'Times New Roman')
    EndFunc

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

    ; Reaktion auf einen Button-Klick
    Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""
    ;if $lParam =
    Switch $hCtrl
    Case $btn_hinzu
    Switch $nNotifyCode
    Case $BN_CLICKED
    _bt_click_hinzufuegen()
    EndSwitch
    Case $btn_loesch
    Switch $nNotifyCode
    Case $BN_CLICKED
    msgbox(64,"test","Test")
    EndSwitch
    Case GUICtrlGetHandle($bt_hinzufoegen_)
    Switch $nNotifyCode
    Case $BN_CLICKED
    msgbox(64,"test","Test")
    _test()
    EndSwitch

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

    Return 0 ; Nur bei Klick auf den Button
    EndSwitch
    ; Setzt die Standardverarbeitung der Autoit3-internen Nachrichtenkommandos fort.
    ; Man kann die Zeile auch weglassen.
    ; !!! Aber nur 'Return' (ohne jegliche Variable) wird die Verarbeitung der Standardnachrichten unterbinden !!!
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

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

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    ; If ($hWndFrom = $hLV Or $hWndFrom = $hLV2) And $iCode = $NM_RCLICK Then _RightClick()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]

    Ich kann z .b beim aufruf der Function _test() keine items erstellen.
    Wie muss ich den Code schreiben, damit ich aus jeder beliebigen Funktion items erstellen und die Farben ändern kann?
    zusätzlich will ich ab einem bestimmtem Wert (Subitem) die Farbe ändern.

  • also hab es mal geändert:

    Spoiler anzeigen
    [autoit]


    #include <GuiListView.au3>
    #include <EditConstants.au3>
    #include 'LV_Format_include.au3'
    #include <GuiButton.au3>

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

    Global $hLV,$GUI

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

    $GUI = GUICreate('')
    $lv = GUICtrlCreateListView("Test1|Test2", 10, 10, 300, 150)
    $btn_hinzu = _GUICtrlButton_Create($GUI, "hinzufügen", 10, 200, 90, 50)
    $btn_loesch = _GUICtrlButton_Create($GUI, "lösche", 10, 250, 90, 50)

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

    $hLV = GUICtrlGetHandle($lv)

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

    $GUI_Format =GUICreate("Hinzüfgen", 239, 196, 331, 468)
    $Label1 = GUICtrlCreateLabel("1. Busfahrt", 8, 40, 55, 17)
    $Label5 = GUICtrlCreateLabel("Telekom", 8, 72, 45, 17)
    $Label9 = GUICtrlCreateLabel("2. Busfahrt", 8, 104, 55, 17)
    $chb_urlaub = GUICtrlCreateCheckbox("Urlaub", 8, 160, 65, 25)
    $Label2 = GUICtrlCreateLabel("Datum", 8, 136, 35, 17)
    $Start = GUICtrlCreateLabel("Start Zeit:", 80, 8, 50, 17)
    $Label3 = GUICtrlCreateLabel("End Zeit", 152, 8, 44, 17)
    $txt_bus1_start = GUICtrlCreateInput("06:00", 72, 32, 65, 21)
    $txt_bus1_ende = GUICtrlCreateInput("06:30", 152, 32, 65, 21)
    $txt_telekom_start = GUICtrlCreateInput("09:00", 72, 64, 65, 21)
    $txt_telekm_ende = GUICtrlCreateInput("16:00", 152, 64, 65, 21)
    $txt_bus2_start = GUICtrlCreateInput("17:00", 72, 96, 65, 21)
    $txt_bus2_ende = GUICtrlCreateInput("20:00", 152, 96, 65, 21)
    $txt_datum = GUICtrlCreateInput("1.1.2012", 72, 128, 145, 21)
    $bt_hinzufoegen_ = GUICtrlCreateButton("Hinzufügen", 72, 160, 145, 25)

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

    ;das hier geht
    _GUICtrlListView_Formatting_Startup($GUI, $hLV)
    _GUICtrlListView_AddOrIns_Item($hLV, 'Test0|Test1'); funktioniert
    _GUICtrlListView_FormattingCell($hLV, 0, 0, 0xff0000, -1, -1, 600, 'Times New Roman'); funktioniert
    ;das hier geht

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

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState(@SW_SHOW, $GUI)

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

    While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
    Case $GUI
    If $msg[0] = -3 Then ExitLoop
    Case $GUI_Format
    If $msg[0] = -3 Then
    GUISetState(@SW_HIDE, $GUI_Format)
    ;_setFormat()
    EndIf
    EndSwitch
    WEnd

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

    func _bt_click_hinzufuegen()
    GUISetState(@SW_SHOW, $GUI_Format)
    EndFunc

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

    func _test()
    ;_GUICtrlListView_Formatting_Startup($GUI, $hLV)
    _GUICtrlListView_AddOrIns_Item($hLV, 'Test0|Test1') ; ab hier hängt das programm und wird beendet
    _GUICtrlListView_FormattingCell($hLV, 0, 0, 0xff0000, -1, -1, 600, 'Times New Roman')
    EndFunc

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

    ; Reaktion auf einen Button-Klick
    Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""
    ;if $lParam =
    Switch $hCtrl
    Case $btn_hinzu
    Switch $nNotifyCode
    Case $BN_CLICKED
    _bt_click_hinzufuegen()
    EndSwitch
    Case $btn_loesch
    Switch $nNotifyCode
    Case $BN_CLICKED
    msgbox(64,"test","Test")
    EndSwitch
    Case GUICtrlGetHandle($bt_hinzufoegen_)
    Switch $nNotifyCode
    Case $BN_CLICKED
    msgbox(64,"test","Test")
    _test()
    EndSwitch

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

    Return 0 ; Nur bei Klick auf den Button
    EndSwitch
    ; Setzt die Standardverarbeitung der Autoit3-internen Nachrichtenkommandos fort.
    ; Man kann die Zeile auch weglassen.
    ; !!! Aber nur 'Return' (ohne jegliche Variable) wird die Verarbeitung der Standardnachrichten unterbinden !!!
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

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

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    ; If ($hWndFrom = $hLV Or $hWndFrom = $hLV2) And $iCode = $NM_RCLICK Then _RightClick()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]

    Wenn ich die funktion _test() über WM_COMMAND($hWnd, $Msg, $wParam, $lParam) aufrufe, geht es nicht. Das Programm reagiert nicht mehr.
    Ich denke beim der Funktion WM_COMMAND($hWnd, $Msg, $wParam, $lParam) liegt das Problem.
    Leider versteh ich das nicht. Kannst du mir das erklären?
    das ich von zwei gui's die verschiedenen buttons klicken kann und dann item's und farbe ändern kann.

  • ich wollte eigentlich damit bezwecken, das die Buttons immer reagieren!

    Ich habe jetzt mal das wm_command zeug weggemacht. wenn ich jetzt auf den Button drück der die Funktion _test() hängt das Programm und wird beendet.
    wo liegt jetzt mein fehler?

    Spoiler anzeigen
    [autoit]


    #include <GuiListView.au3>
    #include <EditConstants.au3>
    #include 'LV_Format_include.au3'
    #include <GuiButton.au3>

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

    Global $hLV,$GUI

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

    $GUI = GUICreate('')
    $lv = GUICtrlCreateListView("Test1|Test2", 10, 10, 300, 150)
    $btn_hinzu = GUICtrlCreateButton( "hinzufügen", 10, 200, 90, 50)
    $btn_loesch = GUICtrlCreateButton( "lösche", 10, 250, 90, 50)

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

    $hLV = GUICtrlGetHandle($lv)

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

    $GUI_Format = GUICreate("Hinzüfgen", 239, 196, 331, 468)
    $Label1 = GUICtrlCreateLabel("1. Busfahrt", 8, 40, 55, 17)
    $Label5 = GUICtrlCreateLabel("Telekom", 8, 72, 45, 17)
    $Label9 = GUICtrlCreateLabel("2. Busfahrt", 8, 104, 55, 17)
    $chb_urlaub = GUICtrlCreateCheckbox("Urlaub", 8, 160, 65, 25)
    $Label2 = GUICtrlCreateLabel("Datum", 8, 136, 35, 17)
    $Start = GUICtrlCreateLabel("Start Zeit:", 80, 8, 50, 17)
    $Label3 = GUICtrlCreateLabel("End Zeit", 152, 8, 44, 17)
    $txt_bus1_start = GUICtrlCreateInput("06:00", 72, 32, 65, 21)
    $txt_bus1_ende = GUICtrlCreateInput("06:30", 152, 32, 65, 21)
    $txt_telekom_start = GUICtrlCreateInput("09:00", 72, 64, 65, 21)
    $txt_telekm_ende = GUICtrlCreateInput("16:00", 152, 64, 65, 21)
    $txt_bus2_start = GUICtrlCreateInput("17:00", 72, 96, 65, 21)
    $txt_bus2_ende = GUICtrlCreateInput("20:00", 152, 96, 65, 21)
    $txt_datum = GUICtrlCreateInput("1.1.2012", 72, 128, 145, 21)
    $bt_hinzufoegen_ = GUICtrlCreateButton("Hinzufügen", 72, 160, 145, 25)

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

    _GUICtrlListView_Formatting_Startup($GUI, $hLV)
    _GUICtrlListView_AddOrIns_Item($hLV, 'Test0|Test1'); funktioniert
    _GUICtrlListView_FormattingCell($hLV, 0, 0, 0xff0000, -1, -1, 600, 'Times New Roman'); funktioniert

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

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState(@SW_SHOW, $GUI)

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    Switch $nMsg[1]
    Case $GUI ; User will das Hauptfenster schließen
    If MsgBox(32 + 4, "Beenden", "Wollen sie das Programm wirklich beenden?") = 6 Then Exit; wenn ja, dann End-Funktion aufrufen
    Case $GUI_Format ; User will das "Neuer Eintrag"-Fenster schließen
    GUISetState(@SW_HIDE,$GUI_Format)
    EndSwitch
    Case $btn_hinzu
    _bt_click_hinzufuegen()
    Case $bt_hinzufoegen_
    _test()

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

    EndSwitch
    WEnd

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

    func _bt_click_hinzufuegen()
    GUISetState(@SW_SHOW, $GUI_Format)
    EndFunc

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

    func _test()
    _GUICtrlListView_AddOrIns_Item($hLV, 'Test0|Test1') ; ab hier hängt das programm und wird beendet
    _GUICtrlListView_FormattingCell($hLV, 1, 1, 0xff0000, -1, -1, 600, 'Times New Roman')
    EndFunc

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

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    ; If ($hWndFrom = $hLV Or $hWndFrom = $hLV2) And $iCode = $NM_RCLICK Then _RightClick()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]

    ich bin langsam echt am verzweifel das musst doch mal endlich klappen

  • Hi,

    mein Script hängt sich auf, wenn ich erst viele ListView-Einträge erstelle, dann alle entferne und dann wieder neue erstelle ( alles mit deinen Funktionen ).
    Beim neuerstellen ist dann Ende, keine Ahnung wieso.

    MfG

    • Offizieller Beitrag

    mein Script hängt sich auf, wenn ich erst viele ListView-Einträge erstelle, dann alle entferne und dann wieder neue erstelle ( alles mit deinen Funktionen ).


    Bei meinen Tests hatte ich mit 2.000 Einträgen in 8 Spalten probiert. Ausser dass das etwas dauert ;) gab es keine Probleme.

  • ich habe ein problem...bei mir kommt immer folgende fehlermeldung

    Z:\BackUps\AutoIt - Scripts\##Fertig\Fremde Scripts\Listview\LV_Format_include[1.3].au3 (257) : ==> The requested action with this object has failed.:
    Local $index = $FORMATLV_oPARAM_SEARCH.Item($iParam)
    Local $index = $FORMATLV_oPARAM_SEARCH.Item($iParam)^ ERROR

    liegt das daran das ich win 7 64 bit verwende oder ist das einfach ein fehler im script?

  • Moin, Moin...
    Zuerst einmal dickes Lob für diese tolle UDF. Hut ab, BugFix!! :thumbup:

    Nun habe ich das ganze in eines meiner Scripte eingefügt und hab dort folgendes Phänomen feststellen können: Bei der Verwendung der Funktionen "_GUICtrlListView_AddOrIns_Item" oder "_GUICtrlListView_FormattingCell" solange die GUI Sichtbar ist ( GUISetState(@SW_SHOW, $GUI) )führt dies zum Absturz des Skriptes. Solange die GUI während dieser Operationen nicht sichtbar ist, läuft das Skript weiter.
    Ich möchte zur Auswertung der Ergebnisse einer anderen UDF eine ListView verwenden. Je nach Ergebnis soll in der ListView der Dateipfad und das Ergebnis dargestellt werden. Bei Fehlern ist das Ergebnis entsprechend einzufärben. Vermutlich hapert es bei mir einfach nur am Verständnis, für Ratschläge wäre ich dankbar. Abgesehen von der Position von GUISetState, habe ich mich an dem Beispiel "Example_LV_Format.au3" orientiert.
    Hier ein wenig Code:

    Meine GUI

    [autoit]



    #region ### START Koda GUI Ssection ###
    $idForm1 = GUICreate("BatchDragon", 435, 320, 391, 325)

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

    GUISetBkColor(0xD4D0C7)
    GUISetIcon($idIcon, -1)
    $Group1 = GUICtrlCreateGroup("", 180, 14, 218, 100, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT), $WS_EX_TRANSPARENT)
    $idButton_Abort = GUICtrlCreateButton("Abort", 300, 38, 65, 25)
    GUICtrlSetFont($idButton_Abort, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetTip($idButton_Abort,"Abort batch processing")
    $idButton_Start = GUICtrlCreateButton("Start", 300, 72, 65, 25)
    GUICtrlSetTip($idButton_Start,"Start batch processing")
    $idButton_Folder = GUICtrlCreateButton("SF", 206, 47, 40, 40, $BS_ICON)
    GUICtrlSetTip($idButton_Folder,"Select files to convert")
    GUICtrlSetImage($idButton_Folder, ".\graphics\icon_folder1.ico", -1, 0)
    $idCheckbox_WaitForErrors = GUICtrlCreateCheckbox("Wait for errors", 16, 8, 89, 17, BitOR($BS_AUTOCHECKBOX,$BS_CENTER))
    GUICtrlSetState($idCheckbox_WaitForErrors, $GUI_CHECKED)
    $idEdit_CurrentFolder = GUICtrlCreateEdit("", 18, 122, 402, 20, BitOR($ES_NOHIDESEL, $WS_CLIPSIBLINGS))
    GUICtrlSetData(-1, "...")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $idProgBar = GUICtrlCreateProgress(36, 274, 362, 17, $PBS_SMOOTH)
    $idStatBar = _GUICtrlStatusBar_Create($idForm1)
    $idStatPic = GUICtrlCreatePic(".\graphics\logo-Nuance_disabled.jpg", 36, 33, 100, 72)

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

    ;CreateListView
    $idListView = GUICtrlCreateListView("File|Status", 18, 146, 402, 125,$GUI_SS_DEFAULT_LISTVIEW,BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT))
    Global $hListView = GUICtrlGetHandle($idListView)
    _GUICtrlListView_SetColumnWidth($hListView, 0, 315)
    _GUICtrlListView_SetColumnWidth($hListView, 1, 66)
    _GUICtrlListView_Formatting_startup($idForm1,$hListView)
    _GUICtrlStatusBar_SetSimple($idStatBar)
    _GUICtrlStatusBar_SetText($idStatBar, "hello")

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

    GUISetState( @SW_SHOW, $idForm1 )
    @Sw_
    #endregion ### END Koda GUI section ###

    [/autoit]


    Hier stürtzt es ab...(Auszug)

    [autoit]


    While 1
    ;Call CheckNDProcess()
    Local $idSplash, $iI
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idButton_Start

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

    ;BlockInput(1)
    GUICtrlSetState($idButton_Start, $GUI_Disable)
    GUICtrlSetState($idButton_Abort, $GUI_Enable)
    GUICtrlSetState($idButton_Folder, $GUI_Disable)

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

    ;get Files

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

    local $aArray = _RecFileListTOArray($sSelectedFolder, "*.wav", 1, 0, 0, 2);WAV, FilesOnly,NoRecursion,FullPath

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

    Select
    Case @extended = 9
    MsgBox(0, "Error", "No WAV files found!")
    GUICtrlSetState($idButton_Abort, $GUI_Disable)
    GUICtrlSetState($idButton_Folder, $GUI_Enable)
    Case @extended = 1
    MsgBox(0, "Error", "Path not found or invalid")
    Case @extended = 0

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

    ; Hier soll die Auswertungs-UDF aufgerufen und das Ergebnis (je eine Zeile) in die ListView eingetragen werden!!

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

    Case Else
    MsgBox(0, "Error", "Unknown error!")
    EndSelect

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

    SplashOff()
    ; BlockInput(0)
    ;SpeechToText()
    GUICtrlSetState($idButton_Abort, $GUI_Disable)
    GUICtrlSetState($idButton_Folder, $GUI_Enable)

    [/autoit]



    Vielen Dank!!
    [size=10]Jan

  • Hallo,

    bei mir funktioniert es nicht. Die Zelle wird nicht rot eingefärbt. Was mache ich falsch?

    [autoit]

    #include "LV_Format.au3"

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

    $gui = GUICreate("" , 1320, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX))

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

    $listview = GUICtrlCreateListView("Spalte1", 0, 70, 1320, 780, $LVS_NOSORTHEADER)
    GUISetState()

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

    _GUICtrlListView_Formatting_Startup($gui, $listview)

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

    _GUICtrlListView_AddOrIns_Item($listview, "Zeile1")

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

    _GUICtrlListView_FormattingCell($listview, 0, 0, 0xff0000)

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

    While True
    WEnd

    [/autoit]


    Getestet mit dieser LV_Format.au3

    Spoiler anzeigen
    [autoit]

    #Region - TimeStamp
    ; 2011-08-08 14:48:18 v 1.3
    #EndRegion - TimeStamp

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

    #cs
    Initialize Global vars at startup
    _GUICtrlListView_Formatting_Startup($hGUI, $hListView)
    $hGUI Handle of your GUI
    $hListView Listview handle, for several LV commit handle's as array

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

    [ Clean up ressources ==> Changed! ==> now automatically called on AutoIt exit ]
    _GUICtrlListView_Formatting_Shutdown()

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

    Add or insert new Listview Item:
    _GUICtrlListView_AddOrIns_Item($hWnd, $sText, $iItem=-1)
    $hWnd Listview handle
    $vText String with:
    lonely string to set only Item text (than SubItem must set with _GUICtrlListView_AddSubItem)
    or
    "Item|SubItem|SubItem.." to set all text at once
    or..
    an Array with this strings to set more than one Item at once
    $iItem Item index, if -1 a new Item will add at the end (default)
    otherwise
    the Item will insert at index position

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

    Delete one, selected or all Item:
    _GUICtrlListView_FormattedDeleteItem($hWnd, $iIndex)
    _GUICtrlListView_FormattedDeleteItemsSelected($hWnd)
    _GUICtrlListView_FormattedDeleteAllItems($hWnd)

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

    Set defaults
    _GUICtrlListView_DefaultsSet($iBkCol=0xFFFFFF, $iCol=0x000000, $iSize=14, $iWeight=400, $sFont='Arial')
    $iBkCol back color default white
    $iCol text color default black
    $iSize font size default 14
    $iWeight font weight default 400
    $sFont font name default Arial

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

    Get defaults
    _GUICtrlListView_DefaultsGet()
    Return: [$iBkCol, $iCol, $iSize, $iWeight, $sFont]

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

    Format Listview Item
    _GUICtrlListView_FormattingCell($hWnd, $iItem, $iSubItem, $iBkCol=-1, $iCol=-1, $iSize=-1, $iWeight=-1, $sFont=-1)
    $hWnd Listview handle
    $iItem Item index
    $iSubItem SubItem index
    $iBkCol back color (-1 = default BkCol)
    $iCol text color (-1 = default txtCol)
    $iSize height of font (-1 = 14)
    $iWeight font weight (-1 = 400)
    $sFont typefont name (-1 = Arial)

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

    Sort Listview:
    By default SimpleSort doesn't really sort Items - only Item-/SubItem text moves. Because that, IParam stands at same
    position like before. I've modified this function, so that IParam also will sorted.
    __GUICtrlListView_SimpleSort($hWnd, ByRef $vDescending, $iCol)

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

    Call from WM_NOTIFY_LV_FORMAT
    __getMarked($hWnd, $iItem, $iSubItem) ==> check if SubItem is formatted
    __DrawItemCol(ByRef $hDC, ByRef $tCustDraw, $hWnd, $iItem, $iSubitem) ==> draw formatted SubItem
    __DrawDefault(ByRef $hDC, ByRef $tCustDraw) ==> draw unformatted SubItem
    for simple sort:
    __GUICtrlListView_SimpleSort($hWnd, ByRef $vDescending, $iCol)

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

    #ce

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

    #include-once
    #include <Array.au3>
    #include <FontConstants.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <Constants.au3>
    #include <WindowsConstants.au3>
    #include <StructureConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>

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

    OnAutoItExitRegister("_GUICtrlListView_Formatting_Shutdown")

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

    Global Const $SHIFT_PARAMVALUE = 9000 ; == if you have higher Ctrl-ID in your script - increase this value
    Global $FORMATLV_hPROC, $FORMATLV_hHOOK, $FORMATLV_hGUI
    Global $FORMATLV_aITEM_INDEX
    ; == $FORMATLV_aITEM_INDEX
    ; == use in your script this Global array variable with information about right clicked Item [state clicked:TrueFalse, $hWndFrom, "Index", "SubItem", $iBkCol, $iCol, $iSize, $iWeight, $sFont]
    ; == use GuiRegisterMessage($WM_NOTIFY, 'Function') to react
    ; == how to use, see Func _RightClick() inside "Example_LV_Format.au3"

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

    Global $FORMATLV_DEF_BKCOL = 0xFFFFFF
    Global $FORMATLV_DEF_COL = 0x000000
    Global $FORMATLV_DEF_SIZE = 14
    Global $FORMATLV_DEF_WEIGHT = 400
    Global $FORMATLV_DEF_FONT = 'Arial'
    Global $FORMATLV_LAST_FONT_SIZE = $FORMATLV_DEF_SIZE
    Global $FORMATLV_LAST_FONT_WEIGHT = $FORMATLV_DEF_WEIGHT
    Global $FORMATLV_LAST_FONT_TYPE = $FORMATLV_DEF_FONT
    Global $FORMATLV_LAST_COL = $FORMATLV_DEF_COL
    Global $FORMATLV_LAST_BKCOL = $FORMATLV_DEF_BKCOL
    Global $FORMATLV_LAST_DEF = False
    Global $FORMATLV_aHWND, $FORMATLV_CURR_WINDOW, $FORMATLV_MAX_COLUMN, $FORMATLV_aIPARAM[1][1][5]
    Global $FORMATLV_oPARAM_SEARCH, $FORMATLV_hFONT, $FORMATLV_B_DESCENDING

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

    Func _GUICtrlListView_Formatting_Startup($hGUI, $hListView)
    $FORMATLV_hGUI = $hGUI
    ; initialize Callback Function to analyze $WM_NOTIFY
    $FORMATLV_hPROC = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
    $FORMATLV_hHOOK = _WinAPI_SetWindowLong($FORMATLV_hGUI, $GWL_WNDPROC, DllCallbackGetPtr($FORMATLV_hPROC))
    Local $count
    If IsArray($hListView) Then
    $FORMATLV_MAX_COLUMN = _GUICtrlListView_GetColumnCount($hListView[0])
    For $i = 0 To UBound($hListView) -1
    If Not IsHWnd($hListView[$i]) Then
    $hListView[$i] = GUICtrlGetHandle($hListView[$i])
    EndIf
    $count = _GUICtrlListView_GetColumnCount($hListView[$i])
    If $count > $FORMATLV_MAX_COLUMN Then
    $FORMATLV_MAX_COLUMN = $count
    EndIf
    Next
    $FORMATLV_aHWND = $hListView
    Else
    If Not IsHWnd($hListView) Then
    $hListView = GUICtrlGetHandle($hListView)
    EndIf
    $FORMATLV_MAX_COLUMN = _GUICtrlListView_GetColumnCount($hListView)
    Local $aTmp[1] = [$hListView]
    $FORMATLV_aHWND = $aTmp
    EndIf
    ReDim $FORMATLV_aIPARAM[1][$FORMATLV_MAX_COLUMN+1][5] ; [n][0][0]=ItemStruct, [n][1..Count][0..4]=SubItemValue
    $FORMATLV_oPARAM_SEARCH = ObjCreate('Scripting.Dictionary')
    $FORMATLV_CURR_WINDOW = $FORMATLV_hGUI
    If Not IsHWnd($FORMATLV_CURR_WINDOW) Then $FORMATLV_CURR_WINDOW = WinGetHandle($FORMATLV_CURR_WINDOW)
    EndFunc ;==>_GUICtrlListView_Formatting_Startup

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

    Func _GUICtrlListView_Formatting_Shutdown()
    $FORMATLV_aIPARAM = 0
    $FORMATLV_oPARAM_SEARCH = 0
    _WinAPI_SetWindowLong($FORMATLV_hGUI, $GWL_WNDPROC, $FORMATLV_hHOOK) ; to reconstruct original WinProcedure
    EndFunc ;==>_GUICtrlListView_Formatting_Shutdown

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

    Func _GUICtrlListView_DefaultsSet($iBkCol=0xFFFFFF, $iCol=0x000000, $iSize=14, $iWeight=400, $sFont='Arial')
    $FORMATLV_DEF_BKCOL = $iBkCol
    $FORMATLV_DEF_COL = $iCol
    $FORMATLV_DEF_SIZE = $iSize
    $FORMATLV_DEF_WEIGHT = $iWeight
    $FORMATLV_DEF_FONT = $sFont
    _WinAPI_RedrawWindow($FORMATLV_CURR_WINDOW)
    EndFunc ;==>_GUICtrlListView_DefaultsSet

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

    Func _GUICtrlListView_DefaultsGet()
    Local $aRet[5] = [ _
    $FORMATLV_DEF_BKCOL, _
    $FORMATLV_DEF_COL, _
    $FORMATLV_DEF_SIZE, _
    $FORMATLV_DEF_WEIGHT, _
    $FORMATLV_DEF_FONT]
    Return $aRet
    EndFunc ;==>_GUICtrlListView_DefaultsGet

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

    Func _GUICtrlListView_AddOrIns_Item($hWnd, $vText, $iItem=-1)
    Local $tagITEMPARAM = "int_ptr;byte[" & $FORMATLV_MAX_COLUMN & "];", $tITEMPARAM, $aItem = $vText, $aItemTxt, $1stItemFilled = 0
    Local $lastIndex, $bAdd = False, $ub_aItem, $ub_aIPARAM, $DataSep = Opt('GUIDataSeparatorChar')
    If Not IsHWnd($hWnd) Then
    $hWnd = GUICtrlGetHandle($hWnd)
    EndIf
    Local $itemCount = _GUICtrlListView_GetItemCount($hWnd)
    ; == if not is array $vText ==> create array
    If Not IsArray($aItem) Then
    Local $aTmp[1] = [$aItem]
    $aItem = $aTmp
    EndIf
    $ub_aItem = UBound($aItem)
    ; == check insert position ($iItem)
    Select
    Case ( $iItem < 0 ) Or ( $iItem >= $itemCount ); append at the end
    $iItem = -1
    $bAdd = True
    Case $iItem < $itemCount
    $bAdd = False
    EndSelect
    ; == one item or array of item - append/insert
    ; == increase array if necessary
    $ub_aIPARAM = UBound($FORMATLV_aIPARAM)
    $lastIndex = $ub_aIPARAM -1
    $1stItemFilled = IsDllStruct($FORMATLV_aIPARAM[0][0][0])
    If $1stItemFilled = 1 Then ; == 1st entry not empty
    ReDim $FORMATLV_aIPARAM[$ub_aIPARAM +$ub_aItem][$FORMATLV_MAX_COLUMN+1][5]
    $lastIndex += 1
    Else ; == 1st entry is empty
    If $ub_aItem > 1 Then
    ReDim $FORMATLV_aIPARAM[$ub_aIPARAM +$ub_aItem -1][$FORMATLV_MAX_COLUMN+1][5]
    EndIf
    EndIf
    For $i = 0 To $ub_aItem -1
    $1stItemFilled = IsDllStruct($FORMATLV_aIPARAM[0][0][0])
    ; == create structure, fill with zeros, store to array
    ; == storage index from array stored about integer pointer in an dictionary object: key=IntegerPointer, val=ArrayIndex
    $tITEMPARAM = DllStructCreate($tagITEMPARAM)
    DllStructSetData($tITEMPARAM, 1, DllStructGetPtr($tITEMPARAM, 2))
    For $j = 1 To $FORMATLV_MAX_COLUMN
    DllStructSetData($tITEMPARAM, 2, 0, $j)
    Next
    If $1stItemFilled = 0 Then
    $FORMATLV_aIPARAM[0][0][0] = $tITEMPARAM
    $FORMATLV_oPARAM_SEARCH.Add(String(DllStructGetData($tITEMPARAM, 1)), 0)
    Else
    $FORMATLV_aIPARAM[$lastIndex +$i][0][0] = $tITEMPARAM
    $FORMATLV_oPARAM_SEARCH.Add(String(DllStructGetData($tITEMPARAM, 1)), $lastIndex +$i)
    EndIf
    ; == create listview -Item, -SubItem, store IntegerPointer as ItemParam
    $aItemTxt = StringSplit($aItem[$i], $DataSep, 1)
    If $bAdd Then
    $iItem = _GUICtrlListView_AddItem($hWnd, $aItemTxt[1])
    Else
    _GUICtrlListView_InsertItem($hWnd, $aItemTxt[1], $iItem)
    EndIf
    _GUICtrlListView_SetItemParam($hWnd, $iItem, DllStructGetData($tITEMPARAM, 1) +$SHIFT_PARAMVALUE)
    If $aItemTxt[0] > 1 Then
    For $j = 2 To UBound($aItemTxt) -1
    _GUICtrlListView_AddSubItem($hWnd, $iItem, $aItemTxt[$j], $j-1)
    Next
    EndIf
    Next
    EndFunc ;==>_GUICtrlListView_AddOrIns_Item

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

    Func _GUICtrlListView_FormattedDeleteItem($hWnd, $iIndex)
    Local $iParam = _GUICtrlListView_GetItemParam($hWnd, $iIndex) -$SHIFT_PARAMVALUE
    $FORMATLV_aIPARAM[$FORMATLV_oPARAM_SEARCH.Item(String($iParam))][0][0] = ''
    $FORMATLV_oPARAM_SEARCH.Remove(String($iParam))
    _GUICtrlListView_DeleteItem($hWnd, $iIndex)
    EndFunc ;==>_GUICtrlListView_FormattedDeleteItem

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

    Func _GUICtrlListView_FormattedDeleteItemsSelected($hWnd)
    Local $aSelected = _GUICtrlListView_GetSelectedIndices($hWnd, True)
    For $i = 1 To $aSelected[0]
    Local $iParam = _GUICtrlListView_GetItemParam($hWnd, $aSelected[$i]) -$SHIFT_PARAMVALUE
    $FORMATLV_aIPARAM[$FORMATLV_oPARAM_SEARCH.Item(String($iParam))][0][0] = ''
    $FORMATLV_oPARAM_SEARCH.Remove(String($iParam))
    _GUICtrlListView_DeleteItem($hWnd, $aSelected[$i])
    Next
    EndFunc ;==>_GUICtrlListView_FormattedDeleteItemsSelected

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

    Func _GUICtrlListView_FormattedDeleteAllItems($hWnd)
    Local $item = _GUICtrlListView_GetItemCount($hWnd)
    For $i = 0 To $item -1
    Local $iParam = _GUICtrlListView_GetItemParam($hWnd, $i) -$SHIFT_PARAMVALUE
    $FORMATLV_aIPARAM[$FORMATLV_oPARAM_SEARCH.Item(String($iParam))][0][0] = ''
    $FORMATLV_oPARAM_SEARCH.Remove(String($iParam))
    Next
    _GUICtrlListView_DeleteAllItems($hWnd)
    EndFunc ;==>_GUICtrlListView_FormattedDeleteAllItems

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

    Func _GUICtrlListView_FormattingCell($hWnd, $iItem, $iSubItem, $iBkCol=-1, $iCol=-1, $iSize=-1, $iWeight=-1, $sFont=-1)
    Local $sumParam = 0
    Local $iParam = _GUICtrlListView_GetItemParam($hWnd, $iItem) -$SHIFT_PARAMVALUE
    Local $index = $FORMATLV_oPARAM_SEARCH.Item(String($iParam))
    If $iBkCol = -1 Then
    $iBkCol = $FORMATLV_DEF_BKCOL
    $sumParam += 1
    EndIf
    If $iCol = -1 Then
    $iCol = $FORMATLV_DEF_COL
    $sumParam += 1
    EndIf
    If $iSize = -1 Then
    $iSize = $FORMATLV_DEF_SIZE
    $sumParam += 1
    EndIf
    If $iWeight = -1 Then
    $iWeight = $FORMATLV_DEF_WEIGHT
    $sumParam += 1
    EndIf
    If $sFont = -1 Then
    $sFont = $FORMATLV_DEF_FONT
    $sumParam += 1
    EndIf
    $FORMATLV_aIPARAM[$index][$iSubItem+1][0] = $iBkCol
    $FORMATLV_aIPARAM[$index][$iSubItem+1][1] = $iCol
    $FORMATLV_aIPARAM[$index][$iSubItem+1][2] = $iSize
    $FORMATLV_aIPARAM[$index][$iSubItem+1][3] = $iWeight
    $FORMATLV_aIPARAM[$index][$iSubItem+1][4] = $sFont
    ; if SubItem not registered in IParam OR all values by -1 (delete Sub from IParam) ==> switch Sub value in IParam
    Local $mark = DllStructGetData($FORMATLV_aIPARAM[$index][0][0], 2, $iSubItem+1)
    If Not $mark Or $sumParam = 5 Then
    DllStructSetData($FORMATLV_aIPARAM[$index][0][0], 2, BitXOR($mark, 1), $iSubItem+1)
    EndIf
    If DllStructGetData($FORMATLV_aIPARAM[$index][0][0], 2, $iSubItem+1) <> $mark Or $sumParam <> 5 Then
    _GUICtrlListView_RedrawItems($hWnd, $iItem, $iItem)
    EndIf
    EndFunc ;==>_GUICtrlListView_FormattingCell

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

    Func __DrawItemCol(ByRef $hDC, ByRef $tCustDraw, $hWnd, $iItem, $iSubitem) ; draw formatted item
    Local $aDefFont[14] = [14,0,0,0,$FW_NORMAL,False,False,False, _
    $DEFAULT_CHARSET,$OUT_DEFAULT_PRECIS,$CLIP_DEFAULT_PRECIS,$DEFAULT_QUALITY,0,'Arial']
    Local $iSZ = $FORMATLV_aIPARAM[$iItem][$iSubItem+1][2]
    Local $iWT = $FORMATLV_aIPARAM[$iItem][$iSubItem+1][3]
    Local $sTP = $FORMATLV_aIPARAM[$iItem][$iSubItem+1][4]
    Local $iTX = $FORMATLV_aIPARAM[$iItem][$iSubItem+1][1]
    Local $iBK = $FORMATLV_aIPARAM[$iItem][$iSubItem+1][0]
    Local $bFontChanged = False
    If ( $iSZ <> $FORMATLV_LAST_FONT_SIZE ) Or ( $iWT <> $FORMATLV_LAST_FONT_WEIGHT ) Or ( $sTP <> $FORMATLV_LAST_FONT_TYPE ) Then
    $aDefFont[0] = $iSZ
    $aDefFont[4] = $iWT
    $aDefFont[13] = $sTP
    $FORMATLV_LAST_FONT_SIZE = $iSZ
    $FORMATLV_LAST_FONT_WEIGHT = $iWT
    $FORMATLV_LAST_FONT_TYPE = $sTP
    $bFontChanged = True
    EndIf
    If ( $iTX <> $FORMATLV_LAST_COL ) Then
    DllStructSetData($tCustDraw, 'clrText', RGB2BGR($iTX))
    $FORMATLV_LAST_COL = $iTX
    EndIf
    If ( $iBK <> $FORMATLV_LAST_BKCOL ) Then
    DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($iBK))
    $FORMATLV_LAST_BKCOL = $iBK
    EndIf
    If $bFontChanged Then
    $FORMATLV_hFONT = _WinAPI_CreateFont($iSZ,$aDefFont[1],$aDefFont[2],$aDefFont[3],$iWT,$aDefFont[5],$aDefFont[6], _
    $aDefFont[7],$aDefFont[8],$aDefFont[9],$aDefFont[10],$aDefFont[11],$aDefFont[12],$sTP)
    _WinAPI_SelectObject($hDC, $FORMATLV_hFONT)
    _WinAPI_DeleteObject($FORMATLV_hFONT)
    EndIf
    $FORMATLV_LAST_DEF = False
    EndFunc ;==>__DrawItemCol

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

    Func __DrawDefault(ByRef $hDC, ByRef $tCustDraw) ; draw unformatted item
    If $FORMATLV_LAST_DEF Then Return
    $hDC = DllStructGetData($tCustDraw, 'hdc')
    DllStructSetData($tCustDraw, 'clrText', RGB2BGR($FORMATLV_DEF_COL))
    DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($FORMATLV_DEF_BKCOL))
    $FORMATLV_hFONT = _WinAPI_CreateFont(14,0,0,0,$FW_NORMAL,False,False,False,$DEFAULT_CHARSET,$OUT_DEFAULT_PRECIS, _
    $CLIP_DEFAULT_PRECIS,$DEFAULT_QUALITY,0,'Arial')
    _WinAPI_SelectObject($hDC, $FORMATLV_hFONT)
    _WinAPI_DeleteObject($FORMATLV_hFONT)
    $FORMATLV_LAST_DEF = True
    $FORMATLV_LAST_FONT_SIZE = $FORMATLV_DEF_SIZE
    $FORMATLV_LAST_FONT_WEIGHT = $FORMATLV_DEF_WEIGHT
    $FORMATLV_LAST_FONT_TYPE = $FORMATLV_DEF_FONT
    $FORMATLV_LAST_COL = $FORMATLV_DEF_COL
    $FORMATLV_LAST_BKCOL = $FORMATLV_DEF_BKCOL
    EndFunc ;==>__DrawDefault

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

    Func __getMarked($hWnd, $iItem, $iSubItem) ; get index from array if item is formatted
    Local $cntCOL = _GUICtrlListView_GetColumnCount($hWnd)
    Local $iParam = _GUICtrlListView_GetItemParam($hWnd, $iItem) -$SHIFT_PARAMVALUE
    Local $struct = DllStructCreate("byte[" & $cntCOL & "]", $iParam)
    If DllStructGetData($struct, 1, $iSubItem+1) Then
    Return $FORMATLV_oPARAM_SEARCH.Item(String($iParam))
    Else
    Return -1
    EndIf
    EndFunc ;==>__getMarked

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

    Func RGB2BGR($iColor)
    Local $sH = Hex($iColor,6)
    Return '0x' & StringRight($sH, 2) & StringMid($sH,3,2) & StringLeft($sH, 2)
    EndFunc ;==>RGB2BGR

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

    Func _WinProc($hWnd, $Msg, $wParam, $lParam)
    If $Msg <> $WM_NOTIFY Then Return _WinAPI_CallWindowProc($FORMATLV_hHOOK, $hWnd, $Msg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

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

    For $i = 0 To UBound($FORMATLV_aHWND) -1
    If $hWndFrom = $FORMATLV_aHWND[$i] Then
    Switch $iCode
    Case $LVN_COLUMNCLICK
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
    __GUICtrlListView_SimpleSort($hWndFrom, $FORMATLV_B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
    Case $NM_CUSTOMDRAW
    If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG
    Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
    Local $iDrawStage, $iItem, $iSubitem, $hDC = DllStructGetData($tCustDraw, 'hdc'), $tRect
    $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage')
    Switch $iDrawStage
    Case $CDDS_ITEMPREPAINT
    Return $CDRF_NOTIFYSUBITEMDRAW
    Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM)
    $iItem = DllStructGetData($tCustDraw, 'dwItemSpec')
    $iSubitem = DllStructGetData($tCustDraw, 'iSubItem')
    Local $index = __getMarked($hWndFrom, $iItem, $iSubitem)
    If $index = -1 Then
    __DrawDefault($hDC, $tCustDraw)
    Else
    __DrawItemCol($hDC, $tCustDraw, $hWndFrom, $index, $iSubitem)
    EndIf
    Return $CDRF_NEWFONT
    EndSwitch
    Case $NM_RCLICK ;== fill Global array $FORMATLV_aITEM_INDEX
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
    Local $aInfo[9] = [True,$hWndFrom, DllStructGetData($tInfo, "Index"), DllStructGetData($tInfo, "SubItem")]
    If $aInfo[2] < 0 Then
    $aInfo[0] = False
    Return $GUI_RUNDEFMSG
    EndIf
    Local $isFormatted = __getMarked($hWndFrom, $aInfo[2], $aInfo[3]) ; always formatted?
    If $isFormatted = -1 Then
    For $i = 4 To 8
    $aInfo[$i] = -1
    Next
    Else ; read formatting values
    $aInfo[4] = $FORMATLV_aIPARAM[$aInfo[2]][$aInfo[3]+1][0]
    $aInfo[5] = $FORMATLV_aIPARAM[$aInfo[2]][$aInfo[3]+1][1]
    $aInfo[6] = $FORMATLV_aIPARAM[$aInfo[2]][$aInfo[3]+1][2]
    $aInfo[7] = $FORMATLV_aIPARAM[$aInfo[2]][$aInfo[3]+1][3]
    $aInfo[8] = $FORMATLV_aIPARAM[$aInfo[2]][$aInfo[3]+1][4]
    EndIf
    $FORMATLV_aITEM_INDEX = $aInfo
    ; if desired - use this array now in main script
    EndSwitch
    EndIf
    Next
    ; call default WinProcedure, which can be analyzed in main script with GuiRegisterMsg
    Return _WinAPI_CallWindowProc($FORMATLV_hHOOK, $hWnd, $Msg, $wParam, $lParam)
    EndFunc ;==>_WinProc

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

    Func __GUICtrlListView_SimpleSort($hWnd, ByRef $vDescending, $iCol) ; modified to sort also IParam
    Local $x, $Y, $Z, $b_desc, $columns, $items, $v_item, $temp_item, $iFocused = -1
    Local $SeparatorChar = Opt('GUIDataSeparatorChar')
    If _GUICtrlListView_GetItemCount($hWnd) Then
    If (IsArray($vDescending)) Then
    $b_desc = $vDescending[$iCol]
    Else
    $b_desc = $vDescending
    EndIf
    $columns = _GUICtrlListView_GetColumnCount($hWnd)
    $items = _GUICtrlListView_GetItemCount($hWnd)
    For $x = 1 To $columns
    $temp_item = $temp_item & " " & $SeparatorChar
    Next
    $temp_item = StringTrimRight($temp_item, 1)
    Local $a_lv[$items][$columns + 2], $i_selected ; add column for IParam ### MODIFIED ###

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

    $i_selected = StringSplit(_GUICtrlListView_GetSelectedIndices($hWnd), $SeparatorChar)
    For $x = 0 To UBound($a_lv) - 1 Step 1
    If $iFocused = -1 Then
    If _GUICtrlListView_GetItemFocused($hWnd, $x) Then $iFocused = $x
    EndIf
    _GUICtrlListView_SetItemSelected($hWnd, $x, False)
    For $Y = 0 To UBound($a_lv, 2) - 3 Step 1 ; ### MODIFIED ###
    $v_item = StringStripWS(_GUICtrlListView_GetItemText($hWnd, $x, $Y), 2)
    If (StringIsFloat($v_item) Or StringIsInt($v_item)) Then
    $a_lv[$x][$Y] = Number($v_item)
    Else
    $a_lv[$x][$Y] = $v_item
    EndIf
    Next
    $a_lv[$x][$Y] = $x
    $a_lv[$x][$Y+1] = _GUICtrlListView_GetItemParam($hWnd, $x) ; ### NEW ###
    Next
    _ArraySort($a_lv, $b_desc, 0, 0, $iCol)
    For $x = 0 To UBound($a_lv) - 1 Step 1
    For $Y = 0 To UBound($a_lv, 2) - 3 Step 1 ; ### MODIFIED ###
    _GUICtrlListView_SetItemText($hWnd, $x, $a_lv[$x][$Y], $Y)
    Next
    _GUICtrlListView_SetItemParam($hWnd, $x, $a_lv[$x][$Y+1]) ; ### NEW ###
    For $Z = 1 To $i_selected[0]
    If $a_lv[$x][UBound($a_lv, 2) - 2] = $i_selected[$Z] Then ; ### MODIFIED ###
    If $a_lv[$x][UBound($a_lv, 2) - 2] = $iFocused Then ; ### MODIFIED ###
    _GUICtrlListView_SetItemSelected($hWnd, $x, True, True)
    Else
    _GUICtrlListView_SetItemSelected($hWnd, $x, True)
    EndIf
    ExitLoop
    EndIf
    Next
    Next
    If (IsArray($vDescending)) Then
    $vDescending[$iCol] = Not $b_desc
    Else
    $vDescending = Not $b_desc
    EndIf
    EndIf
    EndFunc ;==>__GUICtrlListView_SimpleSort

    [/autoit]
    • Offizieller Beitrag

    @Spion
    Die Form, in welcher du die Funktionen aufrufst ist falsch

    Also entweder du muß vor dem GUISetState() alle deine Items erstellen

    Spoiler anzeigen
    [autoit]

    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include "LV_Format_Include[1.3a].au3"
    $gui = GUICreate("", 1320, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX))
    $listview = GUICtrlCreateListView("Spalte1|Spalte2", 0, 70, 1320, 780, $LVS_NOSORTHEADER)
    _GUICtrlListView_Formatting_Startup($gui, $listview)
    _GUICtrlListView_AddOrIns_Item($listview, "Zeile0")
    _GUICtrlListView_FormattingCell($listview, 0, 0, 0xff0000)
    GUISetState()

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

    #region - GUI SwitchLoop
    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd
    #endregion - GUI SwitchLoop

    [/autoit]


    Oder nach dem GUISetState das Listview vorher sperren _GUICtrlListView_BeginUpdate und nach dem erstellen der Items das LIstview wieder freigeben _GUICtrlListView_EndUpdate

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include "LV_Format_Include[1.3a].au3"
    #include <GuiListview.au3>
    $gui = GUICreate("" , 1320, 900, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX))
    $listview = GUICtrlCreateListView("Spalte1", 0, 70, 1320, 780, $LVS_NOSORTHEADER)
    _GUICtrlListView_Formatting_Startup($gui, $listview)
    GUISetState()
    _GUICtrlListView_BeginUpdate($Listview)
    _GUICtrlListView_AddOrIns_Item($listview, "Zeile1")
    _GUICtrlListView_FormattingCell($listview, 0, 0, 0xff0000)
    _GUICtrlListView_EndUpdate($Listview)
    #region - GUI SwitchLoop
    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd
    #endregion

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


    Die UDF läuft nur wenn sie als x86 compiliert wurde.
    Aus mir im Augenblick nicht ersichtlichen Gründen, funktioniert das Colorieren eines 1 Column ListViews nur bei der 2. Codevariante.

    So, um dich jetzt ganz konfus zu machen, setze ich einen obendrauf ^^ :
    Wenn du AutoIt 3.3.12.0 benutzt, kann das Colorieren überhaupt nich funktionieren, da AutoIt selber verbugt ist.
    Die Verwendete Funktion _GUICtrlListView_GetViewDetails liefert falsche Werte zurück. Was aber dein Glück war, da sonst dein oben
    gepostetes Script AutoIt in die ewigen Jagdgründe geschossen hätte (erstellen der Items ohne vorheriges sperren des ListViews).
    Das Listview versucht ein Item darzustellen, welches noch nicht mal existiert, zumindest nicht richtig.

    Lange Rede, kurzer Sinn, ich habe unten mal eine Fehlerbereinigte UDF für AutoIt 3.3.12.0 angehängt. ;)

    @water
    Du bist ja so dicke mit dem EN-Forum, teile den Devs mal mit, das _GUICtrlListView_GetViewDetails und _GUICtrlListView_GetViewLarge verbugt sind und den Wert der jeweilig anderen Funktion zurückgibt. Die Func _GUICtrlListView_GetView wurde geändert, aber die beiden Funktionen nicht darauf
    abgeändert.

    Zitat von Script breaking changes


    1st June, 2014 - v3.3.12.0 :

    _GUICtrlListView_GetView() and _GUICtrlListView_SetView() were using 0 for detailed view and 1 for large icon view, when it's 0 for large icon view and 1 for detailed view.


    _GUICtrlListView_GetViewDetails und _GUICtrlListView_GetViewLarge benutzen die alten Werte.

  • Ticket wurde angelegt.
    Sobald das bestätigt wird baue ich die Änderung im Repository ein.