Thema: Delphi TreeView und ListView

Einzelnen Beitrag anzeigen

Malte Koch

Registriert seit: 11. Sep 2007
Ort: Recklinghausen
15 Beiträge
 
Delphi 2007 Professional
 
#21

Re: TreeView und ListView

  Alt 12. Sep 2007, 16:29
Liest die Ordner aus:

Delphi-Quellcode:
procedure TForm2.HoleVerzeichnisse(const Pfad: String; var Tree: TTreeView;
                                  Start: TTreeNode);
var
 SR: TSearchRec;
  begin
    if FindFirst(Pfad + '\*.*', faAnyFile, SR) = 0 then
  repeat
    Application.ProcessMessages;
    if (SR.Attr AND faDirectory = faDirectory) AND (SR.Name[1] <> '.')
        AND (SR.Name[1] <> '_') then
    begin
      baum := Tree.Items.Addchild(Start, SR.Name);
      baum.SelectedIndex := 1;
      baum.ImageIndex := 1;
      baum.StateIndex := -1;
      HoleVerzeichnisse(Pfad+'\'+ SR.Name, Tree, baum);
    end;
  until (FindNext(SR) <> 0);
 SysUtils.FindClose(SR);
end;
Zeigt die entsprechenden Dateien an:

Delphi-Quellcode:
procedure TForm2.HoleDateien(const Pfad: String; ListV: TListView; Filter: String);
var
 SR: TSearchRec;
 anItem:TListItem;
   begin
    if FindFirst(Pfad + '\' + Filter, faAnyFile, SR) = 0 then
  repeat
    Application.ProcessMessages;
    if (SR.Attr AND faDirectory <> 16) AND (SR.Name[1] <> '.')
        AND (SR.Name[1] <> '_') then
    begin
            anItem:=ListV.Items.Add;
            anItem.Caption:=SR.Name;

            anItem.SubItems.Add( IntToStr(GetFileSizeEx(Pfad+'\'+SR.Name)div 1024));
            anItem.SubItems.Add( GetFileTypename(Pfad+'\'+SR.Name));
            anItem.SubItems.Add( DateToStr(GetFileLastAccessTime(Pfad+'\'+SR.name)));
            anItem.SubItems.Add( DateToStr(GetCreationTimeOfFile(Pfad+'\'+SR.Name)));
      end;
  until (FindNext(SR) <> 0);
  SysUtils.FindClose(SR);
end;
  Mit Zitat antworten Zitat