⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 这是一套全面的网络组件
💻 PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    btnCompress: TButton;
    btnUncompress: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    edtSource: TEdit;
    btnSource: TButton;
    edtDestination: TEdit;
    btnDestination: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    clGZip1: TclGZip;
    ProgressBar1: TProgressBar;
    procedure clGZip1Progress(Sender: TObject; ABytesProceed,
      ATotalBytes: Integer);
    procedure btnSourceClick(Sender: TObject);
    procedure btnDestinationClick(Sender: TObject);
    procedure btnCompressClick(Sender: TObject);
    procedure btnUncompressClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.clGZip1Progress(Sender: TObject; ABytesProceed, ATotalBytes: Integer);
begin
  ProgressBar1.Max := ATotalBytes;
  ProgressBar1.Position := ABytesProceed;
end;

procedure TForm1.btnSourceClick(Sender: TObject);
begin
  if OpenDialog1.Execute() then
  begin
    edtSource.Text := OpenDialog1.FileName;
  end;
end;

procedure TForm1.btnDestinationClick(Sender: TObject);
begin
  if SaveDialog1.Execute() then
  begin
    edtDestination.Text := SaveDialog1.FileName;
  end;
end;

procedure TForm1.btnCompressClick(Sender: TObject);
begin
  clGZip1.Compress(edtSource.Text, edtDestination.Text);
  ShowMessage(Format('The file %s was deflated and stored to %s', [edtSource.Text, edtDestination.Text]));
end;

procedure TForm1.btnUncompressClick(Sender: TObject);
var
  source, dest: TStream;
begin
  source := TFileStream.Create(edtSource.Text, fmOpenRead);
  dest := TFileStream.Create(edtDestination.Text, fmCreate);
  try
    clGZip1.Uncompress(source, dest);
  finally
    dest.Free();
    source.Free();
  end;
  ShowMessage(Format('The file %s was inflated and stored to %s', [edtSource.Text, edtDestination.Text]));
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -