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

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

3.1 verze, první revize

File size: 2.2 KB
Line 
1unit Main;
2
3interface
4
5uses
6 Windows, Classes, Controls, Forms, StdCtrls, CoolTrayIcon;
7
8type
9 TMainForm = class(TForm)
10 CoolTrayIcon1: TCoolTrayIcon;
11 CheckBox1: TCheckBox;
12 Label1: TLabel;
13 Button1: TButton;
14 Label2: TLabel;
15 Label3: TLabel;
16 procedure CheckBox1Click(Sender: TObject);
17 procedure CoolTrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
18 Shift: TShiftState; X, Y: Integer);
19 procedure CoolTrayIcon1Startup(Sender: TObject; var ShowMainForm: Boolean);
20 procedure Button1Click(Sender: TObject);
21 private
22 function LoadSetting(Key, Item: String; DefValue: Boolean): Boolean;
23 procedure SaveSetting(Key, Item: String; Value: Boolean);
24 procedure RemoveSetting(Key: String);
25 end;
26
27var
28 MainForm: TMainForm;
29
30implementation
31
32{$R *.dfm}
33
34uses
35 Registry;
36
37const
38 StartHiddenKey = 'Software\CoolTrayIcon\StartHiddenDemo';
39
40
41function TMainForm.LoadSetting(Key, Item: String; DefValue: Boolean): Boolean;
42var
43 Reg: TRegIniFile;
44begin
45 Reg := TRegIniFile.Create(Key);
46 Result := Reg.ReadBool('', Item, DefValue);
47 Reg.Free;
48end;
49
50
51procedure TMainForm.SaveSetting(Key, Item: String; Value: Boolean);
52var
53 Reg: TRegIniFile;
54begin
55 Reg := TRegIniFile.Create(Key);
56 Reg.WriteBool('', Item, Value);
57 Reg.Free;
58end;
59
60
61procedure TMainForm.RemoveSetting(Key: String);
62var
63 Reg: TRegIniFile;
64begin
65 Reg := TRegIniFile.Create(Key);
66 Reg.EraseSection('');
67 Reg.Free;
68end;
69
70
71procedure TMainForm.CheckBox1Click(Sender: TObject);
72begin
73 if CheckBox1.Checked then
74 SaveSetting(StartHiddenKey, 'StartHidden', True)
75 else
76 RemoveSetting(StartHiddenKey);
77end;
78
79
80procedure TMainForm.CoolTrayIcon1MouseDown(Sender: TObject;
81 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
82begin
83 CoolTrayIcon1.ShowMainForm;
84end;
85
86
87procedure TMainForm.CoolTrayIcon1Startup(Sender: TObject; var ShowMainForm: Boolean);
88var
89 StartHidden: Boolean;
90begin
91 StartHidden := LoadSetting(StartHiddenKey, 'StartHidden', False);
92 CheckBox1.Checked := StartHidden;
93 ShowMainForm := not StartHidden;
94end;
95
96
97procedure TMainForm.Button1Click(Sender: TObject);
98begin
99 Close;
100end;
101
102end.
103
Note: See TracBrowser for help on using the repository browser.