home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Demos / FastNet / Uue / uuedem.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  4KB  |  118 lines

  1. ///////////////////////////////////////////////////////////////////////////
  2. //                                                                       //
  3. // Copyright ⌐ 1997-1998, NetMasters, L.L.C                              //
  4. //  - All rights reserved worldwide. -                                   //
  5. //  Portions may be Copyright ⌐ Inprise.                                 //
  6. //                                                                       //
  7. // UUEncode/Decode/MIME Demo Unit 1:  (UNIT1.PAS)                        //
  8. //                                                                       //
  9. // DESCRIPTION:                                                          //
  10. //                                                                       //
  11. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY //
  12. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE   //
  13. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR //
  14. // PURPOSE.                                                              //
  15. //                                                                       //
  16. ///////////////////////////////////////////////////////////////////////////
  17. //
  18. // Revision History
  19. //
  20. //                                                                       //
  21. ///////////////////////////////////////////////////////////////////////////
  22. unit uuedem;
  23.  
  24. interface
  25.  
  26. uses
  27.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  28.   NMUUE, StdCtrls, ComCtrls, Buttons;
  29.  
  30. type
  31.   TForm1 = class(TForm)
  32.     Edit1: TEdit;
  33.     Label1: TLabel;
  34.     NMUUE1: TNMUUProcessor;
  35.     Edit2: TEdit;
  36.     Label2: TLabel;
  37.     Button1: TButton;
  38.     GroupBox1: TGroupBox;
  39.     RadioButton1: TRadioButton;
  40.     RadioButton2: TRadioButton;
  41.     GroupBox2: TGroupBox;
  42.     RadioButton3: TRadioButton;
  43.     RadioButton4: TRadioButton;
  44.     StatusBar1: TStatusBar;
  45.     SpeedButton1: TSpeedButton;
  46.     OpenDialog1: TOpenDialog;
  47.     procedure Button1Click(Sender: TObject);
  48.     procedure NMUUE1BeginDecode(Sender: TObject);
  49.     procedure NMUUE1BeginEncode(Sender: TObject);
  50.     procedure NMUUE1EndDecode(Sender: TObject);
  51.     procedure NMUUE1EndEncode(Sender: TObject);
  52.     procedure SpeedButton1Click(Sender: TObject);
  53.   private
  54.     { Private declarations }
  55.   public
  56.     { Public declarations }
  57.   end;
  58.  
  59. var
  60.   Form1: TForm1;
  61.  
  62. implementation
  63.  
  64. {$R *.DFM}
  65.  
  66.  
  67. procedure TForm1.Button1Click(Sender: TObject);
  68. var
  69.   InStream,
  70.   OutStream: TFileStream;
  71. begin
  72.   InStream := TFileStream.Create(Edit1.Text, fmOpenRead);
  73.   OutStream := TFileStream.Create(Edit2.Text, fmCreate);
  74.   try
  75.     If RadioButton4.Checked then
  76.       NMUUE1.Method := uuMIME
  77.     else
  78.       NMUUE1.Method := uuCode;
  79.     NMUUE1.InputStream := InStream;
  80.     NMUUE1.OutputStream := OutStream;
  81.     If RadioButton1.Checked then
  82.       NMUUE1.Encode
  83.     else
  84.       NMUUE1.Decode;
  85.   finally
  86.     InStream.Free;
  87.     OutStream.Free;
  88.   end;
  89. end;
  90.  
  91. procedure TForm1.NMUUE1BeginDecode(Sender: TObject);
  92. begin
  93.   StatusBar1.SimpleText := 'Decoding stream'; 
  94. end;
  95.  
  96. procedure TForm1.NMUUE1BeginEncode(Sender: TObject);
  97. begin
  98.   StatusBar1.SimpleText := 'encoding stream';
  99. end;
  100.  
  101. procedure TForm1.NMUUE1EndDecode(Sender: TObject);
  102. begin
  103.   StatusBar1.SimpleText := 'Completed decoding stream';
  104. end;
  105.  
  106. procedure TForm1.NMUUE1EndEncode(Sender: TObject);
  107. begin
  108.   StatusBar1.SimpleText := 'Completed encoding stream';
  109. end;
  110.  
  111. procedure TForm1.SpeedButton1Click(Sender: TObject);
  112. begin
  113.   If OpenDialog1.Execute then
  114.     Edit1.Text := OpenDialog1.FileName;
  115. end;
  116.  
  117. end.
  118.