home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / unity / d23456 / SYNAPSE.ZIP / source / demo / mime / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2001-04-06  |  1.7 KB  |  87 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, mimemess, mimepart;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Edit1: TEdit;
  12.     Button1: TButton;
  13.     ListBox1: TListBox;
  14.     Label1: TLabel;
  15.     Memo1: TMemo;
  16.     Button2: TButton;
  17.     Label2: TLabel;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure FormDestroy(Sender: TObject);
  21.     procedure ListBox1Click(Sender: TObject);
  22.     procedure Button2Click(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     Mime:TMimemess;
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37. procedure TForm1.Button1Click(Sender: TObject);
  38. var
  39.   n:integer;
  40.   s:string;
  41. begin
  42.   mime.Clear;
  43.   listbox1.Clear;
  44.   memo1.Clear;
  45.   mime.Lines.LoadFromFile(edit1.text);
  46.   mime.DecodeMessage;
  47.   for n:=0 to mime.PartList.Count-1 do
  48.     begin
  49.       with TMimePart(mime.PartList[n]) do
  50.         begin
  51.           s:=format('%12s/%-12s %-15s %-s',[primary,secondary,filename,description]);
  52.         end;
  53.       listbox1.items.Add(s);
  54.     end;
  55. end;
  56.  
  57. procedure TForm1.FormCreate(Sender: TObject);
  58. begin
  59.   mime:=TMimemess.create;
  60. end;
  61.  
  62. procedure TForm1.FormDestroy(Sender: TObject);
  63. begin
  64.   mime.free;
  65. end;
  66.  
  67. procedure TForm1.ListBox1Click(Sender: TObject);
  68. begin
  69.   memo1.Lines.assign(TMimePart(mime.PartList[listbox1.itemindex]).Lines);
  70. end;
  71.  
  72. procedure TForm1.Button2Click(Sender: TObject);
  73. var
  74.   f:string;
  75. begin
  76.   with TMimePart(mime.PartList[listbox1.itemindex]) do
  77.     begin
  78.       f:=filename;
  79.       if f=''
  80.         then f:='mimedemo.txt';
  81.       f:='c:/'+f;
  82.       decodedlines.SaveToFile(f);
  83.     end;
  84. end;
  85.  
  86. end.
  87.