1 | unit Main;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
|
---|
7 | CoolTrayIcon;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TMainForm = class(TForm)
|
---|
11 | CoolTrayIcon1: TCoolTrayIcon;
|
---|
12 | Label1: TLabel;
|
---|
13 | RadioGroup1: TRadioGroup;
|
---|
14 | Button1: TButton;
|
---|
15 | procedure FormCreate(Sender: TObject);
|
---|
16 | procedure CoolTrayIcon1Click(Sender: TObject);
|
---|
17 | procedure CoolTrayIcon1MinimizeToTray(Sender: TObject);
|
---|
18 | procedure Button1Click(Sender: TObject);
|
---|
19 | procedure RadioGroup1Click(Sender: TObject);
|
---|
20 | private
|
---|
21 | IsMinimized: Boolean;
|
---|
22 | procedure FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
|
---|
23 | procedure FadeWindow(Minimizing: Boolean);
|
---|
24 | procedure ImplodeWindow(Minimizing: Boolean);
|
---|
25 | procedure ImplodeOutlineWindow(Minimizing: Boolean);
|
---|
26 | public
|
---|
27 | StartX, StartY, StartW, StartH: Integer;
|
---|
28 | end;
|
---|
29 |
|
---|
30 | var
|
---|
31 | MainForm: TMainForm;
|
---|
32 |
|
---|
33 | implementation
|
---|
34 |
|
---|
35 | uses
|
---|
36 | TrayAnimation;
|
---|
37 |
|
---|
38 | {$R *.dfm}
|
---|
39 |
|
---|
40 | {--------------------- TMainForm ----------------------}
|
---|
41 |
|
---|
42 | procedure TMainForm.FormCreate(Sender: TObject);
|
---|
43 | begin
|
---|
44 | StartW := Width;
|
---|
45 | StartH := Height;
|
---|
46 | RadioGroup1Click(Self);
|
---|
47 | end;
|
---|
48 |
|
---|
49 |
|
---|
50 | procedure TMainForm.CoolTrayIcon1MinimizeToTray(Sender: TObject);
|
---|
51 | begin
|
---|
52 | case RadioGroup1.ItemIndex of
|
---|
53 | 1: FloatRectangles(True, True);
|
---|
54 | 2: FadeWindow(True);
|
---|
55 | 3: ImplodeWindow(True);
|
---|
56 | 4: ImplodeOutlineWindow(True);
|
---|
57 | end;
|
---|
58 | IsMinimized := True;
|
---|
59 | end;
|
---|
60 |
|
---|
61 |
|
---|
62 | procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
|
---|
63 | begin
|
---|
64 | if IsMinimized then
|
---|
65 | begin
|
---|
66 | case RadioGroup1.ItemIndex of
|
---|
67 | 1: begin
|
---|
68 | FloatRectangles(False, True);
|
---|
69 | CoolTrayIcon1.ShowMainForm;
|
---|
70 | end;
|
---|
71 | 2: begin
|
---|
72 | CoolTrayIcon1.ShowMainForm;
|
---|
73 | FadeWindow(False);
|
---|
74 | end;
|
---|
75 | 3: begin
|
---|
76 | CoolTrayIcon1.ShowMainForm;
|
---|
77 | ImplodeWindow(False);
|
---|
78 | end;
|
---|
79 | 4: begin
|
---|
80 | ImplodeOutlineWindow(False);
|
---|
81 | CoolTrayIcon1.ShowMainForm;
|
---|
82 | end;
|
---|
83 | else
|
---|
84 | CoolTrayIcon1.ShowMainForm;
|
---|
85 | end;
|
---|
86 | IsMinimized := False;
|
---|
87 | end;
|
---|
88 | end;
|
---|
89 |
|
---|
90 |
|
---|
91 | procedure TMainForm.FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
|
---|
92 | begin
|
---|
93 | FloatingRectangles(Minimizing, OverrideUserSettings);
|
---|
94 | end;
|
---|
95 |
|
---|
96 |
|
---|
97 | procedure TMainForm.FadeWindow(Minimizing: Boolean);
|
---|
98 | var
|
---|
99 | WindowFader: TWindowFader;
|
---|
100 | begin
|
---|
101 | WindowFader := TWindowFader.Create(False);
|
---|
102 | WindowFader.FadeOut := Minimizing;
|
---|
103 | WindowFader.Execute;
|
---|
104 | WindowFader.Free;
|
---|
105 | end;
|
---|
106 |
|
---|
107 |
|
---|
108 | procedure TMainForm.ImplodeWindow(Minimizing: Boolean);
|
---|
109 | var
|
---|
110 | WindowImploder: TWindowImploder;
|
---|
111 | begin
|
---|
112 | WindowImploder := TWindowImploder.Create(False);
|
---|
113 | WindowImploder.Imploding := Minimizing;
|
---|
114 | WindowImploder.Execute;
|
---|
115 | WindowImploder.Free;
|
---|
116 | end;
|
---|
117 |
|
---|
118 |
|
---|
119 | procedure TMainForm.ImplodeOutlineWindow(Minimizing: Boolean);
|
---|
120 | var
|
---|
121 | WindowOutlineImploder: TWindowOutlineImploder;
|
---|
122 | begin
|
---|
123 | WindowOutlineImploder := TWindowOutlineImploder.Create;
|
---|
124 | WindowOutlineImploder.Imploding := Minimizing;
|
---|
125 | WindowOutlineImploder.Execute;
|
---|
126 | WindowOutlineImploder.Free;
|
---|
127 | end;
|
---|
128 |
|
---|
129 |
|
---|
130 | procedure TMainForm.Button1Click(Sender: TObject);
|
---|
131 | begin
|
---|
132 | Close;
|
---|
133 | end;
|
---|
134 |
|
---|
135 |
|
---|
136 | procedure TMainForm.RadioGroup1Click(Sender: TObject);
|
---|
137 | begin
|
---|
138 | { We turn AlphaBlend on/off as needed because when AlphaBlend is true
|
---|
139 | the form flickers when it's resized. }
|
---|
140 | {$IFDEF DELPHI_6_UP}
|
---|
141 | if RadioGroup1.ItemIndex = 2 then
|
---|
142 | begin
|
---|
143 | AlphaBlend := True;
|
---|
144 | AlphaBlendValue := 255;
|
---|
145 | end
|
---|
146 | else
|
---|
147 | AlphaBlend := False;
|
---|
148 | {$ELSE}
|
---|
149 | if RadioGroup1.ItemIndex = 2 then
|
---|
150 | MessageDlg('Alpha-blend (fade) not supported in this Delphi version.',
|
---|
151 | mtInformation, [mbOk], 0);
|
---|
152 | {$ENDIF}
|
---|
153 | end;
|
---|
154 |
|
---|
155 | end.
|
---|
156 |
|
---|