AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

array of record sortieren

Ein Thema von venice2 · begonnen am 7. Dez 2020 · letzter Beitrag vom 27. Jan 2021
Antwort Antwort
venice2
(Gast)

n/a Beiträge
 
#1

AW: array of record sortieren

  Alt 8. Dez 2020, 14:05
TItemsInfo wird nur erstellt wenn entsprechende Column ein Icon enthält.
Column oder Row?
Row(Zeile) natürlich sorry..
Die Sortierung ist aber Column(Spalten) abhängig.
  Mit Zitat antworten Zitat
freimatz

Registriert seit: 20. Mai 2010
1.491 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: array of record sortieren

  Alt 8. Dez 2020, 15:06
Versuchte schon mehrmals vergeblich rauszufinden was Du willst.
Ich habe den Eindruck Du willst nicht ein "array of record sortieren" sondern Einträge in einem Litview. Ich bin dann raus.
  Mit Zitat antworten Zitat
venice2
(Gast)

n/a Beiträge
 
#3

AW: array of record sortieren

  Alt 8. Dez 2020, 15:22
Versuchte schon mehrmals vergeblich rauszufinden was Du willst.
Ich habe den Eindruck Du willst nicht ein "array of record sortieren" sondern Einträge in einem Litview. Ich bin dann raus.
Nee beides.
Das array of record soll so sortiert werden das der Index des records passend ist zu dem der über
ListView_SortItems(hListView, @CompareFunc, ColumnIndex); // Liste wird sortiert

sortiert wurde.

Ich habe jetzt mal versucht die Bilder fest an das ListView zu binden über eine Imageliste!
Delphi-Quellcode:
  // Imageliste initialisieren
  if hLarge = 0 then
  begin
    hLarge := ImageList_Create(round(bw), round(bh), ILC_COLOR32, 1, 1); // 32 Bit Bitmap konvertiert zu Icon
    ListView_SetImageList(Handle, hLarge, LVSIL_NORMAL);
  end;
  // Icon zur Liste addieren
  ImageList_AddIcon(hLarge, hIconItem);

  SetLength(ItemsInfo, nItem + 1);
  ItemsInfo[nItem].Item := nItem;
  ItemsInfo[nItem].SubItem := nSubItem;
  ItemsInfo[nItem].Width := round(bw);
  ItemsInfo[nItem].Height := round(bh);
  ItemsInfo[nItem].ImgIcon := hIconItem;
  ItemsInfo[nItem].IdentStr := ImgIdent;

  // Icon freigeben
  // wird nicht mehr verwendet da in der ImageList enthalten
  DestroyIcon(hIconItem);
Delphi-Quellcode:
            if assigned(ItemsInfo) then
            begin
              if (HeaderItem = ItemsInfo[Item].SubItem) and (ItemsInfo[Item].ImgIcon <> 0) then
              begin
                GetWindowRect(HeaderHandle, HeaderWindowRect);

                TmpRect := ClientRect;
                TmpRect.Left := ClientRect.Left + ItemsInfo[Item].Width;
                TmpRect.Top := ClientRect.Top + ((ItemHeight - FPointSize) div 2);

                HeaderItemRect.Left := (HeaderWindowRect.Left - LvWindowRect.Left) +
                  (ClientRect.Left + HeaderItemRect.Left);

                if ImageList_Draw(hLarge, Item, hTempDC,
                  HeaderItemRect.Left, (ClientRect.Top + 4), ILD_TRANSPARENT) then
                //DrawIconEx(hTempDC, HeaderItemRect.Left, (ClientRect.Top + 4),
                // ItemsInfo[Item].ImgIcon, ItemsInfo[Item].Width,
                // ItemsInfo[Item].Height, 0, 0, DI_NORMAL);

                DrawItem(WinHandle, hTempDC, Item, HeaderItem, TmpRect, ItemText, nSelected);
              end
              else
              //..
aber nein. Die Bitmaps werden nicht an der korrekten Position gezeichnet bleiben einfach da wo sie sind nach dem sortieren.
Warum?

