Thema: Delphi TStrings Liste

Einzelnen Beitrag anzeigen

tmrxxoja

Registriert seit: 16. Mär 2008
Ort: Helgoland
27 Beiträge
 
Delphi 7 Professional
 
#4

Re: TStrings Liste

  Alt 16. Mär 2008, 14:04
keine spalten

eigentlich nur Pfad angaben

Delphi-Quellcode:
unit Main;

interface

uses
  Windows,
  Messages,
  SysUtils,
  Variants,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  StdCtrls,
  Grids;

type
  TForm1 = class(TForm)
    Grid: TStringGrid;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    nBild : integer;
  end;

procedure FileList(const APath, AExt: string; ARecurse: Boolean; AList: TStrings);

var
  Form1: TForm1;

implementation

{$R *.dfm}

//******************************************************************************
procedure TForm1.Button1Click(Sender: TObject);
var cPfad : string;
    aList : TStrings;
        n : integer;
begin

  cPfad := 'c:/test/';
  FileList(cPfad, '*.jpg', True, aList);

  for n := 0 to aList.Count do begin
    inc(nBild);
    Grid.RowCount := Grid.RowCount+1;

    Grid.Cells[0,nBild] := 'test1';
    Grid.Cells[1,nBild] := aList[nBild];
    Grid.Cells[2,nBild] := 'test3';
  end;

end;

//******************************************************************************

procedure FileList(const APath, AExt: string; ARecurse: Boolean; AList: TStrings);
var
  F : TSearchRec;
  Path : string;
begin
  Path := IncludeTrailingPathDelimiter(APath); // nur für Delphi 4 und höher!
  if (ARecurse) and
    (FindFirst(Path + '*.*', faAnyFile, F) = 0) then
  try
    repeat
      if (F.Name <> '.') and (F.Name <> '..') and
        ((F.Attr and faDirectory) = faDirectory) then
        FileList(Path + F.Name, AExt, ARecurse, AList);
    until FindNext(F) <> 0;
  finally
    FindClose(F);
  end;
  if FindFirst(Path + AExt, faAnyFile, F) = 0 then
  try
    repeat
      if (F.Name <> '.') and (F.Name <> '..') and
        ((F.Attr and faDirectory) <> faDirectory) then
        AList.Add(Path + F.Name);
    until FindNext(F) <> 0;
  finally
    FindClose(F);
  end;
end;

//******************************************************************************

procedure TForm1.FormCreate(Sender: TObject);
begin
  nBild := 0;

  Grid.Cells[0,0]:= 'Bildname';
  Grid.Cells[1,0]:= 'Pfad';
  Grid.Cells[2,0]:= 'Erstellungdatum';


end;

end.
so sieht zur zeit mein programm aus
  Mit Zitat antworten Zitat