source: components/CoolTrayIcon/demos/TextTrayTest/TtMain.pas

Last change on this file was 1, checked in by maron, 16 years ago

3.1 verze, první revize

File size: 4.6 KB
Line 
1unit TtMain;
2
3interface
4
5uses
6 Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls,
7 ExtCtrls, ComCtrls, Menus, Graphics, CoolTrayIcon, TextTrayIcon;
8
9type
10 TMainForm = class(TForm)
11 Timer1: TTimer;
12 FontDialog1: TFontDialog;
13 ColorDialog1: TColorDialog;
14 Button1: TButton;
15 Button2: TButton;
16 Button3: TButton;
17 Button7: TButton;
18 GroupBox1: TGroupBox;
19 Label1: TLabel;
20 Edit1: TEdit;
21 CheckBox1: TCheckBox;
22 CheckBox2: TCheckBox;
23 Button4: TButton;
24 Button5: TButton;
25 Button6: TButton;
26 Label2: TLabel;
27 Edit2: TEdit;
28 UpDown2: TUpDown;
29 Label3: TLabel;
30 Edit3: TEdit;
31 UpDown3: TUpDown;
32 Label4: TLabel;
33 Edit4: TEdit;
34 UpDown4: TUpDown;
35 TrayIcon1: TTextTrayIcon;
36 procedure FormCreate(Sender: TObject);
37 procedure FormDestroy(Sender: TObject);
38 procedure Edit1Change(Sender: TObject);
39 procedure CheckBox1Click(Sender: TObject);
40 procedure CheckBox2Click(Sender: TObject);
41 procedure Button1Click(Sender: TObject);
42 procedure Button2Click(Sender: TObject);
43 procedure Button3Click(Sender: TObject);
44 procedure Button4Click(Sender: TObject);
45 procedure Button5Click(Sender: TObject);
46 procedure Button6Click(Sender: TObject);
47 procedure Button7Click(Sender: TObject);
48 procedure Timer1Timer(Sender: TObject);
49 procedure TrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
50 Shift: TShiftState; X, Y: Integer);
51 procedure Edit2Change(Sender: TObject);
52 procedure Edit3Change(Sender: TObject);
53 procedure Edit4Change(Sender: TObject);
54 private
55 TrayCounter: Integer;
56 LoopNumbers: Boolean;
57 BgIcon: TIcon;
58 end;
59
60var
61 MainForm: TMainForm;
62
63implementation
64
65{$R *.DFM}
66
67procedure TMainForm.FormCreate(Sender: TObject);
68begin
69 BgIcon := TIcon.Create;
70 BgIcon.Assign(TrayIcon1.BackgroundIcon);
71 Edit1Change(Self);
72 CheckBox1Click(Self);
73 CheckBox2Click(Self);
74 Edit2Change(Self);
75 Edit3Change(Self);
76 Edit4Change(Self);
77end;
78
79
80procedure TMainForm.FormDestroy(Sender: TObject);
81begin
82 BgIcon.Free;
83end;
84
85
86procedure TMainForm.Button7Click(Sender: TObject);
87begin
88 Close;
89end;
90
91
92procedure TMainForm.Timer1Timer(Sender: TObject);
93begin
94 if TrayCounter < 91 then
95 begin
96 if LoopNumbers then
97 Edit1.Text := IntToStr(TrayCounter-65)
98 else
99// Edit1.Text := Char(TrayCounter) + #13 + Char(TrayCounter+32);
100 Edit1.Text := Char(TrayCounter) + Char(TrayCounter) + #13 + Char(TrayCounter) + Char(TrayCounter);
101 Inc(TrayCounter);
102 end;
103 if TrayCounter = 91 then
104 TrayCounter := 65;
105end;
106
107
108procedure TMainForm.Button1Click(Sender: TObject);
109begin
110 // Loop numbers
111 LoopNumbers := True;
112 TrayCounter := 65;
113 Timer1.Enabled := True;
114end;
115
116
117procedure TMainForm.Button2Click(Sender: TObject);
118begin
119 // Loop characters
120 LoopNumbers := False;
121 TrayCounter := 65;
122 Timer1.Enabled := True;
123end;
124
125
126procedure TMainForm.Button3Click(Sender: TObject);
127begin
128 Timer1.Enabled := False;
129end;
130
131
132procedure TMainForm.Button4Click(Sender: TObject);
133begin
134 FontDialog1.Font.Assign(TrayIcon1.Font);
135 if FontDialog1.Execute then
136 TrayIcon1.Font.Assign(FontDialog1.Font);
137// Alternative: TrayIcon1.Font := FontDialog1.Font;
138end;
139
140
141procedure TMainForm.Button5Click(Sender: TObject);
142begin
143 ColorDialog1.Color := TrayIcon1.Color;
144 if ColorDialog1.Execute then
145 TrayIcon1.Color := ColorDialog1.Color;
146end;
147
148
149procedure TMainForm.Button6Click(Sender: TObject);
150begin
151 ColorDialog1.Color := TrayIcon1.BorderColor;
152 if ColorDialog1.Execute then
153 TrayIcon1.BorderColor := ColorDialog1.Color;
154end;
155
156
157procedure TMainForm.Edit1Change(Sender: TObject);
158begin
159 TrayIcon1.Text := Edit1.Text;
160end;
161
162
163procedure TMainForm.CheckBox1Click(Sender: TObject);
164begin
165 TrayIcon1.Border := CheckBox1.Checked;
166end;
167
168
169procedure TMainForm.CheckBox2Click(Sender: TObject);
170begin
171 if CheckBox2.Checked then
172 TrayIcon1.BackgroundIcon := BgIcon
173 else
174 TrayIcon1.BackgroundIcon := nil;
175end;
176
177
178procedure TMainForm.Edit2Change(Sender: TObject);
179begin
180 TrayIcon1.Options.OffsetX := StrToInt(Edit2.Text);
181end;
182
183
184procedure TMainForm.Edit3Change(Sender: TObject);
185begin
186 TrayIcon1.Options.OffsetY := StrToInt(Edit3.Text);
187end;
188
189
190procedure TMainForm.Edit4Change(Sender: TObject);
191begin
192 TrayIcon1.Options.LineDistance := StrToInt(Edit4.Text);
193end;
194
195
196procedure TMainForm.TrayIcon1MouseDown(Sender: TObject;
197 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
198begin
199// Timer1.Enabled := not Timer1.Enabled;
200end;
201
202end.
203
Note: See TracBrowser for help on using the repository browser.