Das Problem ist hier das gleiche.
Ich addiere Icons in der Reihenfolge. Die Reihenfolge richtet sich aber nicht nach dem Index der Zeile sondern wird hintereinander in die ImageListe
addiert und schon habe ich wieder das Problem das der Index nicht passend zur Zeile ist.

Bsp.
ListRows
1,2,3,4,5 (3 Zeile hat kein Bild)
ImageListe addiert
1,2,3,4 (3 Ist ja leer) also -1 Bild

wenn ich nun zeichne werden die Rows mit Bildern belegt von 1 > 4 die 3 sollte eigentlich leer sein und die 5 Belegt.
Wie will man das prüfen.
grrr....

Geändert von venice2 ( 8. Dez 2020 um 15:58 Uhr)
  Mit Zitat antworten Zitat
venice2
(Gast)

n/a Beiträge
 
#4

AW: array of record sortieren

  Alt 8. Dez 2020, 20:10
Ok. Habe eine vorläufig Lösung.
Ich übergebe ja in SetItemIcon das SubItem wo ich die Bilder zeichne.
ItemsInfo[nItem].SubItem := nSubItem;

Das verwende ich nun für SortItems
das.
Delphi-Quellcode:
   for i := 0 to ItemCount - 1 do
    begin
      ZeroMemory(@buf, sizeof(buf));
      ListView_GetItemText(hListView, i, 1, buf, sizeof(buf));
      ItemText := buf;
      StringList.Add(ItemText); // Stringliste anhand der Sortierung erstellen.
    end;
zu
Delphi-Quellcode:
    for i := 0 to ItemCount - 1 do
    begin
      ZeroMemory(@buf, sizeof(buf));
      ListView_GetItemText(hListView, i, ItemsInfo[i].SubItem, buf, sizeof(buf));
      ItemText := buf;
      StringList.Add(ItemText); // Stringliste anhand der Sortierung erstellen.
    end;
gut ist
  Mit Zitat antworten Zitat
venice2
(Gast)

n/a Beiträge
 
#5

AW: array of record sortieren

  Alt 8. Dez 2020, 22:44
Neues Problem das nur unter 32Bit auftritt.

Zitat:
Exception:
------------------------------------------------------------------------------------
2.2 Address: 0263A332
2.5 Type : EBufferOverflowError
2.6 Message: Application has corrupted the memory: $0E663DE0 ARRAY [?] 5128 bytes.
2.7 ID : 40060000
2.11 Sent : 0

Call Stack Information:
----------------------------------------------------------------------------------------------------------------------------------------
|Methods |Details|Stack |Address |Module |Offset |Unit |Class |Procedure/Method |Line |
----------------------------------------------------------------------------------------------------------------------------------------
|*Exception Thread: ID=9580; Parent=0; Priority=0 |
|Class=; Name=MAIN |
|DeadLock=0; Wait Chain= |
|Comment= |
|--------------------------------------------------------------------------------------------------------------------------------------|
|7FFFFFFE|03 |00000000|0263A337|SK_Aero.dll |0000A337|System | |_DynArrayClear | |
|00000020|04 |0019E490|0281B1B8|SK_Aero.dll |001EB1B8|uListView|TSkinListView|SortItems |1858[38] |
|00000020|04 |0019E6CC|02819C37|SK_Aero.dll |001E9C37|uListView|TSkinListView|ListViewProc |1270[40] |
|00000020|04 |0019E9DC|0281783B|SK_Aero.dll |001E783B|uListView|TSkinListView|ClientWndProc |292[18] |
In der Funktion.

Delphi-Quellcode:

    SetLength(lItemsInfoArray, length(ItemsInfo));

    for i := High(ItemsInfo) downto Low(ItemsInfo) do
      begin
        j := StringList.IndexOf(ItemsInfo[i].IdentStr);
        if j >= 0 then
          begin
            lItemsInfoArray[j] := ItemsInfo[i];
            StringList[j] := 'Vorhanden';
          end;
      end;

      for i := High(lItemsInfoArray) downto Low(lItemsInfoArray) do
        ItemsInfo[i] := lItemsInfoArray[i];
