source: trunk/Packages/synapse/source/demo/mime/Unit1.pas

Last change on this file was 2, checked in by chronos, 12 years ago
  • Přidáno: Základní kostra projektu.
  • Přidáno: Knihovna synapse.
File size: 2.1 KB
Line 
1unit Unit1;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, mimemess, mimepart, ComCtrls;
8
9type
10 TForm1 = class(TForm)
11 Edit1: TEdit;
12 Button1: TButton;
13 Label1: TLabel;
14 Memo1: TMemo;
15 Button2: TButton;
16 Label2: TLabel;
17 TreeView1: TTreeView;
18 procedure Button1Click(Sender: TObject);
19 procedure FormCreate(Sender: TObject);
20 procedure FormDestroy(Sender: TObject);
21 procedure Button2Click(Sender: TObject);
22 procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
23 private
24 { Private declarations }
25 procedure AddMimeNode(const parent: TTreeNode; const part: TMimepart);
26 public
27 Mime:TMimemess;
28 { Public declarations }
29 end;
30
31var
32 Form1: TForm1;
33
34implementation
35
36{$R *.DFM}
37
38procedure TForm1.AddMimeNode(const parent: TTreeNode; const part: TMimepart);
39var
40 s: string;
41 node: TTreeNode;
42 n: integer;
43begin
44 s := format('%-24s %-15s %-s',[part.primary + '/' + part.secondary,part.filename,part.description]);
45 node := TreeView1.Items.AddChild(parent, s);
46 node.Data := part;
47 for n := 0 to part.GetSubPartCount - 1 do
48 AddMimeNode(node, part.getsubpart(n));
49end;
50
51procedure TForm1.Button1Click(Sender: TObject);
52var
53 n:integer;
54 s:string;
55begin
56 mime.Clear;
57 memo1.Clear;
58 mime.Lines.LoadFromFile(edit1.text);
59 mime.DecodeMessage;
60 ShowMessage(datetimetostr(mime.Header.Date));
61
62 Treeview1.Items.Clear;
63 AddMimeNode(nil, mime.MessagePart);
64 Treeview1.FullExpand;
65end;
66
67procedure TForm1.FormCreate(Sender: TObject);
68begin
69 mime:=TMimemess.create;
70end;
71
72procedure TForm1.FormDestroy(Sender: TObject);
73begin
74 mime.free;
75end;
76
77procedure TForm1.Button2Click(Sender: TObject);
78var
79 f:string;
80begin
81 with TMimePart(Treeview1.Selected.data) do
82 begin
83 f:=filename;
84 if f=''
85 then f:='mimedemo.txt';
86 f:='c:/'+f;
87 Decodepart;
88 decodedlines.SaveToFile(f);
89 end;
90end;
91
92procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
93begin
94 memo1.Lines.assign(TMimepart(Node.Data).Lines);
95end;
96
97end.
Note: See TracBrowser for help on using the repository browser.