home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue62 / system / FrmMain.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2000-09-08  |  1.5 KB  |  70 lines

  1. unit FrmMain;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ComCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     FileCount: TLabel;
  13.     FileList: TListView;
  14.     OpenDialog: TOpenDialog;
  15.     procedure FormCreate(Sender: TObject);
  16.     procedure FormDestroy(Sender: TObject);
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.DFM}
  30.  
  31. uses CABFile;
  32.  
  33. var
  34.     cab: TCabinet;
  35.  
  36. procedure TForm1.FormCreate(Sender: TObject);
  37. begin
  38.     cab := TCabinet.Create (Self);
  39. end;
  40.  
  41. procedure TForm1.FormDestroy(Sender: TObject);
  42. begin
  43.     cab.Free;
  44. end;
  45.  
  46. procedure TForm1.Button1Click (Sender: TObject);
  47. var
  48.     Idx: Integer;
  49.     Item: TListItem;
  50. begin
  51.     if OpenDialog.Execute then begin
  52.         FileList.Items.Clear;
  53.         cab.CABFileName := OpenDialog.FileName;
  54.         FileCount.Caption := 'Files in CAB = ' + IntToStr (cab.FileCount);
  55.         FileList.Items.BeginUpdate;
  56.         try
  57.             for Idx := 0 to cab.FileCount - 1 do begin
  58.                 Item := FileList.Items.Add;
  59.                 Item.Caption := cab [Idx];
  60.                 Item.SubItems.Add (cab.FileSize [Idx]);
  61.                 Item.SubItems.Add (cab.FileDate [Idx]);
  62.             end;
  63.         finally
  64.             FileList.Items.EndUpdate;
  65.         end;
  66.     end;
  67. end;
  68.  
  69. end.
  70.