selber code unter 64Bit läuft einwandfrei.

Kommentiere ich ihn aus läuft alles nur nicht mehr sortiert.


Hmm..

Geändert von venice2 ( 9. Dez 2020 um 03:22 Uhr)
  Mit Zitat antworten Zitat
Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.487 Beiträge
 
Delphi 12 Athens
 
#6

AW: array of record sortieren

  Alt 9. Dez 2020, 11:39
buf: array [0 .. 255] of Char;

ListView_GetItemText entspricht in dieser Delphi-Version ListView_GetItemTextW und erwartet als Buffer ein Array aus WideChar
Als Buffergröße muss nicht die maximale Anzahl der Byte, sondern die maximale Anzahl der WideChar (je 2 Byte) angegeben werden.
Delphi-Quellcode:
buf: array [0 .. 255] of WideChar;

ListView_GetItemText(hListView, i, 1, buf, Length(buf));
  Mit Zitat antworten Zitat
venice2
(Gast)

n/a Beiträge
 
#7

AW: array of record sortieren

  Alt 9. Dez 2020, 15:45
buf: array [0 .. 255] of Char;

ListView_GetItemText entspricht in dieser Delphi-Version ListView_GetItemTextW und erwartet als Buffer ein Array aus WideChar
Als Buffergröße muss nicht die maximale Anzahl der Byte, sondern die maximale Anzahl der WideChar (je 2 Byte) angegeben werden.
Delphi-Quellcode:
buf: array [0 .. 255] of WideChar;

ListView_GetItemText(hListView, i, 1, buf, Length(buf));
Die Stringliste wird korrekt mit den Daten gefüllt.
Das Problem ist das Array.


Exception:
------------------------------------------------------------------------------------
2.2 Address: 0238A332
2.5 Type : EBufferOverflowError
2.6 Message: Application has corrupted the memory: $0674EB40 ARRAY [?] 5128 bytes.
2.7 ID : E53C0000
2.11 Sent : 0

Call Stack Information:
--------------------------------------------------------------------------------------------------------------------------------------
|Methods |Details|Stack |Address |Module |Offset |Unit |Class |Procedure/Method |Line |
--------------------------------------------------------------------------------------------------------------------------------------
|*Exception Thread: ID=2236; Parent=0; Priority=0 |
|Class=; Name=MAIN |
|DeadLock=0; Wait Chain= |
|Comment= |
|------------------------------------------------------------------------------------------------------------------------------------|
|7FFFFFFE|03 |00000000|0238A337|SK_Aero.dll |0000A337|System | |_DynArrayClear | |
|00000020|04 |0019D9D0|0256B1A7|SK_Aero.dll |001EB1A7|uListView|TSkinListView|SortItems |1863[42] |
|00000020|03 |0019E1C0|7742E892|a |0001E892|recursive|area |removed |3[0] |
|00000020|03 |0019E464|023896CA|SK_Aero.dll |000096CA|System | |_CopyRecord | |
|00000020|04 |0019E47C|0256B10F|SK_Aero.dll |001EB10F|uListView|TSkinListView|SortItems |1848[27] |
|00000020|04 |0019E6CC|02569C24|SK_Aero.dll |001E9C24|uListView|TSkinListView|ListViewProc |1271[40] |



definition von ListView_GetItemText
D2010
Delphi-Quellcode:
function ListView_GetItemText(hwndLV: HWND; i, iSubItem: Integer;
  pszText: PWideChar; cchTextMax: Integer): Integer;
D10.4
LPWSTR = PWideChar!
Delphi-Quellcode:
function ListView_GetItemText(hwndLV: HWND; i, iSubItem: Integer;
  pszText: LPWSTR; cchTextMax: Integer): Integer;
Sollte also gleich sein. Aber . Ja! Ich habe es getestet macht keinen unterschied. Danke
Anwendung stürzt ab innerhalb des Arrays

Geändert von venice2 ( 9. Dez 2020 um 17:54 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:43 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