home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / comps / widgets / delphi10 / ffltlbox / ffltlbox.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-15  |  1.5 KB  |  60 lines

  1. unit Ffltlbox;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls;
  8.  
  9. type
  10.   TFileFilterListBox = class(TListBox)
  11.   private
  12.     { Private declarations }
  13.     FTheMask : String;
  14.     FOnShowFileList : TNotifyevent;
  15.   protected
  16.     { Protected declarations }
  17.   public
  18.     { Public declarations }
  19.     procedure ShowFileList;
  20.   published
  21.     { Published declarations }
  22.     Property TheMask : String read FTheMask write FTheMask;
  23.     property OnShowFileList : TNotifyEvent read FOnShowFileList write
  24.      FOnShowFileList;
  25.   end;
  26.  
  27. procedure Register;
  28.  
  29. implementation
  30.  
  31. procedure TFileFilterListBox.ShowFileList;
  32. var Finished        : Boolean;         { Loop flag              }
  33.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  34.     TheResult       : Integer;         { return variable        }
  35. begin
  36.   if Assigned( FOnShowFileList ) then OnShowFileList( Self );
  37.   if TheMask = '' then exit;
  38.   Finished := false;
  39.   { Make needed call to FindFirst and discard '.' }
  40.   TheResult := FindFirst( TheMask , faAnyFile , TheSR );
  41.   while not Finished do
  42.   begin
  43.     { Loop through file again, this time getting only archive files }
  44.     TheResult := FindNext( TheSR );
  45.     { Result of -1 indicates no more files }
  46.     if TheResult < 0 then Finished := true else
  47.     begin
  48.       Items.Add( TheSR.Name );
  49.     end;
  50.   end;
  51.   Show;
  52. end;
  53.  
  54. procedure Register;
  55. begin
  56.   RegisterComponents('Widgets', [TFileFilterListBox]);
  57. end;
  58.  
  59. end.
  60.