home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Dirscan / dirlist1.pas < prev    next >
Pascal/Delphi Source File  |  1995-05-15  |  2KB  |  72 lines

  1. { Import this Unit into a new project and delete the default Unit1 }
  2. unit Dirlist1;
  3.  
  4. interface
  5.  
  6. uses
  7.   SysUtils,
  8.   WinTypes,
  9.   WinProcs,
  10.   Messages,
  11.   Classes,
  12.   Graphics,
  13.   Controls,
  14.   Forms,
  15.   Dialogs,
  16.   StdCtrls;
  17.  
  18. type
  19.   TForm1 = class(TForm)
  20.     ListBox1: TListBox;
  21.     Edit1: TEdit;
  22.     Label1: TLabel;
  23.     Label2: TLabel;
  24.     Edit2: TEdit;
  25.     Button1: TButton;
  26.     Button2: TButton;
  27.     procedure Button2Click(Sender: TObject);
  28.     procedure Button1Click(Sender: TObject);
  29.   private
  30.     { this is the notification function for the directory scan }
  31.     Function LogFiles( Const path: String; Const SRec: TSearchRec ): Boolean;
  32.     { Private-Deklarationen }
  33.   public
  34.     { Public-Deklarationen }
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. USes DirScan;
  43.  
  44. {$R *.DFM}
  45.  
  46. Function TForm1.LogFiles( Const path: String; Const SRec: TSearchRec ): Boolean;
  47.   Begin
  48.     Listbox1.Items.Add( path+SRec.Name );
  49.     Result := True;   (* proceeed with recursion *)
  50.   End;
  51.  
  52. procedure TForm1.Button2Click(Sender: TObject);
  53. begin
  54.   Application.Terminate;
  55. end;
  56.  
  57. procedure TForm1.Button1Click(Sender: TObject);
  58. begin
  59.   Screen.Cursor := crHourGlass;
  60.   ListBox1.Clear;
  61.   Listbox1.Perform( WM_SETREDRAW, 0, 0 );
  62.   FindRecursive( Edit1.Text, Edit2.Text, LogFiles );
  63.   Listbox1.Perform( WM_SETREDRAW, 1, 0 );
  64.   Listbox1.Refresh;
  65.   Screen.Cursor := crDefault;
  66.   If ListBox1.Items.Count = 0 Then
  67.     MessageDlg('No files matching the mask were found!',
  68.                mtInformation, [mbOK], 0);
  69. end;
  70.  
  71. end.
  72.