Einzelnen Beitrag anzeigen

Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.380 Beiträge
 
Delphi 10.4 Sydney
 
#9

AW: TTreeView komige Speedprobleme...

  Alt 27. Aug 2011, 13:36
Probier' mal so, vielleicht bringt's ja was.

Delphi-Quellcode:

procedure GetNodeDirs(const ADirectory: String; const Tree: TTreeView; const Start: TTreeNode);

  function SlashSep(const Path, S: String): String;
  begin
    if AnsiLastChar(Path)^ <> '\then
      Result:= Path+'\'+S
    else
      Result:= Path+S;
  end;

var
  SearchRec: TSearchRec;
  NewNode: TTreeNode;

begin
  if FindFirst(SlashSep(ADirectory, '*.*'), faDirectory, SearchRec) = 0 then
  try
    repeat
      if ((SearchRec.Attr and faDirectory) <> 0) then
        if ((SearchRec.Name <> '.') and (SearchRec.Name <> '..')) then
        begin
          NewNode:= Tree.Items.AddChild(Start, SearchRec.Name);
          GetNodeDirs(SlashSep(ADirectory, SearchRec.Name), Tree, NewNode);
        end;
    until FindNext(SearchRec) <> 0;
  finally
    Findclose(SearchRec);
  end;
end;


TreeView1.Items.BeginUpDate;
TreeView1.Items.Clear;
GetNodeDirs('C:\', TreeView1, TreeView1.Items.AddChild(Nil, 'C:\'));
// TreeView1.AlphaSort;
TreeView1.Items.EndUpDate;
  Mit Zitat antworten Zitat