EncForm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit EncForm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, ExtCtrls;
  6. type
  7.   TFormEncode = class(TForm)
  8.     Memo1: TMemo;
  9.     Memo2: TMemo;
  10.     OpenDialog1: TOpenDialog;
  11.     SaveDialog1: TSaveDialog;
  12.     Panel1: TPanel;
  13.     BtnLoadPlain: TButton;
  14.     BtnSaveEncoded: TButton;
  15.     BtnLoadEncoded: TButton;
  16.     Splitter1: TSplitter;
  17.     procedure BtnSaveEncodedClick(Sender: TObject);
  18.     procedure BtnLoadEncodedClick(Sender: TObject);
  19.     procedure BtnLoadPlainClick(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25. var
  26.   FormEncode: TFormEncode;
  27. implementation
  28. {$R *.DFM}
  29. uses
  30.   EncodStr;
  31. procedure TFormEncode.BtnSaveEncodedClick(Sender: TObject);
  32. var
  33.   EncStr: TEncodedStream;
  34. begin
  35.   if SaveDialog1.Execute then
  36.   begin
  37.     EncStr := TEncodedStream.Create(
  38.       SaveDialog1.Filename, fmCreate);
  39.     try
  40.       Memo1.Lines.SaveToStream (EncStr);
  41.     finally
  42.       EncStr.Free;
  43.     end;
  44.   end;
  45. end;
  46. procedure TFormEncode.BtnLoadEncodedClick(Sender: TObject);
  47. var
  48.   EncStr: TEncodedStream;
  49. begin
  50.   if OpenDialog1.Execute then
  51.   begin
  52.     EncStr := TEncodedStream.Create(
  53.       OpenDialog1.FileName, fmOpenRead);
  54.     try
  55.       Memo2.Lines.LoadFromStream (EncStr);
  56.     finally
  57.       EncStr.Free;
  58.     end;
  59.   end;
  60. end;
  61. procedure TFormEncode.BtnLoadPlainClick(Sender: TObject);
  62. begin
  63.   if OpenDialog1.Execute then
  64.     Memo1.Lines.LoadFromFile (
  65.       OpenDialog1.FileName);
  66. end;
  67. end.