Autor Beitrag
delphinia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 25.03.06 12:57 
Hallo

nutzte ne TListView für die Anzeige von Icons. Derzeit habe ich über 5000 Icons in der Liste das Programm braucht derzeit mehrere Minuten zum laden und anzeigen der Icons. Kann man der ListView ein bisschen mehr speed verleihen?

Danke Euch und wünsche euch ein schönes ruhiges Wochenende....

Eure Doreen
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 25.03.06 13:34 
Rufst Du vor dem Reinschreiben die "BeginUpdate"- und nachher die "EndUpdate"-Methode auf?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 25.03.06 13:35 
nööö... sollte ich das tun?
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Sa 25.03.06 13:37 
Ja, dadurch wird das Eintragen in das ListView erheblich schneller.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 25.03.06 13:39 
Ja, das solltest Du tun ;-) Damit wird verhindert, dass die Bildschirmanzeige bei jedem Icon aktualisiert wird.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 25.03.06 13:39 
hmm hab das mal gerade eingefügt ... aber nen unterschied merk ich net ;(
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 25.03.06 13:39 
Zeig mal bitte Deinen Code!

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 25.03.06 13:43 
hmmm code zeigen ist schwer ich lade die


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
procedure LV_InsertFiles(strPath: string; ListView: TlistView; ImageList: TImageList);
var
  i: Integer;
  Icon: TIcon;
  SearchRec: TSearchRec;
  ListItem: TListItem;
  FileInfo: SHFILEINFO;
begin
  Icon := TIcon.Create;
  ListView.Items.BeginUpdate;

  try
    i := FindFirst(strPath + '*.*', faAnyFile, SearchRec);
    while i = 0 do
    begin
      with ListView do
      begin
        if ((SearchRec.Attr and FaDirectory <> FaDirectory) and
          (SearchRec.Attr and FaVolumeId <> FaVolumeID)) then
        begin
          ListItem := ListView.Items.Add;
Application.ProcessMessages;

          SHGetFileInfo(PChar(strPath + SearchRec.Name), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_LARGEICON);
          icon.Handle := FileInfo.hIcon;

          ListItem.ImageIndex := ImageList.AddIcon(Icon);


          DestroyIcon(FileInfo.hIcon);

          Application.ProcessMessages;
        end;
      end;
      i := FindNext(SearchRec);
    end;
  finally
    Icon.Free;
    ListView.Items.EndUpdate;
  end;
end;



nun und dann das

ausblenden Delphi-Quelltext
1:
LV_InsertFiles('C:\Windows\System32', listview1, imagelist1);					
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 25.03.06 13:50 
hallo

deine schnekce ist das pllication.processmesaages

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 25.03.06 13:55 
Hab ich auch gedacht, macht komischerweise bei mir aber nur 0,2s auf insgesamt 5,8s aus.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 25.03.06 13:57 
hmmm also auch alle Ratlos?

@Christian S.
Wie haste die Zeit gemessen?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8553
Erhaltene Danke: 479

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 25.03.06 14:01 
Mit der manchmal etwas geringen Geschwindigkeit der Listview hatte ich auch mal Probleme. Ich bin dann umgestiegen auf eine andere Komponente, den VirtualTreeView: www.soft-gems.net/
Kann ich nur empfehlen. Die Bedienung ist zwar etwas komplizierter als bei der Listview, aber es lohnt sich - und das sage ich, wo ich absolut kein Freund von vielen Fremdkomponenten bin.

_________________
We are, we were and will not be.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 25.03.06 14:01 
Ich messe die Zeit mittels GetTickCount.

So, wie es aussieht, ist der Flaschenhals die SHGetFileInfo-Methode. Darauf entfallen bei mir 3,7s.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".