![]() |
AW: (nonVcl) ListView Sortieren ein durcheinander
Zitat:
Klar kann sie das Strings und Integer werte. Ist erweiterbar aber mir reichst. Habe das für meine Zwecke noch abgeändert um unabhängig von irgendwelchen ID's bzw.. SubItems zu sein.
Delphi-Quellcode:
TSortType = (sortInt = 1, sortString = 2);
Delphi-Quellcode:
PColumnInfo = ^TColumnInfo;
TColumnInfo = record SortType: TSortType; end;
Delphi-Quellcode:
ColumnInfo: array of TColumnInfo;
Delphi-Quellcode:
Aufgerufen wird es dann so.
function CompareFunc(lp1, lp2, SubItem: LPARAM): integer; stdcall;
var buf1, buf2 : WideString; a, b : integer; begin SetLength(buf1, MAX_PATH); ZeroMemory(@buf1[1], MAX_PATH); SetLength(buf2, MAX_PATH); ZeroMemory(@buf2[2], MAX_PATH); ListView_GetItemText(LVHandle, lp1, SubItem, @buf1[1], MAX_PATH); ListView_GetItemText(LVHandle, lp2, SubItem, @buf2[1], MAX_PATH); case ColumnInfo[SubItem].SortType of // Dateigröße sortInt: begin // alles nach dem Leerzeichen entfernen (z.B. "12345 B") if(pos(#32, buf1) > 0) then delete(buf1, pos(#32,buf1), length(buf1)); if(pos(#32, buf2) > 0) then delete(buf2, pos(#32, buf2), length(buf2)); if UpDown then begin b := StrToIntDef(buf1, 0); a := StrToIntDef(buf2, 0); end else begin a := StrToIntDef(buf1, 0); b := StrToIntDef(buf2, 0); end; if(a > b) then Result := 1 else if(a < b) then Result := -1 else Result := 0; end // Name oder Typ else begin if UpDown then Result := lstrcmpi(@buf2[1], @buf1[1]) else Result := lstrcmpi(@buf1[1], @buf2[1]); end; end; end;
Delphi-Quellcode:
So kann man jeder Spalte zuweisen wie sie Sortiert werden soll.
LVPlayList.InsertColumn(LVPlayList.Handle, 0, 'Nr.', 50, False, sortInt);
LVPlayList.InsertColumn(LVPlayList.Handle, 1, 'Time', 55, False, sortString); False steht für das Icon ob es angezeigt werden soll beim Start oder nicht. gruss |
AW: (nonVcl) ListView Sortieren ein durcheinander
Zitat:
|
AW: (nonVcl) ListView Sortieren ein durcheinander
Zitat:
Versuchs mal nur mit ListView_SortItems und schau was dabei rum kommt. Für mich ist ausschlaggebend das ich 6000 Dateien im ms. Bereich sortieren kann. gruss |
AW: (nonVcl) ListView Sortieren ein durcheinander
irgend jemand ne Ahnung wie ich das hier auf Luckies Compare Funktion umlegen kann?
Delphi-Quellcode:
Ich könnte mir dann diesen type erweitern.
//Float-Werte
2: begin Compare := 0; if StrToFloat(TextToSort1) > StrToFloat(TextToSort2) then Compare := Trunc(StrToFloat(TextToSort1)-StrToFloat(TextToSort2))+1; if StrToFloat(TextToSort1) < StrToFloat(TextToSort2) then Compare := Trunc(StrToFloat(TextToSort1)-StrToFloat(TextToSort2))-1; end; //2 //DateTime-Werte 3: begin Compare := 0; if StrToDateTime(TextToSort1) > StrToDateTime(TextToSort2) then Compare := Trunc(StrToDateTime(TextToSort1)-StrToDateTime(TextToSort2))+1; if StrToDateTime(TextToSort1) < StrToDateTime(TextToSort2) then Compare := Trunc(StrToDateTime(TextToSort1)-StrToDateTime(TextToSort2))-1; end; //3
Delphi-Quellcode:
TSortType = (sortInt = 1, sortString = 2);
Delphi-Quellcode:
TSortType = (sortInt = 1, sortString = 2, sortFloat = 3, sortDateTime = 4);
gruss |
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:12 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz