source: components/CoolTrayIcon/demos/MinimizeAnimation/Main.pas

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

3.1 verze, první revize

File size: 3.5 KB
Line 
1unit Main;
2
3interface
4
5uses
6 Windows, Messages, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
7 CoolTrayIcon;
8
9type
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
30var
31 MainForm: TMainForm;
32
33implementation
34
35uses
36 TrayAnimation;
37
38{$R *.dfm}
39
40{--------------------- TMainForm ----------------------}
41
42procedure TMainForm.FormCreate(Sender: TObject);
43begin
44 StartW := Width;
45 StartH := Height;
46 RadioGroup1Click(Self);
47end;
48
49
50procedure TMainForm.CoolTrayIcon1MinimizeToTray(Sender: TObject);
51begin
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;
59end;
60
61
62procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
63begin
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;
88end;
89
90
91procedure TMainForm.FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
92begin
93 FloatingRectangles(Minimizing, OverrideUserSettings);
94end;
95
96
97procedure TMainForm.FadeWindow(Minimizing: Boolean);
98var
99 WindowFader: TWindowFader;
100begin
101 WindowFader := TWindowFader.Create(False);
102 WindowFader.FadeOut := Minimizing;
103 WindowFader.Execute;
104 WindowFader.Free;
105end;
106
107
108procedure TMainForm.ImplodeWindow(Minimizing: Boolean);
109var
110 WindowImploder: TWindowImploder;
111begin
112 WindowImploder := TWindowImploder.Create(False);
113 WindowImploder.Imploding := Minimizing;
114 WindowImploder.Execute;
115 WindowImploder.Free;
116end;
117
118
119procedure TMainForm.ImplodeOutlineWindow(Minimizing: Boolean);
120var
121 WindowOutlineImploder: TWindowOutlineImploder;
122begin
123 WindowOutlineImploder := TWindowOutlineImploder.Create;
124 WindowOutlineImploder.Imploding := Minimizing;
125 WindowOutlineImploder.Execute;
126 WindowOutlineImploder.Free;
127end;
128
129
130procedure TMainForm.Button1Click(Sender: TObject);
131begin
132 Close;
133end;
134
135
136procedure TMainForm.RadioGroup1Click(Sender: TObject);
137begin
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}
153end;
154
155end.
156
Note: See TracBrowser for help on using the repository browser.