├── CoolTrayIcon.chm
├── CoolTrayTest.exe
├── Source
├── CoolTrayIcon.dcr
├── TextTrayIcon.dcr
├── SimpleTimer.pas
├── CoolTrayIcon.inc
└── TextTrayIcon.pas
├── Delphi
├── CoolTrayIcon_D12.res
├── CoolTrayIcon_D14.res
├── CoolTrayIcon_D15.res
├── CoolTrayIcon_XE10.res
├── CoolTrayIcon_XE2.res
├── CoolTrayIcon_XE3.res
├── bds5
│ ├── CoolTrayIcon_Design.res
│ └── CoolTrayIcon_Design.dpk
├── CoolTrayIcon_D5.dpk
├── CoolTrayIcon_D6plus.dpk
├── CoolTrayIcon_D12.dpk
├── CoolTrayIcon_D14.dpk
├── CoolTrayIcon_D15.dpk
├── CoolTrayIcon_XE10.dpk
├── CoolTrayIcon_XE2.dpk
├── CoolTrayIcon_XE3.dpk
└── CoolTrayIcon_XE6.dpk
├── demos
├── CustomHint2
│ ├── images.res
│ ├── BigHintDemo.res
│ ├── BigHintDemo.dpr
│ ├── BigHint.dfm
│ └── BigHint.pas
├── StartHidden
│ ├── Main.dfm
│ ├── StartHidden.res
│ ├── StartHidden.dpr
│ └── Main.pas
├── TrayDraw
│ ├── TrayDraw.ico
│ ├── TrayDraw.res
│ ├── TrayDraw.dpr
│ ├── CtDraw.dfm
│ └── CtDraw.pas
├── CoolTrayTest
│ ├── CtMain.dcu
│ ├── CtMain.dfm
│ ├── TrayIcon.ico
│ ├── CoolTrayTest.res
│ ├── CoolTrayTest.dpr
│ └── CtMain.pas
├── TextTrayTest
│ ├── TtMain.dfm
│ ├── bubble.ico
│ ├── TrayText.ico
│ ├── TextTrayTest.res
│ ├── TextTrayTest.dpr
│ └── TtMain.pas
├── CoolService
│ ├── CoolService.res
│ ├── readme.txt
│ ├── CoolService.dpr
│ ├── CoolTrayService.bat
│ ├── Service.dfm
│ └── Service.pas
├── CustomHint1
│ ├── CustomHint.res
│ ├── CustomHint.dpr
│ ├── Main.dfm
│ └── Main.pas
├── MinimizeAnimation
│ ├── Main.dfm
│ ├── animation.ico
│ ├── MinimizeAnimation.res
│ ├── MinimizeAnimation.dpr
│ ├── readme.txt
│ ├── Main.pas
│ └── TrayAnimation.pas
├── demo.groupproj
└── demo.dsk
├── docs
├── History - CoolTrayIcon.txt
├── convert_st_projects.txt
├── History - TextTrayIcon.txt
├── convert_cti_projects.txt
├── History - SimpleTimer.txt
├── SimpleTimer.html
├── TextTrayIcon.html
└── CoolTrayIcon.html
├── readme.txt
├── demos.txt
├── Design
└── RegisterTrayIcons.pas
└── install.txt
/CoolTrayIcon.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/CoolTrayIcon.chm
--------------------------------------------------------------------------------
/CoolTrayTest.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/CoolTrayTest.exe
--------------------------------------------------------------------------------
/Source/CoolTrayIcon.dcr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Source/CoolTrayIcon.dcr
--------------------------------------------------------------------------------
/Source/TextTrayIcon.dcr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Source/TextTrayIcon.dcr
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D12.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/CoolTrayIcon_D12.res
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D14.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/CoolTrayIcon_D14.res
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D15.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/CoolTrayIcon_D15.res
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE10.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/CoolTrayIcon_XE10.res
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE2.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/CoolTrayIcon_XE2.res
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE3.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/CoolTrayIcon_XE3.res
--------------------------------------------------------------------------------
/demos/CustomHint2/images.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CustomHint2/images.res
--------------------------------------------------------------------------------
/demos/StartHidden/Main.dfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/StartHidden/Main.dfm
--------------------------------------------------------------------------------
/demos/TrayDraw/TrayDraw.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/TrayDraw/TrayDraw.ico
--------------------------------------------------------------------------------
/demos/TrayDraw/TrayDraw.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/TrayDraw/TrayDraw.res
--------------------------------------------------------------------------------
/demos/CoolTrayTest/CtMain.dcu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CoolTrayTest/CtMain.dcu
--------------------------------------------------------------------------------
/demos/CoolTrayTest/CtMain.dfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CoolTrayTest/CtMain.dfm
--------------------------------------------------------------------------------
/demos/TextTrayTest/TtMain.dfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/TextTrayTest/TtMain.dfm
--------------------------------------------------------------------------------
/demos/TextTrayTest/bubble.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/TextTrayTest/bubble.ico
--------------------------------------------------------------------------------
/demos/CoolService/CoolService.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CoolService/CoolService.res
--------------------------------------------------------------------------------
/demos/CoolTrayTest/TrayIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CoolTrayTest/TrayIcon.ico
--------------------------------------------------------------------------------
/demos/CustomHint1/CustomHint.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CustomHint1/CustomHint.res
--------------------------------------------------------------------------------
/demos/CustomHint2/BigHintDemo.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CustomHint2/BigHintDemo.res
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/Main.dfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/MinimizeAnimation/Main.dfm
--------------------------------------------------------------------------------
/demos/StartHidden/StartHidden.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/StartHidden/StartHidden.res
--------------------------------------------------------------------------------
/demos/TextTrayTest/TrayText.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/TextTrayTest/TrayText.ico
--------------------------------------------------------------------------------
/docs/History - CoolTrayIcon.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/docs/History - CoolTrayIcon.txt
--------------------------------------------------------------------------------
/Delphi/bds5/CoolTrayIcon_Design.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/Delphi/bds5/CoolTrayIcon_Design.res
--------------------------------------------------------------------------------
/demos/CoolTrayTest/CoolTrayTest.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/CoolTrayTest/CoolTrayTest.res
--------------------------------------------------------------------------------
/demos/TextTrayTest/TextTrayTest.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/TextTrayTest/TextTrayTest.res
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/animation.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/MinimizeAnimation/animation.ico
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/MinimizeAnimation.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coolshou/CoolTrayIcon/HEAD/demos/MinimizeAnimation/MinimizeAnimation.res
--------------------------------------------------------------------------------
/demos/CoolService/readme.txt:
--------------------------------------------------------------------------------
1 | CoolService demo
2 | ----------------
3 |
4 | Use CoolTrayService.bat to register and start the service.
5 | You need to change the path of SERVICEPATH to this folder.
6 |
7 |
--------------------------------------------------------------------------------
/demos/CustomHint2/BigHintDemo.dpr:
--------------------------------------------------------------------------------
1 | program BigHintDemo;
2 |
3 | uses
4 | Forms,
5 | BigHint in 'BigHint.pas' {Form1};
6 |
7 | {$R *.res}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.CreateForm(TForm1, Form1);
12 | Application.Run;
13 | end.
14 |
--------------------------------------------------------------------------------
/demos/CoolService/CoolService.dpr:
--------------------------------------------------------------------------------
1 | program CoolService;
2 |
3 | uses
4 | SvcMgr,
5 | Service in 'Service.pas' {CoolTrayService: TService};
6 |
7 | {$R *.RES}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.CreateForm(TCoolTrayService, CoolTrayService);
12 | Application.Run;
13 | end.
14 |
--------------------------------------------------------------------------------
/demos/CustomHint1/CustomHint.dpr:
--------------------------------------------------------------------------------
1 | program CustomHint;
2 |
3 | uses
4 | Forms,
5 | Main in 'Main.pas' {Form1};
6 |
7 | {$R *.RES}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.Title := 'Custom Tooltip';
12 | Application.CreateForm(TForm1, Form1);
13 | Application.Run;
14 | end.
15 |
16 |
--------------------------------------------------------------------------------
/demos/StartHidden/StartHidden.dpr:
--------------------------------------------------------------------------------
1 | program StartHidden;
2 |
3 | uses
4 | Forms,
5 | Main in 'Main.pas' {MainForm};
6 |
7 | {$R *.res}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.Title := 'Start Hidden?';
12 | Application.CreateForm(TMainForm, MainForm);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/demos/TrayDraw/TrayDraw.dpr:
--------------------------------------------------------------------------------
1 | program TrayDraw;
2 |
3 | uses
4 | Forms,
5 | CtDraw in 'CtDraw.pas' {DrawForm};
6 |
7 | {$R *.RES}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.Title := 'CoolTrayIcon Drawing Demo';
12 | Application.CreateForm(TDrawForm, DrawForm);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/demos/CoolTrayTest/CoolTrayTest.dpr:
--------------------------------------------------------------------------------
1 | program CoolTrayTest;
2 |
3 | uses
4 | Forms,
5 | CtMain in 'CtMain.pas' {MainForm};
6 |
7 | {$R *.RES}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.Title := 'CoolTrayIcon Demo';
12 | Application.CreateForm(TMainForm, MainForm);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/demos/TextTrayTest/TextTrayTest.dpr:
--------------------------------------------------------------------------------
1 | program TextTrayTest;
2 |
3 | uses
4 | Forms,
5 | TtMain in 'TtMain.pas' {MainForm};
6 |
7 | {$R *.RES}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.Title := 'TextTrayIcon Demo';
12 | Application.CreateForm(TMainForm, MainForm);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/MinimizeAnimation.dpr:
--------------------------------------------------------------------------------
1 | program MinimizeAnimation;
2 |
3 | uses
4 | Forms,
5 | Main in 'Main.pas' {MainForm},
6 | TrayAnimation in 'TrayAnimation.pas';
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.Title := 'Animation effects';
13 | Application.CreateForm(TMainForm, MainForm);
14 | Application.Run;
15 | end.
16 |
--------------------------------------------------------------------------------
/demos/CoolService/CoolTrayService.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | rem This batch file (re)installs the CoolTrayService, then starts it.
4 |
5 | rem Change this path:
6 | set SERVICEPATH=C:\Troels\Delphi\TrayIconTest\CoolService
7 |
8 | %SERVICEPATH%\CoolService.exe /uninstall /silent
9 | %SERVICEPATH%\CoolService.exe /install /silent
10 | net start CoolTrayService
11 |
12 | rem Start the Service Manager
13 | rem %SystemRoot%\system32\services.msc /s
14 |
15 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | This zip-file contains the two Delphi components, CoolTrayIcon and
2 | TextTrayIcon (tray icon components).
3 |
4 | Refer to CoolTrayIcon.chm and install.txt for documentation.
5 |
6 | See also convert_cti_projects.txt if you're upgrading from a previous version
7 | of CoolTrayIcon/TextTrayIcon.
8 |
9 | ***** If you redistribute this package, please include all original files. *****
10 |
11 | Original: http://subsimple.com/delphi.php
12 | http://www.songbeamer.com/delphi/
13 |
--------------------------------------------------------------------------------
/docs/convert_st_projects.txt:
--------------------------------------------------------------------------------
1 | Version 2.0.0 of SimpleTimer is incompatible with older versions, which
2 | means you will have to adjust your previous projects that use SimpleTimer.
3 |
4 |
5 | 1) The Start and Stop methods have been replaced with the Enabled and Interval
6 | properties, to make SimpleTimer more interchangeable with TTimer.
7 |
8 | To start the timer you will need to first set the Interval, then set Enabled
9 | to True (just like TTimer). Also, you must specify an OnTimer event method
10 | (see below).
11 |
12 |
13 | 2) The callback method you used for receiving notifications from a SimpleTimer
14 | object has been replaced by an OnTimer event. This both makes SimpleTimer
15 | easier to use and makes it look more like TTimer.
16 |
17 |
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/readme.txt:
--------------------------------------------------------------------------------
1 | MinimizeAnimation demo
2 | ----------------------
3 |
4 | This demo demonstrates the use of CoolTrayIcon's OnMinimizeToTray event,
5 | using animation effects.
6 |
7 | The effects are provided as a proof of concept, and I'm well aware some of them
8 | (like the "Implode outline" effect) have bugs.
9 |
10 | If you find a way to improve the effects or even develop new ones, send your
11 | code to me, and I'll include it in future versions of CoolTrayIcon.
12 |
13 | If you feel like including similar animation effects in your application,
14 | remember the simple guideline for good design: Less is more. Animation effects
15 | are most often useless, and some people tend to get annoyed at them in the
16 | long run. Use animation and sound sparingly. Windows is bad enough as it is.
17 |
18 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D5.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_D5;
2 |
3 | {$R *.RES}
4 | {$R 'CoolTrayIcon.dcr'}
5 | {$R 'TextTrayIcon.dcr'}
6 | {$ALIGN ON}
7 | {$ASSERTIONS ON}
8 | {$BOOLEVAL OFF}
9 | {$DEBUGINFO ON}
10 | {$EXTENDEDSYNTAX ON}
11 | {$IMPORTEDDATA ON}
12 | {$IOCHECKS ON}
13 | {$LOCALSYMBOLS ON}
14 | {$LONGSTRINGS ON}
15 | {$OPENSTRINGS ON}
16 | {$OPTIMIZATION ON}
17 | {$OVERFLOWCHECKS OFF}
18 | {$RANGECHECKS OFF}
19 | {$REFERENCEINFO ON}
20 | {$SAFEDIVIDE OFF}
21 | {$STACKFRAMES OFF}
22 | {$TYPEDADDRESS OFF}
23 | {$VARSTRINGCHECKS ON}
24 | {$WRITEABLECONST OFF}
25 | {$MINENUMSIZE 1}
26 | {$IMAGEBASE $400000}
27 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
28 | {$IMPLICITBUILD OFF}
29 |
30 | requires
31 | VCL50;
32 |
33 | contains
34 | SimpleTimer in 'SimpleTimer.pas',
35 | TextTrayIcon in 'TextTrayIcon.pas',
36 | CoolTrayIcon in 'CoolTrayIcon.pas',
37 | RegisterTrayIcons in 'RegisterTrayIcons.pas';
38 |
39 | end.
40 |
41 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D6plus.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_D6plus;
2 |
3 | {$R *.res}
4 | {$R 'CoolTrayIcon.dcr'}
5 | {$R 'TextTrayIcon.dcr'}
6 | {$ALIGN 8}
7 | {$ASSERTIONS ON}
8 | {$BOOLEVAL OFF}
9 | {$DEBUGINFO ON}
10 | {$EXTENDEDSYNTAX ON}
11 | {$IMPORTEDDATA ON}
12 | {$IOCHECKS ON}
13 | {$LOCALSYMBOLS ON}
14 | {$LONGSTRINGS ON}
15 | {$OPENSTRINGS ON}
16 | {$OPTIMIZATION ON}
17 | {$OVERFLOWCHECKS OFF}
18 | {$RANGECHECKS OFF}
19 | {$REFERENCEINFO ON}
20 | {$SAFEDIVIDE OFF}
21 | {$STACKFRAMES OFF}
22 | {$TYPEDADDRESS OFF}
23 | {$VARSTRINGCHECKS ON}
24 | {$WRITEABLECONST OFF}
25 | {$MINENUMSIZE 1}
26 | {$IMAGEBASE $400000}
27 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
28 | {$IMPLICITBUILD OFF}
29 |
30 | requires
31 | rtl,
32 | vcl;
33 |
34 | contains
35 | SimpleTimer in 'SimpleTimer.pas',
36 | TextTrayIcon in 'TextTrayIcon.pas',
37 | CoolTrayIcon in 'CoolTrayIcon.pas',
38 | RegisterTrayIcons in 'RegisterTrayIcons.pas';
39 |
40 | end.
41 |
42 |
--------------------------------------------------------------------------------
/docs/History - TextTrayIcon.txt:
--------------------------------------------------------------------------------
1 | TextTrayIcon, ver. 1.2.1
2 |
3 |
4 | - ver. 1.2.1: Bugfix: The background icon was not freed when TextTrayIcon
5 | was destroyed.
6 |
7 | - ver. 1.2.0: A big thanks to Jouni Airaksinen, who suggested
8 | improvements to the drawing/painting methods. The background
9 | icon should now display with the correct colors.
10 |
11 | - ver. 1.1.1: Some internal class-level handling is introduced as a
12 | result of updating the parent component CoolTrayIcon. Updated the
13 | documentation.
14 |
15 | - ver. 1.1.0: A background icon is introduced. Property ShowTextIcon
16 | is discarded.
17 |
18 | - ver. 1.0.0: First release. TextTrayIcon is distributed together
19 | with the CoolTrayIcon component (ver. 3.0.0). Some of the code
20 | was inspired by an example Robert Price sent me.
21 |
22 |
23 |
24 | If you have any comments or corrections, I would very much like to
25 | hear them.
26 |
27 | Troels Jakobsen
28 | troels.jakobsen@gmail.com
29 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D12.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_D12;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$ALIGN 8}
7 | {$ASSERTIONS ON}
8 | {$BOOLEVAL OFF}
9 | {$DEBUGINFO OFF}
10 | {$EXTENDEDSYNTAX ON}
11 | {$IMPORTEDDATA ON}
12 | {$IOCHECKS ON}
13 | {$LOCALSYMBOLS OFF}
14 | {$LONGSTRINGS ON}
15 | {$OPENSTRINGS ON}
16 | {$OPTIMIZATION ON}
17 | {$OVERFLOWCHECKS OFF}
18 | {$RANGECHECKS OFF}
19 | {$REFERENCEINFO OFF}
20 | {$SAFEDIVIDE OFF}
21 | {$STACKFRAMES OFF}
22 | {$TYPEDADDRESS OFF}
23 | {$VARSTRINGCHECKS ON}
24 | {$WRITEABLECONST OFF}
25 | {$MINENUMSIZE 1}
26 | {$IMAGEBASE $400000}
27 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
28 | {$IMPLICITBUILD OFF}
29 | {$DEFINE RELEASE}
30 |
31 | requires
32 | rtl,
33 | vcl;
34 |
35 | contains
36 | SimpleTimer in '..\source\SimpleTimer.pas',
37 | TextTrayIcon in '..\source\TextTrayIcon.pas',
38 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
39 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
40 |
41 | end.
42 |
43 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D14.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_D14;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$ALIGN 8}
7 | {$ASSERTIONS ON}
8 | {$BOOLEVAL OFF}
9 | {$DEBUGINFO OFF}
10 | {$EXTENDEDSYNTAX ON}
11 | {$IMPORTEDDATA ON}
12 | {$IOCHECKS ON}
13 | {$LOCALSYMBOLS OFF}
14 | {$LONGSTRINGS ON}
15 | {$OPENSTRINGS ON}
16 | {$OPTIMIZATION ON}
17 | {$OVERFLOWCHECKS OFF}
18 | {$RANGECHECKS OFF}
19 | {$REFERENCEINFO OFF}
20 | {$SAFEDIVIDE OFF}
21 | {$STACKFRAMES OFF}
22 | {$TYPEDADDRESS OFF}
23 | {$VARSTRINGCHECKS ON}
24 | {$WRITEABLECONST OFF}
25 | {$MINENUMSIZE 1}
26 | {$IMAGEBASE $400000}
27 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
28 | {$IMPLICITBUILD OFF}
29 | {$DEFINE RELEASE}
30 |
31 | requires
32 | rtl,
33 | vcl;
34 |
35 | contains
36 | SimpleTimer in '..\source\SimpleTimer.pas',
37 | TextTrayIcon in '..\source\TextTrayIcon.pas',
38 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
39 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
40 |
41 | end.
42 |
43 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_D15.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_D15;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$ALIGN 8}
7 | {$ASSERTIONS ON}
8 | {$BOOLEVAL OFF}
9 | {$DEBUGINFO OFF}
10 | {$EXTENDEDSYNTAX ON}
11 | {$IMPORTEDDATA ON}
12 | {$IOCHECKS ON}
13 | {$LOCALSYMBOLS OFF}
14 | {$LONGSTRINGS ON}
15 | {$OPENSTRINGS ON}
16 | {$OPTIMIZATION ON}
17 | {$OVERFLOWCHECKS OFF}
18 | {$RANGECHECKS OFF}
19 | {$REFERENCEINFO OFF}
20 | {$SAFEDIVIDE OFF}
21 | {$STACKFRAMES OFF}
22 | {$TYPEDADDRESS OFF}
23 | {$VARSTRINGCHECKS ON}
24 | {$WRITEABLECONST OFF}
25 | {$MINENUMSIZE 1}
26 | {$IMAGEBASE $400000}
27 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
28 | {$IMPLICITBUILD OFF}
29 | {$DEFINE RELEASE}
30 |
31 | requires
32 | rtl,
33 | vcl;
34 |
35 | contains
36 | SimpleTimer in '..\source\SimpleTimer.pas',
37 | TextTrayIcon in '..\source\TextTrayIcon.pas',
38 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
39 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
40 |
41 | end.
42 |
43 |
--------------------------------------------------------------------------------
/Delphi/bds5/CoolTrayIcon_Design.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_Design;
2 |
3 | {$R *.res}
4 | {$R '..\..\source\CoolTrayIcon.dcr'}
5 | {$R '..\..\source\TextTrayIcon.dcr'}
6 | {$ALIGN 8}
7 | {$ASSERTIONS ON}
8 | {$BOOLEVAL OFF}
9 | {$DEBUGINFO OFF}
10 | {$EXTENDEDSYNTAX ON}
11 | {$IMPORTEDDATA ON}
12 | {$IOCHECKS ON}
13 | {$LOCALSYMBOLS OFF}
14 | {$LONGSTRINGS ON}
15 | {$OPENSTRINGS ON}
16 | {$OPTIMIZATION ON}
17 | {$OVERFLOWCHECKS OFF}
18 | {$RANGECHECKS OFF}
19 | {$REFERENCEINFO OFF}
20 | {$SAFEDIVIDE OFF}
21 | {$STACKFRAMES OFF}
22 | {$TYPEDADDRESS OFF}
23 | {$VARSTRINGCHECKS ON}
24 | {$WRITEABLECONST OFF}
25 | {$MINENUMSIZE 1}
26 | {$IMAGEBASE $400000}
27 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
28 | {$IMPLICITBUILD OFF}
29 | {$DEFINE RELEASE}
30 |
31 | requires
32 | rtl,
33 | vcl;
34 |
35 | contains
36 | SimpleTimer in '..\..\source\SimpleTimer.pas',
37 | TextTrayIcon in '..\..\source\TextTrayIcon.pas',
38 | CoolTrayIcon in '..\..\source\CoolTrayIcon.pas',
39 | RegisterTrayIcons in '..\..\Design\RegisterTrayIcons.pas';
40 |
41 | end.
42 |
43 |
--------------------------------------------------------------------------------
/demos.txt:
--------------------------------------------------------------------------------
1 | CoolTrayIcon demos
2 |
3 | The following demos are distributed with CoolTrayIcon:
4 |
5 | * CoolTrayTest - Main demo of CoolTrayIcon features
6 | * TextTrayTest - Main demo of TextTrayIcon features
7 | * StartHidden - How to determine at runtime if your app. should start visible or not
8 | * CoolService - A simple interactive service using CoolTrayIcon
9 | * TrayDraw - A demo of the CoolTrayIcon.BitmapToIcon method
10 | * CustomHint1 - Modifying the common tray icon tooltip, changing the font and colors
11 | * CustomHint2 - Replacing the tray icon tooltip with your own custom tooltip
12 | * MinimizeAnimation - Animation effect when user minimizes a form
13 |
14 |
15 | CustomHint1 was more or less a port of a VB project by Eduardo A. Morcillo
16 | (http://www.domaindlx.com/e_morcillo).
17 | CustomHint2 was made by Zeljko Avramovic and modified by me.
18 | All other demos were made by me.
19 |
20 | If you have a cool demo demonstrating how to accomplish a task with CoolTrayIcon
21 | or TextTrayIcon, send it to me.
22 |
--------------------------------------------------------------------------------
/Design/RegisterTrayIcons.pas:
--------------------------------------------------------------------------------
1 | {*****************************************************************}
2 | { The CoolTrayIcon and TextTrayIcon components are freeware. }
3 | { }
4 | { Feel free to use and improve them. I would be pleased to hear }
5 | { what you think. }
6 | { }
7 | { Troels Jakobsen - troels.jakobsen@gmail.com }
8 | { Copyright (c) 2006 }
9 | { }
10 | { This unit by Jouni Airaksinen - mintus@codefield.com }
11 | {*****************************************************************}
12 |
13 | unit RegisterTrayIcons;
14 |
15 | interface
16 |
17 | procedure Register;
18 |
19 | implementation
20 |
21 | uses
22 | Classes, CoolTrayIcon, TextTrayIcon;
23 |
24 | procedure Register;
25 | begin
26 | RegisterComponents('Tray Icons', [TCoolTrayIcon, TTextTrayIcon]);
27 | end;
28 |
29 | end.
30 |
31 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE10.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_XE10;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
7 | {$ALIGN 8}
8 | {$ASSERTIONS ON}
9 | {$BOOLEVAL OFF}
10 | {$DEBUGINFO OFF}
11 | {$EXTENDEDSYNTAX ON}
12 | {$IMPORTEDDATA ON}
13 | {$IOCHECKS ON}
14 | {$LOCALSYMBOLS OFF}
15 | {$LONGSTRINGS ON}
16 | {$OPENSTRINGS ON}
17 | {$OPTIMIZATION ON}
18 | {$OVERFLOWCHECKS OFF}
19 | {$RANGECHECKS OFF}
20 | {$REFERENCEINFO OFF}
21 | {$SAFEDIVIDE OFF}
22 | {$STACKFRAMES OFF}
23 | {$TYPEDADDRESS OFF}
24 | {$VARSTRINGCHECKS ON}
25 | {$WRITEABLECONST OFF}
26 | {$MINENUMSIZE 1}
27 | {$IMAGEBASE $400000}
28 | {$DEFINE RELEASE}
29 | {$ENDIF IMPLICITBUILDING}
30 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
31 | {$IMPLICITBUILD OFF}
32 |
33 | requires
34 | rtl,
35 | vcl;
36 |
37 | contains
38 | SimpleTimer in '..\source\SimpleTimer.pas',
39 | TextTrayIcon in '..\source\TextTrayIcon.pas',
40 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
41 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
42 |
43 | end.
44 |
45 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE2.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_XE2;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
7 | {$ALIGN 8}
8 | {$ASSERTIONS ON}
9 | {$BOOLEVAL OFF}
10 | {$DEBUGINFO OFF}
11 | {$EXTENDEDSYNTAX ON}
12 | {$IMPORTEDDATA ON}
13 | {$IOCHECKS ON}
14 | {$LOCALSYMBOLS OFF}
15 | {$LONGSTRINGS ON}
16 | {$OPENSTRINGS ON}
17 | {$OPTIMIZATION ON}
18 | {$OVERFLOWCHECKS OFF}
19 | {$RANGECHECKS OFF}
20 | {$REFERENCEINFO OFF}
21 | {$SAFEDIVIDE OFF}
22 | {$STACKFRAMES OFF}
23 | {$TYPEDADDRESS OFF}
24 | {$VARSTRINGCHECKS ON}
25 | {$WRITEABLECONST OFF}
26 | {$MINENUMSIZE 1}
27 | {$IMAGEBASE $400000}
28 | {$DEFINE RELEASE}
29 | {$ENDIF IMPLICITBUILDING}
30 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
31 | {$IMPLICITBUILD OFF}
32 |
33 | requires
34 | rtl,
35 | vcl;
36 |
37 | contains
38 | SimpleTimer in '..\source\SimpleTimer.pas',
39 | TextTrayIcon in '..\source\TextTrayIcon.pas',
40 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
41 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
42 |
43 | end.
44 |
45 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE3.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_XE3;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
7 | {$ALIGN 8}
8 | {$ASSERTIONS ON}
9 | {$BOOLEVAL OFF}
10 | {$DEBUGINFO OFF}
11 | {$EXTENDEDSYNTAX ON}
12 | {$IMPORTEDDATA ON}
13 | {$IOCHECKS ON}
14 | {$LOCALSYMBOLS OFF}
15 | {$LONGSTRINGS ON}
16 | {$OPENSTRINGS ON}
17 | {$OPTIMIZATION ON}
18 | {$OVERFLOWCHECKS OFF}
19 | {$RANGECHECKS OFF}
20 | {$REFERENCEINFO OFF}
21 | {$SAFEDIVIDE OFF}
22 | {$STACKFRAMES OFF}
23 | {$TYPEDADDRESS OFF}
24 | {$VARSTRINGCHECKS ON}
25 | {$WRITEABLECONST OFF}
26 | {$MINENUMSIZE 1}
27 | {$IMAGEBASE $400000}
28 | {$DEFINE RELEASE}
29 | {$ENDIF IMPLICITBUILDING}
30 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
31 | {$IMPLICITBUILD OFF}
32 |
33 | requires
34 | rtl,
35 | vcl;
36 |
37 | contains
38 | SimpleTimer in '..\source\SimpleTimer.pas',
39 | TextTrayIcon in '..\source\TextTrayIcon.pas',
40 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
41 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
42 |
43 | end.
44 |
45 |
--------------------------------------------------------------------------------
/Delphi/CoolTrayIcon_XE6.dpk:
--------------------------------------------------------------------------------
1 | package CoolTrayIcon_XE6;
2 |
3 | {$R *.res}
4 | {$R '..\source\CoolTrayIcon.dcr'}
5 | {$R '..\source\TextTrayIcon.dcr'}
6 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
7 | {$ALIGN 8}
8 | {$ASSERTIONS ON}
9 | {$BOOLEVAL OFF}
10 | {$DEBUGINFO OFF}
11 | {$EXTENDEDSYNTAX ON}
12 | {$IMPORTEDDATA ON}
13 | {$IOCHECKS ON}
14 | {$LOCALSYMBOLS OFF}
15 | {$LONGSTRINGS ON}
16 | {$OPENSTRINGS ON}
17 | {$OPTIMIZATION ON}
18 | {$OVERFLOWCHECKS OFF}
19 | {$RANGECHECKS OFF}
20 | {$REFERENCEINFO OFF}
21 | {$SAFEDIVIDE OFF}
22 | {$STACKFRAMES OFF}
23 | {$TYPEDADDRESS OFF}
24 | {$VARSTRINGCHECKS ON}
25 | {$WRITEABLECONST OFF}
26 | {$MINENUMSIZE 1}
27 | {$IMAGEBASE $400000}
28 | {$DEFINE RELEASE}
29 | {$ENDIF IMPLICITBUILDING}
30 | {$DESCRIPTION 'CoolTrayIcon and Friends'}
31 | {$IMPLICITBUILD OFF}
32 |
33 | requires
34 | rtl,
35 | vcl;
36 |
37 | contains
38 | SimpleTimer in '..\source\SimpleTimer.pas',
39 | TextTrayIcon in '..\source\TextTrayIcon.pas',
40 | CoolTrayIcon in '..\source\CoolTrayIcon.pas',
41 | RegisterTrayIcons in '..\Design\RegisterTrayIcons.pas';
42 |
43 | end.
44 |
45 |
--------------------------------------------------------------------------------
/docs/convert_cti_projects.txt:
--------------------------------------------------------------------------------
1 | A few things have changed in ver. 4.0.0 of CoolTrayIcon which means you may
2 | have to slightly adjust your previous projects that use CooltrayIcon or
3 | TextTrayIcon.
4 |
5 |
6 | 1) The IconVisible property is now default false in stead of true.
7 |
8 | The reason for this is that the tray icon would apparently show itself,
9 | regardless of the property being false, if CoolTrayIcon was used in a
10 | DLL file.
11 |
12 | This change means that you have to reset the property to true in your old
13 | projects, in case the value was originally true.
14 |
15 |
16 | 2) The StartMinimized property no longer exists. It has been replaced by the
17 | OnStartup event. This event has a ShowMainForm parameter, which you set to
18 | false if you don't want the main form to show when your app. starts.
19 |
20 | The reason for this change is that StartMinimized only worked at design-time,
21 | meaning you could not determine at run-time if you wanted to show the form
22 | or not. With the change it is now possible to have a user option for this
23 | in your app.
24 |
25 | See the StartHidden demo for an example.
26 |
27 |
--------------------------------------------------------------------------------
/docs/History - SimpleTimer.txt:
--------------------------------------------------------------------------------
1 | SimpleTimer, ver. 2.0.3
2 |
3 |
4 | - ver. 2.0.3: Added property Tag to make SimpleTimer compatible with TTimer.
5 |
6 | - ver. 2.0.2: No functional change, just a correction of the demo and
7 | the documentation (Create was used instead of CreateEx).
8 |
9 | - ver. 2.0.1: Since overloaded methods are not allowed in D2 and D3
10 | I renamed the second constructor from "Create" to "CreateEx" and
11 | dropped the overload directive.
12 |
13 | - ver. 2.0.0: Major restructuring. Big thanks go to mikk from Hungary
14 | for contributing with suggestions and code. Changes in 2.0.0 include:
15 | * The Start and Stop methods have been replaced with Enabled and Interval
16 | properties, so SimpleTimer resembles TTimer more closely.
17 | * The callback method is replaced by an OnTimer event.
18 | * Added AutoDisable and CallBackMethod properties.
19 | * Added two stand-alone methods.
20 | +++++ See convert_st_projects.txt if you are using SimpleTimer already +++++
21 |
22 | - ver. 1.0.3: Reintroduced reference to the Forms unit, as it was needed
23 | by Delphi 5 and below (doh!).
24 |
25 | - ver. 1.0.2: Removed reference to the Forms unit.
26 |
27 | - ver. 1.0.1: Removed exception handling from the WndProc method as it
28 | would catch any and all exceptions, including the ones which were
29 | supposed to be thrown. Thanks to George Mealer for telling me.
30 |
31 | - ver. 1.0.0: First release.
32 |
33 |
34 |
35 | If you have any comments or corrections, I would very much like to
36 | hear them.
37 |
38 | Troels Jakobsen
39 | troels.jakobsen@gmail.com
40 |
--------------------------------------------------------------------------------
/demos/CustomHint1/Main.dfm:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 397
3 | Top = 312
4 | BorderStyle = bsDialog
5 | Caption = 'Custom tooltip'
6 | ClientHeight = 129
7 | ClientWidth = 254
8 | Color = clBtnFace
9 | Font.Charset = DEFAULT_CHARSET
10 | Font.Color = clWindowText
11 | Font.Height = -11
12 | Font.Name = 'MS Sans Serif'
13 | Font.Style = []
14 | OldCreateOrder = False
15 | Position = poScreenCenter
16 | OnCreate = FormCreate
17 | OnDestroy = FormDestroy
18 | PixelsPerInch = 96
19 | TextHeight = 13
20 | object Label1: TLabel
21 | Left = 8
22 | Top = 8
23 | Width = 223
24 | Height = 26
25 | Caption =
26 | 'This simple app. demonstrates how to get the common tooltip wind' +
27 | 'ow shared by all tray icons.'
28 | WordWrap = True
29 | end
30 | object Label2: TLabel
31 | Left = 8
32 | Top = 44
33 | Width = 235
34 | Height = 39
35 | Caption =
36 | 'The MouseEnter event changes the font and colors, while the Mous' +
37 | 'eExit event resets them, so the tooltip will look normal for oth' +
38 | 'er tray icons.'
39 | WordWrap = True
40 | end
41 | object Button1: TButton
42 | Left = 88
43 | Top = 94
44 | Width = 75
45 | Height = 25
46 | Caption = 'E&xit'
47 | TabOrder = 0
48 | OnClick = Button1Click
49 | end
50 | object CoolTrayIcon1: TCoolTrayIcon
51 | CycleInterval = 500
52 | Hint = 'This is a custom hint'
53 | Icon.Data = {
54 | 0000010001001010040000000000280100001600000028000000100000002000
55 | 0000010004000000000080000000000000000000000010000000000000000000
56 | 0000000080000080000000808000800000008000800080800000C0C0C0008080
57 | 80000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
58 | 000000000000000000000000000000000000000000000000000000000000000F
59 | F00000FF000000FF00000FF0000000FF00000FF0000000FF00000FF0000000FF
60 | FF000FFFF000000FF00000FF0000000000000000000000000000000000000000
61 | 000000000000000000000000000000000000000000000000000000000000FFFF
62 | 0000FFFF0000FFFF0000E7CF0000C38700008103000081030000810300008103
63 | 0000C3870000E7CF0000FFFF0000C3870000FFFF0000FFFF0000FFFF0000}
64 | IconVisible = True
65 | IconIndex = 0
66 | PopupMenu = PopupMenu1
67 | WantEnterExitEvents = True
68 | OnMouseEnter = CoolTrayIcon1MouseEnter
69 | OnMouseExit = CoolTrayIcon1MouseExit
70 | Left = 208
71 | Top = 92
72 | end
73 | object PopupMenu1: TPopupMenu
74 | Left = 176
75 | Top = 92
76 | object Exit1: TMenuItem
77 | Caption = '&Exit'
78 | OnClick = Exit1Click
79 | end
80 | end
81 | end
82 |
--------------------------------------------------------------------------------
/demos/StartHidden/Main.pas:
--------------------------------------------------------------------------------
1 | unit Main;
2 |
3 | interface
4 |
5 | uses
6 | Windows, Classes, Controls, Forms, StdCtrls, CoolTrayIcon;
7 |
8 | type
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 |
27 | var
28 | MainForm: TMainForm;
29 |
30 | implementation
31 |
32 | {$R *.dfm}
33 |
34 | uses
35 | Registry;
36 |
37 | const
38 | StartHiddenKey = 'Software\CoolTrayIcon\StartHiddenDemo';
39 |
40 |
41 | function TMainForm.LoadSetting(Key, Item: String; DefValue: Boolean): Boolean;
42 | var
43 | Reg: TRegIniFile;
44 | begin
45 | Reg := TRegIniFile.Create(Key);
46 | Result := Reg.ReadBool('', Item, DefValue);
47 | Reg.Free;
48 | end;
49 |
50 |
51 | procedure TMainForm.SaveSetting(Key, Item: String; Value: Boolean);
52 | var
53 | Reg: TRegIniFile;
54 | begin
55 | Reg := TRegIniFile.Create(Key);
56 | Reg.WriteBool('', Item, Value);
57 | Reg.Free;
58 | end;
59 |
60 |
61 | procedure TMainForm.RemoveSetting(Key: String);
62 | var
63 | Reg: TRegIniFile;
64 | begin
65 | Reg := TRegIniFile.Create(Key);
66 | Reg.EraseSection('');
67 | Reg.Free;
68 | end;
69 |
70 |
71 | procedure TMainForm.CheckBox1Click(Sender: TObject);
72 | begin
73 | if CheckBox1.Checked then
74 | SaveSetting(StartHiddenKey, 'StartHidden', True)
75 | else
76 | RemoveSetting(StartHiddenKey);
77 | end;
78 |
79 |
80 | procedure TMainForm.CoolTrayIcon1MouseDown(Sender: TObject;
81 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
82 | begin
83 | CoolTrayIcon1.ShowMainForm;
84 | end;
85 |
86 |
87 | procedure TMainForm.CoolTrayIcon1Startup(Sender: TObject; var ShowMainForm: Boolean);
88 | var
89 | StartHidden: Boolean;
90 | begin
91 | StartHidden := LoadSetting(StartHiddenKey, 'StartHidden', False);
92 | CheckBox1.Checked := StartHidden;
93 | ShowMainForm := not StartHidden;
94 | end;
95 |
96 |
97 | procedure TMainForm.Button1Click(Sender: TObject);
98 | begin
99 | Close;
100 | end;
101 |
102 | end.
103 |
104 |
--------------------------------------------------------------------------------
/install.txt:
--------------------------------------------------------------------------------
1 | How to install the components
2 | -----------------------------
3 |
4 | *** YOU NEED TO INSTALL THE COMPONENTS BEFORE OPENING THE DEMOS IN DELPHI. ***
5 |
6 |
7 | If you're running Delphi 5 or later:
8 |
9 | 1. Open CoolTrayIcon_D5.dpk (Delphi 5) or CoolTrayIcon_D6plus.dpk (Delphi 6
10 | or later) either by doubleclicking the file or by selecting "Open Project"
11 | inside Delphi. (CoolTrayIcon_D5.dpk may work for older Delphi versions
12 | as well, but I don't know for sure. Please tell me if I'm right.)
13 |
14 | 2. Click Compile, then Install.
15 |
16 | 3. You may need to add the folder containing the components to your library path
17 | (select Tools -> Environment Options from the menu).
18 |
19 | 4. That's it. The components should be visible in the component palette
20 | in a tab called "Tray Icons" (if older versions of the components were
21 | already installed they may be found in "Custom").
22 |
23 |
24 |
25 | If you're running Delphi versions older than ver. 5:
26 |
27 | 1. Try the steps above with the CoolTrayIcon_D5.dpk file (it may work in
28 | older versions of Delphi, but I don't know for sure. Please tell me).
29 | If this doesn't work then do the following:
30 |
31 | 2. Select "Install Component" from the "Component" menu item (may vary
32 | depending on your Delphi version).
33 |
34 | 3. A dialog displays where you must select the components to install and
35 | the package to install into. I recommend creating a new package, if you
36 | haven't already done so, rather than installing into the default package.
37 |
38 | 4. Browse for the RegisterTrayIcons.pas file and select OK.
39 |
40 | 5. You may need to add the folder containing the components to your library path
41 | (select Tools -> Environment Options from the menu).
42 |
43 | 6. That's it. The components should be visible in the component palette
44 | in a tab called "Tray Icons" (if older versions of the components were
45 | already installed they may be found in "Custom").
46 |
47 |
48 |
49 | If you're running C++ Builder:
50 |
51 | The required steps are the same as in Delphi, so just follow the steps above.
52 |
53 | Alternatively, use this approach:
54 |
55 | 1. Select "New Component..." from the menu
56 |
57 | 2. In "Ancestor type", select "TTrayIcon [trayicon]"
58 |
59 | 3. In "Class Name", type "TCoolTrayIcon"
60 |
61 | 4. In "Palette Page", type "Tray Icons" (or another tab you want to install to)
62 |
63 | 5. In "Unit file name", select "RegisterTrayIcons.pas" (which is found in the
64 | CoolTrayIcon package). Also, include CoolTrayIcon.pas and TextTrayIcon.pas,
65 | or you might get an error regarding "IMGLIST.OBJ".
66 |
67 | 6. Click on the "Install" button.
68 |
--------------------------------------------------------------------------------
/demos/CoolService/Service.dfm:
--------------------------------------------------------------------------------
1 | object CoolTrayService: TCoolTrayService
2 | OldCreateOrder = False
3 | DisplayName = 'CoolTrayIcon Service'
4 | Interactive = True
5 | StartType = stManual
6 | AfterInstall = ServiceAfterInstall
7 | OnExecute = ServiceExecute
8 | Left = 165
9 | Top = 548
10 | Height = 285
11 | Width = 561
12 | object CoolTrayIcon1: TCoolTrayIcon
13 | CycleInterval = 0
14 | Hint = 'CoolTrayIcon Service'
15 | Icon.Data = {
16 | 0000010001002020100000000000E80200001600000028000000200000004000
17 | 0000010004000000000000020000000000000000000000000000000000000000
18 | 000000008000008000000080800080000000800080008080000080808000C0C0
19 | C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000040
20 | 000040040400000000400040004007004000004000040000000000C000404000
21 | 0000000000040000000800000004004000000000000C00000000000400004000
22 | 00000000004C4000000000000004000000C00000444744440000000070000000
23 | 00000044C047400C4400000000000070000044C0004840000C44000000044000
24 | 00044C000048400000C44000000040000044C00000474000000C440000000000
25 | 004C00000448C4000000C4000000400004C0000404C8C40400000C40000C0000
26 | 0400004040C8C04040000040000000004C000004CC7F7CC4000000C400000000
27 | 40000440C87F78C04400000400000004444444CC778F877CCC4444444000044C
28 | C77887888FFFFFF88878877CC4400004444444CC778F8774CC44444440000000
29 | 40000440C87F78C044000004000000004C000004CC7F7CC4000000C400000000
30 | 0400004040C8C040400000400000000004C0000404C8C40400000C4000040000
31 | 004C000004C8C4000000C4000000000C0044C00000474000000C440000000000
32 | 00044C000048400000C4400700040400000044C0004840000C44000000000000
33 | 00000044C047400C44000000000008000000000044474444000000000000000C
34 | 00000000004C40000000C00000040000400000000004000000000000C0400700
35 | 0000040000040000000000800000004000000000000000000C00000040040000
36 | 0000000000000000000000000000000000000000000000000000000000000000
37 | 0000000000000000000000000000000000000000000000000000000000000000
38 | 0000000000000000000000000000000000000000000000000000000000000000
39 | 000000000000000000000000000000000000000000000000000000000000}
40 | IconVisible = True
41 | IconIndex = 0
42 | PopupMenu = PopupMenu1
43 | Left = 28
44 | Top = 10
45 | end
46 | object PopupMenu1: TPopupMenu
47 | Left = 108
48 | Top = 10
49 | object GetValue1: TMenuItem
50 | Caption = '&Get magic number'
51 | OnClick = GetValue1Click
52 | end
53 | object SetValue1: TMenuItem
54 | Caption = 'Set &magic number'
55 | OnClick = SetValue1Click
56 | end
57 | object N1: TMenuItem
58 | Caption = '-'
59 | end
60 | object StopService1: TMenuItem
61 | Caption = '&Stop this service'
62 | OnClick = StopService1Click
63 | end
64 | end
65 | end
66 |
--------------------------------------------------------------------------------
/demos/CustomHint1/Main.pas:
--------------------------------------------------------------------------------
1 | unit Main;
2 |
3 | interface
4 |
5 | uses
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 | StdCtrls, ExtCtrls, ImgList, CoolTrayIcon, Menus;
8 |
9 | type
10 | TForm1 = class(TForm)
11 | CoolTrayIcon1: TCoolTrayIcon;
12 | PopupMenu1: TPopupMenu;
13 | Exit1: TMenuItem;
14 | Label1: TLabel;
15 | Button1: TButton;
16 | Label2: TLabel;
17 | procedure FormCreate(Sender: TObject);
18 | procedure FormDestroy(Sender: TObject);
19 | procedure Loaded; override;
20 | procedure CoolTrayIcon1MouseEnter(Sender: TObject);
21 | procedure CoolTrayIcon1MouseExit(Sender: TObject);
22 | procedure Exit1Click(Sender: TObject);
23 | procedure Button1Click(Sender: TObject);
24 | private
25 | HTooltip: HWND;
26 | CustomFont: TFont;
27 | BackColor, TextColor: COLORREF;
28 | end;
29 |
30 | var
31 | Form1: TForm1;
32 |
33 | implementation
34 |
35 | {$R *.DFM}
36 |
37 | const
38 | // Tooltip constants
39 | TTM_SETMAXTIPWIDTH = (WM_USER + 24);
40 | TTM_SETTIPBKCOLOR = (WM_USER + 19);
41 | TTM_SETTIPTEXTCOLOR = (WM_USER + 20);
42 | TTM_SETTITLEA = (WM_USER + 32);
43 |
44 | procedure TForm1.FormCreate(Sender: TObject);
45 | begin
46 | CustomFont := TFont.Create;
47 | CustomFont.Size := 14;
48 | CustomFont.Name := 'Verdana';
49 | BackColor := RGB(0, 0, 255);
50 | TextColor := RGB(255, 255, 0);
51 | end;
52 |
53 |
54 | procedure TForm1.FormDestroy(Sender: TObject);
55 | begin
56 | CustomFont.Free;
57 | end;
58 |
59 |
60 | procedure TForm1.Loaded;
61 | begin
62 | inherited;
63 | HTooltip := CoolTrayIcon1.GetTooltipHandle;
64 | end;
65 |
66 |
67 | procedure TForm1.CoolTrayIcon1MouseEnter(Sender: TObject);
68 | begin
69 | if HTooltip = 0 then
70 | Exit;
71 | // Set colors
72 | SendMessage(HTooltip, TTM_SETTIPBKCOLOR, BackColor, 0);
73 | SendMessage(HTooltip, TTM_SETTIPTEXTCOLOR, TextColor, 0);
74 | // Set max width
75 | // SendMessage(HTooltip, TTM_SETMAXTIPWIDTH, 0, 999); //???
76 | // Set font
77 | SendMessage(HTooltip, WM_SETFONT, CustomFont.Handle, 0);
78 | end;
79 |
80 |
81 | procedure TForm1.CoolTrayIcon1MouseExit(Sender: TObject);
82 | begin
83 | if HTooltip = 0 then
84 | Exit;
85 | // Close tooltip immediately (by moving it off-screen)
86 | SetWindowPos(HTooltip, 0, -500, -500, 0, 0, SWP_NOZORDER or SWP_NOACTIVATE or SWP_NOSIZE);
87 | // Reset tooltip properties to defaults
88 | SendMessage(HTooltip, TTM_SETMAXTIPWIDTH, 0, -1);
89 | SendMessage(HTooltip, WM_SETFONT, 0, 0);
90 | SendMessage(HTooltip, TTM_SETTIPBKCOLOR, GetSysColor(COLOR_INFOBK), 0);
91 | SendMessage(HTooltip, TTM_SETTIPTEXTCOLOR, GetSysColor(COLOR_INFOTEXT), 0);
92 | end;
93 |
94 |
95 | procedure TForm1.Exit1Click(Sender: TObject);
96 | begin
97 | Close;
98 | end;
99 |
100 |
101 | procedure TForm1.Button1Click(Sender: TObject);
102 | begin
103 | Exit1Click(Self);
104 | end;
105 |
106 | end.
107 |
108 |
--------------------------------------------------------------------------------
/demos/TrayDraw/CtDraw.dfm:
--------------------------------------------------------------------------------
1 | object DrawForm: TDrawForm
2 | Left = 330
3 | Top = 307
4 | BorderIcons = [biSystemMenu, biMinimize]
5 | BorderStyle = bsSingle
6 | Caption = 'CoolTrayIcon Drawing Demo'
7 | ClientHeight = 206
8 | ClientWidth = 281
9 | Color = clBtnFace
10 | Font.Charset = DEFAULT_CHARSET
11 | Font.Color = clWindowText
12 | Font.Height = -11
13 | Font.Name = 'MS Sans Serif'
14 | Font.Style = []
15 | OldCreateOrder = False
16 | Position = poScreenCenter
17 | OnClose = FormClose
18 | OnCreate = FormCreate
19 | PixelsPerInch = 96
20 | TextHeight = 13
21 | object Shape1: TShape
22 | Left = 11
23 | Top = 11
24 | Width = 162
25 | Height = 162
26 | end
27 | object PaintBox1: TPaintBox
28 | Left = 12
29 | Top = 12
30 | Width = 160
31 | Height = 160
32 | Color = clWhite
33 | ParentColor = False
34 | OnMouseDown = PaintBox1MouseDown
35 | OnMouseMove = PaintBox1MouseMove
36 | OnMouseUp = PaintBox1MouseUp
37 | OnPaint = PaintBox1Paint
38 | end
39 | object Button2: TButton
40 | Left = 192
41 | Top = 12
42 | Width = 75
43 | Height = 25
44 | Caption = '&Clear'
45 | TabOrder = 0
46 | OnClick = Button2Click
47 | end
48 | object Button3: TButton
49 | Left = 192
50 | Top = 44
51 | Width = 75
52 | Height = 25
53 | Caption = '&Load...'
54 | TabOrder = 1
55 | OnClick = Button3Click
56 | end
57 | object Button4: TButton
58 | Left = 192
59 | Top = 146
60 | Width = 75
61 | Height = 25
62 | Caption = 'E&xit'
63 | TabOrder = 3
64 | OnClick = Button4Click
65 | end
66 | object CheckBox1: TCheckBox
67 | Left = 12
68 | Top = 180
69 | Width = 109
70 | Height = 17
71 | Caption = '&Transparent'
72 | TabOrder = 4
73 | OnClick = CheckBox1Click
74 | end
75 | object Button1: TButton
76 | Left = 192
77 | Top = 114
78 | Width = 75
79 | Height = 25
80 | Caption = '&?'
81 | TabOrder = 2
82 | TabStop = False
83 | OnClick = Button1Click
84 | end
85 | object CoolTrayIcon1: TCoolTrayIcon
86 | CycleInterval = 0
87 | ShowHint = False
88 | Icon.Data = {
89 | 0000010001001010100000000000280100001600000028000000100000002000
90 | 00000100040000000000C0000000000000000000000000000000000000000000
91 | 0000000080000080000000808000800000008000800080800000C0C0C0008080
92 | 80000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
93 | 0000000000000000000000000000000000000000000000000000000000000000
94 | 0000000000000000000000000000000000000000000000000000000000000000
95 | 0000000000000000000000000000000000000000000000000000000000000000
96 | 000000000000000000000000000000000000000000000000000000000000FFFF
97 | 0000FFFF0000DFF70000C7C70000EBAF0000EC6F0000F55F0000F39F0000EBAF
98 | 00009BB3000000010000FD7F0000FD7F0000FEFF0000FEFF0000FFFF0000}
99 | IconVisible = True
100 | IconIndex = 0
101 | Left = 200
102 | Top = 78
103 | end
104 | object OpenPictureDialog1: TOpenPictureDialog
105 | Filter = 'Bitmaps (*.bmp)|*.bmp|All files (*.*)|*.*'
106 | Left = 236
107 | Top = 78
108 | end
109 | end
110 |
--------------------------------------------------------------------------------
/demos/CustomHint2/BigHint.dfm:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 292
3 | Top = 215
4 | BorderStyle = bsDialog
5 | Caption = 'Big Hint Demo'
6 | ClientHeight = 108
7 | ClientWidth = 213
8 | Color = clBtnFace
9 | Font.Charset = DEFAULT_CHARSET
10 | Font.Color = clWindowText
11 | Font.Height = -11
12 | Font.Name = 'MS Sans Serif'
13 | Font.Style = []
14 | OldCreateOrder = False
15 | Position = poScreenCenter
16 | OnCreate = FormCreate
17 | OnDestroy = FormDestroy
18 | PixelsPerInch = 96
19 | TextHeight = 13
20 | object Label1: TLabel
21 | Left = 12
22 | Top = 12
23 | Width = 175
24 | Height = 13
25 | Caption = 'Position the cursor over the tray icon.'
26 | ShowAccelChar = False
27 | end
28 | object Label2: TLabel
29 | Left = 12
30 | Top = 34
31 | Width = 191
32 | Height = 26
33 | Caption = 'Use the popu menu to change between different hint windows.'
34 | ShowAccelChar = False
35 | WordWrap = True
36 | end
37 | object Button1: TButton
38 | Left = 128
39 | Top = 74
40 | Width = 75
41 | Height = 25
42 | Caption = 'E&xit'
43 | TabOrder = 0
44 | OnClick = Button1Click
45 | end
46 | object TextTrayIcon1: TTextTrayIcon
47 | CycleInterval = 0
48 | Hint = '- FIRST LINE -'
49 | ShowHint = False
50 | Icon.Data = {
51 | 0000010001001010040000000000280100001600000028000000100000002000
52 | 0000010004000000000080000000000000000000000010000000000000000000
53 | 0000000080000080000000808000800000008000800080800000C0C0C0008080
54 | 80000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
55 | 000000000000074447FFFF7444700FF848FFFF848FF00FFF447FF744FFF00FFF
56 | 747FF747FFF00FFF748FF847FFF00FFFF44FF44FFFF00FFFF44FF44FFFF00FFF
57 | F44FF44FFFF00FFFF44FF44FFFF00FFF748FF847FFF00FFF747FF747FFF00FFF
58 | 447FF744FFF00FF848FFFF848FF0078447FFFF74487000000000000000000000
59 | 0000000000000000000000000000000000000000000000000000000000000000
60 | 000000000000000000000000000000000000000000000000000000000000}
61 | IconVisible = True
62 | IconIndex = 0
63 | PopupMenu = PopupMenu1
64 | WantEnterExitEvents = True
65 | OnMouseMove = TextTrayIcon1MouseMove
66 | OnMouseEnter = TextTrayIcon1MouseEnter
67 | OnMouseExit = TextTrayIcon1MouseExit
68 | Text = 'OO'
69 | Font.Charset = EASTEUROPE_CHARSET
70 | Font.Color = clNavy
71 | Font.Height = -24
72 | Font.Name = 'Tahoma'
73 | Font.Style = []
74 | Color = clWhite
75 | Border = True
76 | Options.OffsetX = 0
77 | Options.OffsetY = 0
78 | Options.LineDistance = 0
79 | Left = 12
80 | Top = 70
81 | end
82 | object PopupMenu1: TPopupMenu
83 | Left = 52
84 | Top = 70
85 | object Regular1: TMenuItem
86 | Caption = '&Regular THintWindow'
87 | Checked = True
88 | GroupIndex = 1
89 | RadioItem = True
90 | OnClick = Regular1Click
91 | end
92 | object Custom1: TMenuItem
93 | Caption = '&Tiled THintWindow'
94 | GroupIndex = 1
95 | RadioItem = True
96 | OnClick = Custom1Click
97 | end
98 | object N1: TMenuItem
99 | Caption = '-'
100 | GroupIndex = 1
101 | end
102 | object Exit1: TMenuItem
103 | Caption = 'E&xit'
104 | GroupIndex = 1
105 | OnClick = Exit1Click
106 | end
107 | end
108 | object Timer1: TTimer
109 | Enabled = False
110 | OnTimer = Timer1Timer
111 | Left = 64
112 | Top = 70
113 | end
114 | object Timer2: TTimer
115 | Enabled = False
116 | OnTimer = Timer2Timer
117 | Left = 76
118 | Top = 70
119 | end
120 | end
121 |
--------------------------------------------------------------------------------
/demos/CoolService/Service.pas:
--------------------------------------------------------------------------------
1 | unit Service;
2 |
3 | interface
4 |
5 | uses
6 | Windows, Classes, SvcMgr, Menus, CoolTrayIcon;
7 |
8 | type
9 | TCoolTrayService = class(TService)
10 | CoolTrayIcon1: TCoolTrayIcon;
11 | PopupMenu1: TPopupMenu;
12 | GetValue1: TMenuItem;
13 | SetValue1: TMenuItem;
14 | N1: TMenuItem;
15 | StopService1: TMenuItem;
16 | procedure ServiceExecute(Sender: TService);
17 | procedure StopService1Click(Sender: TObject);
18 | procedure ServiceAfterInstall(Sender: TService);
19 | procedure SetValue1Click(Sender: TObject);
20 | procedure GetValue1Click(Sender: TObject);
21 | public
22 | function GetServiceController: TServiceController; override;
23 | private
24 | MagicNumber: Integer;
25 | end;
26 |
27 | var
28 | CoolTrayService: TCoolTrayService;
29 |
30 | implementation
31 |
32 | uses
33 | ShellApi, WinSvc, Registry, SysUtils;
34 |
35 | {$R *.DFM}
36 |
37 | function ServiceStop(aMachine, aServiceName: String): Boolean;
38 | // aMachine is UNC path or local machine if empty
39 | var
40 | h_manager, h_svc: SC_Handle;
41 | ServiceStatus: TServiceStatus;
42 | dwCheckPoint: DWORD;
43 | begin
44 | h_manager := OpenSCManager(PChar(aMachine), nil, SC_MANAGER_CONNECT);
45 | if h_manager > 0 then
46 | begin
47 | h_svc := OpenService(h_manager, PChar(aServiceName),
48 | SERVICE_STOP or SERVICE_QUERY_STATUS);
49 | if h_svc > 0 then
50 | begin
51 | if (ControlService(h_svc, SERVICE_CONTROL_STOP, ServiceStatus)) then
52 | begin
53 | if (QueryServiceStatus(h_svc, ServiceStatus)) then
54 | begin
55 | while (SERVICE_STOPPED <> ServiceStatus.dwCurrentState) do
56 | begin
57 | dwCheckPoint := ServiceStatus.dwCheckPoint;
58 | Sleep(ServiceStatus.dwWaitHint);
59 | if (not QueryServiceStatus(h_svc, ServiceStatus)) then
60 | // couldn't check status
61 | break;
62 | if (ServiceStatus.dwCheckPoint < dwCheckPoint) then
63 | Break;
64 | end;
65 | end;
66 | end;
67 | CloseServiceHandle(h_svc);
68 | end;
69 | CloseServiceHandle(h_manager);
70 | end;
71 |
72 | Result := (SERVICE_STOPPED = ServiceStatus.dwCurrentState);
73 | end;
74 |
75 |
76 | procedure ServiceController(CtrlCode: DWord); stdcall;
77 | begin
78 | CoolTrayService.Controller(CtrlCode);
79 | end;
80 |
81 |
82 | function TCoolTrayService.GetServiceController: TServiceController;
83 | begin
84 | Result := ServiceController;
85 | end;
86 |
87 |
88 | procedure TCoolTrayService.ServiceExecute(Sender: TService);
89 | begin
90 | while not Terminated do
91 | begin
92 | ServiceThread.ProcessRequests(True);
93 | // Sleep(1); // If you use ProcessRequests(False), insert a Sleep(1) or the service will eat all cpu power
94 | end;
95 | end;
96 |
97 |
98 | procedure TCoolTrayService.StopService1Click(Sender: TObject);
99 | begin
100 | // WinExec(PChar('net stop '+Name), 0); // Dirty indeed! Use ControlService instead!
101 | ServiceStop('', Name);
102 | ReportStatus; // Notify the Service Manager (Windows)
103 | end;
104 |
105 |
106 | procedure TCoolTrayService.ServiceAfterInstall(Sender: TService);
107 | // Registers the service's description
108 | var
109 | Reg: TRegistry;
110 | begin
111 | Reg := TRegistry.Create(KEY_READ or KEY_WRITE);
112 | try
113 | Reg.RootKey := HKEY_LOCAL_MACHINE;
114 | if Reg.OpenKey('System\CurrentControlSet\Services\' + Name, True) then
115 | begin
116 | Reg.WriteString('Description', 'A sample service using the CoolTrayIcon component.');
117 | end
118 | finally
119 | Reg.Free;
120 | end;
121 | end;
122 |
123 |
124 | procedure TCoolTrayService.SetValue1Click(Sender: TObject);
125 | begin
126 | Randomize;
127 | MagicNumber := Random(100);
128 | GetValue1Click(Self);
129 | end;
130 |
131 |
132 | procedure TCoolTrayService.GetValue1Click(Sender: TObject);
133 | begin
134 | MessageBox(0, PChar('Magic number is ' + IntToStr(MagicNumber)), 'Information', MB_ICONINFORMATION or MB_OK);
135 | end;
136 |
137 | end.
138 |
139 |
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/Main.pas:
--------------------------------------------------------------------------------
1 | unit Main;
2 |
3 | {$DEFINE DELPHI_6_UP}
4 | {$IFDEF VER80} {$UNDEF DELPHI_6_UP} {$ENDIF}
5 | {$IFDEF VER90} {$UNDEF DELPHI_6_UP} {$ENDIF}
6 | {$IFDEF VER100} {$UNDEF DELPHI_6_UP} {$ENDIF}
7 | {$IFDEF VER120} {$UNDEF DELPHI_6_UP} {$ENDIF}
8 | {$IFDEF VER130} {$UNDEF DELPHI_6_UP} {$ENDIF}
9 |
10 | interface
11 |
12 | uses
13 | Windows, Messages, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
14 | CoolTrayIcon;
15 |
16 | type
17 | TMainForm = class(TForm)
18 | CoolTrayIcon1: TCoolTrayIcon;
19 | Label1: TLabel;
20 | RadioGroup1: TRadioGroup;
21 | Button1: TButton;
22 | procedure FormCreate(Sender: TObject);
23 | procedure CoolTrayIcon1Click(Sender: TObject);
24 | procedure CoolTrayIcon1MinimizeToTray(Sender: TObject);
25 | procedure Button1Click(Sender: TObject);
26 | procedure RadioGroup1Click(Sender: TObject);
27 | private
28 | IsMinimized: Boolean;
29 | procedure FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
30 | procedure FadeWindow(Minimizing: Boolean);
31 | procedure ImplodeWindow(Minimizing: Boolean);
32 | procedure ImplodeOutlineWindow(Minimizing: Boolean);
33 | public
34 | StartX, StartY, StartW, StartH: Integer;
35 | end;
36 |
37 | var
38 | MainForm: TMainForm;
39 |
40 | implementation
41 |
42 | uses
43 | TrayAnimation;
44 |
45 | {$R *.dfm}
46 |
47 | {--------------------- TMainForm ----------------------}
48 |
49 | procedure TMainForm.FormCreate(Sender: TObject);
50 | begin
51 | StartW := Width;
52 | StartH := Height;
53 | RadioGroup1Click(Self);
54 | end;
55 |
56 |
57 | procedure TMainForm.CoolTrayIcon1MinimizeToTray(Sender: TObject);
58 | begin
59 | case RadioGroup1.ItemIndex of
60 | 1: FloatRectangles(True, True);
61 | 2: FadeWindow(True);
62 | 3: ImplodeWindow(True);
63 | 4: ImplodeOutlineWindow(True);
64 | end;
65 | IsMinimized := True;
66 | end;
67 |
68 |
69 | procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
70 | begin
71 | if IsMinimized then
72 | begin
73 | case RadioGroup1.ItemIndex of
74 | 1: begin
75 | FloatRectangles(False, True);
76 | CoolTrayIcon1.ShowMainForm;
77 | end;
78 | 2: begin
79 | CoolTrayIcon1.ShowMainForm;
80 | FadeWindow(False);
81 | end;
82 | 3: begin
83 | CoolTrayIcon1.ShowMainForm;
84 | ImplodeWindow(False);
85 | end;
86 | 4: begin
87 | ImplodeOutlineWindow(False);
88 | CoolTrayIcon1.ShowMainForm;
89 | end;
90 | else
91 | CoolTrayIcon1.ShowMainForm;
92 | end;
93 | IsMinimized := False;
94 | end;
95 | end;
96 |
97 |
98 | procedure TMainForm.FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
99 | begin
100 | FloatingRectangles(Minimizing, OverrideUserSettings);
101 | end;
102 |
103 |
104 | procedure TMainForm.FadeWindow(Minimizing: Boolean);
105 | var
106 | WindowFader: TWindowFader;
107 | begin
108 | WindowFader := TWindowFader.Create(False);
109 | WindowFader.FadeOut := Minimizing;
110 | WindowFader.Execute;
111 | WindowFader.Free;
112 | end;
113 |
114 |
115 | procedure TMainForm.ImplodeWindow(Minimizing: Boolean);
116 | var
117 | WindowImploder: TWindowImploder;
118 | begin
119 | WindowImploder := TWindowImploder.Create(False);
120 | WindowImploder.Imploding := Minimizing;
121 | WindowImploder.Execute;
122 | WindowImploder.Free;
123 | end;
124 |
125 |
126 | procedure TMainForm.ImplodeOutlineWindow(Minimizing: Boolean);
127 | var
128 | WindowOutlineImploder: TWindowOutlineImploder;
129 | begin
130 | WindowOutlineImploder := TWindowOutlineImploder.Create;
131 | WindowOutlineImploder.Imploding := Minimizing;
132 | WindowOutlineImploder.Execute;
133 | WindowOutlineImploder.Free;
134 | end;
135 |
136 |
137 | procedure TMainForm.Button1Click(Sender: TObject);
138 | begin
139 | Close;
140 | end;
141 |
142 |
143 | procedure TMainForm.RadioGroup1Click(Sender: TObject);
144 | begin
145 | { We turn AlphaBlend on/off as needed because when AlphaBlend is true
146 | the form flickers when it's resized. }
147 | {$IFDEF DELPHI_6_UP}
148 | if RadioGroup1.ItemIndex = 2 then
149 | begin
150 | AlphaBlend := True;
151 | AlphaBlendValue := 255;
152 | end
153 | else
154 | AlphaBlend := False;
155 | {$ELSE}
156 | if RadioGroup1.ItemIndex = 2 then
157 | MessageDlg('Alpha-blend (fade) not supported in this Delphi version.',
158 | mtInformation, [mbOk], 0);
159 | {$ENDIF}
160 | end;
161 |
162 | end.
163 |
164 |
--------------------------------------------------------------------------------
/demos/demo.groupproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {41557190-6902-410A-8861-FF63DE8A5B9B}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Default.Personality.12
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/demos/TextTrayTest/TtMain.pas:
--------------------------------------------------------------------------------
1 | unit TtMain;
2 |
3 | interface
4 |
5 | uses
6 | Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls,
7 | ExtCtrls, ComCtrls, Menus, Graphics, CoolTrayIcon, TextTrayIcon;
8 |
9 | type
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 |
60 | var
61 | MainForm: TMainForm;
62 |
63 | implementation
64 |
65 | {$R *.DFM}
66 |
67 | procedure TMainForm.FormCreate(Sender: TObject);
68 | begin
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);
77 | end;
78 |
79 |
80 | procedure TMainForm.FormDestroy(Sender: TObject);
81 | begin
82 | BgIcon.Free;
83 | end;
84 |
85 |
86 | procedure TMainForm.Button7Click(Sender: TObject);
87 | begin
88 | Close;
89 | end;
90 |
91 |
92 | procedure TMainForm.Timer1Timer(Sender: TObject);
93 | begin
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;
105 | end;
106 |
107 |
108 | procedure TMainForm.Button1Click(Sender: TObject);
109 | begin
110 | // Loop numbers
111 | LoopNumbers := True;
112 | TrayCounter := 65;
113 | Timer1.Enabled := True;
114 | end;
115 |
116 |
117 | procedure TMainForm.Button2Click(Sender: TObject);
118 | begin
119 | // Loop characters
120 | LoopNumbers := False;
121 | TrayCounter := 65;
122 | Timer1.Enabled := True;
123 | end;
124 |
125 |
126 | procedure TMainForm.Button3Click(Sender: TObject);
127 | begin
128 | Timer1.Enabled := False;
129 | end;
130 |
131 |
132 | procedure TMainForm.Button4Click(Sender: TObject);
133 | begin
134 | FontDialog1.Font.Assign(TrayIcon1.Font);
135 | if FontDialog1.Execute then
136 | TrayIcon1.Font.Assign(FontDialog1.Font);
137 | // Alternative: TrayIcon1.Font := FontDialog1.Font;
138 | end;
139 |
140 |
141 | procedure TMainForm.Button5Click(Sender: TObject);
142 | begin
143 | ColorDialog1.Color := TrayIcon1.Color;
144 | if ColorDialog1.Execute then
145 | TrayIcon1.Color := ColorDialog1.Color;
146 | end;
147 |
148 |
149 | procedure TMainForm.Button6Click(Sender: TObject);
150 | begin
151 | ColorDialog1.Color := TrayIcon1.BorderColor;
152 | if ColorDialog1.Execute then
153 | TrayIcon1.BorderColor := ColorDialog1.Color;
154 | end;
155 |
156 |
157 | procedure TMainForm.Edit1Change(Sender: TObject);
158 | begin
159 | TrayIcon1.Text := Edit1.Text;
160 | end;
161 |
162 |
163 | procedure TMainForm.CheckBox1Click(Sender: TObject);
164 | begin
165 | TrayIcon1.Border := CheckBox1.Checked;
166 | end;
167 |
168 |
169 | procedure TMainForm.CheckBox2Click(Sender: TObject);
170 | begin
171 | if CheckBox2.Checked then
172 | TrayIcon1.BackgroundIcon := BgIcon
173 | else
174 | TrayIcon1.BackgroundIcon := nil;
175 | end;
176 |
177 |
178 | procedure TMainForm.Edit2Change(Sender: TObject);
179 | begin
180 | TrayIcon1.Options.OffsetX := StrToInt(Edit2.Text);
181 | end;
182 |
183 |
184 | procedure TMainForm.Edit3Change(Sender: TObject);
185 | begin
186 | TrayIcon1.Options.OffsetY := StrToInt(Edit3.Text);
187 | end;
188 |
189 |
190 | procedure TMainForm.Edit4Change(Sender: TObject);
191 | begin
192 | TrayIcon1.Options.LineDistance := StrToInt(Edit4.Text);
193 | end;
194 |
195 |
196 | procedure TMainForm.TrayIcon1MouseDown(Sender: TObject;
197 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
198 | begin
199 | // Timer1.Enabled := not Timer1.Enabled;
200 | end;
201 |
202 | end.
203 |
204 |
--------------------------------------------------------------------------------
/demos/CustomHint2/BigHint.pas:
--------------------------------------------------------------------------------
1 | unit BigHint;
2 |
3 | interface
4 |
5 | uses
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7 | Dialogs, CoolTrayIcon, TextTrayIcon, Menus, ExtCtrls, StdCtrls;
8 |
9 | type
10 | TTiledHintWindow = class(THintWindow)
11 | private
12 | Bmp: TBitmap;
13 | procedure TileImage(Bitmap: TBitmap; R: TRect);
14 | protected
15 | procedure Paint; override;
16 | public
17 | constructor Create(AOwner: TComponent); override;
18 | destructor Destroy; override;
19 | end;
20 |
21 | TForm1 = class(TForm)
22 | TextTrayIcon1: TTextTrayIcon;
23 | PopupMenu1: TPopupMenu;
24 | Regular1: TMenuItem;
25 | Custom1: TMenuItem;
26 | N1: TMenuItem;
27 | Exit1: TMenuItem;
28 | Timer1: TTimer;
29 | Timer2: TTimer;
30 | Label1: TLabel;
31 | Button1: TButton;
32 | Label2: TLabel;
33 | procedure FormCreate(Sender: TObject);
34 | procedure FormDestroy(Sender: TObject);
35 | procedure Timer1Timer(Sender: TObject);
36 | procedure Timer2Timer(Sender: TObject);
37 | procedure TextTrayIcon1MouseExit(Sender: TObject);
38 | procedure TextTrayIcon1MouseEnter(Sender: TObject);
39 | procedure Exit1Click(Sender: TObject);
40 | procedure Button1Click(Sender: TObject);
41 | procedure TextTrayIcon1MouseMove(Sender: TObject; Shift: TShiftState;
42 | X, Y: Integer);
43 | procedure Regular1Click(Sender: TObject);
44 | procedure Custom1Click(Sender: TObject);
45 | private
46 | HintWindow1: THintWindow;
47 | HintWindow2: TTiledHintWindow;
48 | CurrentHintWindow: THintWindow;
49 | LastMouse, LastHint: TPoint;
50 | Hint: string;
51 | end;
52 |
53 | var
54 | Form1: TForm1;
55 |
56 | implementation
57 |
58 | {$R *.dfm}
59 | {$R 'images.res'}
60 |
61 | {------------------------ TForm1 ----------------------}
62 |
63 | procedure TForm1.FormCreate(Sender: TObject);
64 | var
65 | I: Integer;
66 | begin
67 | HintWindow1 := THintWindow.Create(Self);
68 | HintWindow1.Color := clAqua;
69 | HintWindow1.Canvas.Font.Style := [fsBold];
70 | HintWindow1.Canvas.Font.Size := 10;
71 |
72 | HintWindow2 := TTiledHintWindow.Create(Self);
73 | HintWindow2.Canvas.Font.Color := clWhite;
74 |
75 | Timer1.Interval := Application.HintPause;
76 | Timer2.Interval := Application.HintHidePause;
77 |
78 | Hint := Hint + 'This is a BIG hint!'+#13;
79 | for I := 1 to 30 do
80 | begin
81 | Hint := Hint + 'abc - 0123456789 - 0123456789 - 0123456789 - 0123456789 - def';
82 | if I <> 30 then
83 | Hint := Hint + #13;
84 | end;
85 |
86 | Regular1Click(Self);
87 | end;
88 |
89 | procedure TForm1.FormDestroy(Sender: TObject);
90 | begin
91 | HintWindow1.Free;
92 | HintWindow2.Free;
93 | end;
94 |
95 | procedure TForm1.TextTrayIcon1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
96 | begin
97 | LastMouse.X := X;
98 | LastMouse.Y := Y;
99 | end;
100 |
101 | procedure TForm1.Timer1Timer(Sender: TObject);
102 | var
103 | HintRect: TRect;
104 | begin
105 | Timer1.Enabled := False;
106 | if (LastHint.X <> LastMouse.X) or (LastHint.Y <> LastMouse.Y) then
107 | begin
108 | if not Timer2.Enabled then
109 | begin
110 | HintRect := CurrentHintWindow.CalcHintRect(Screen.Width, Hint, nil);
111 | CurrentHintWindow.ActivateHint(Rect(LastMouse.X - HintRect.Right,
112 | LastMouse.Y - HintRect.Bottom, LastMouse.X, LastMouse.Y), Hint);
113 | end;
114 | LastHint.X := LastMouse.X;
115 | LastHint.Y := LastMouse.Y;
116 | end;
117 | Timer2.Enabled := true;
118 | end;
119 |
120 | procedure TForm1.Timer2Timer(Sender: TObject);
121 | begin
122 | CurrentHintWindow.ReleaseHandle;
123 | Timer2.Enabled := False;
124 | end;
125 |
126 | procedure TForm1.Regular1Click(Sender: TObject);
127 | begin
128 | Regular1.Checked := True;
129 | CurrentHintWindow := HintWindow1;
130 | end;
131 |
132 | procedure TForm1.Custom1Click(Sender: TObject);
133 | begin
134 | Custom1.Checked := True;
135 | CurrentHintWindow := HintWindow2;
136 | end;
137 |
138 | procedure TForm1.Exit1Click(Sender: TObject);
139 | begin
140 | Close;
141 | end;
142 |
143 | procedure TForm1.TextTrayIcon1MouseExit(Sender: TObject);
144 | begin
145 | CurrentHintWindow.ReleaseHandle;
146 | Timer1.Enabled := False;
147 | Timer2.Enabled := False;
148 | Timer1.Interval := Application.HintPause;
149 | Timer2.Interval := 5000; // Seems to be the time a tooltip is open
150 | end;
151 |
152 | procedure TForm1.TextTrayIcon1MouseEnter(Sender: TObject);
153 | begin
154 | if not Timer1.Enabled then
155 | Timer1.Enabled := True;
156 | end;
157 |
158 | procedure TForm1.Button1Click(Sender: TObject);
159 | begin
160 | Exit1Click(Self);
161 | end;
162 |
163 | {------------------ TTiledHintWindow ------------------}
164 |
165 | constructor TTiledHintWindow.Create(AOwner: TComponent);
166 | var
167 | H: HBITMAP;
168 | begin
169 | inherited Create(AOwner);
170 | Bmp := TBitmap.Create;
171 | H := LoadBitmap(HINSTANCE, 'BACKGROUND');
172 | Bmp.Handle := H;
173 | end;
174 |
175 | destructor TTiledHintWindow.Destroy;
176 | begin
177 | Bmp.Free;
178 | inherited Destroy;
179 | end;
180 |
181 | procedure TTiledHintWindow.Paint;
182 | var
183 | R: TRect;
184 | begin
185 | R := ClientRect;
186 | Inc(R.Left, 2);
187 | Inc(R.Top, 2);
188 | TileImage(Bmp, R);
189 | DrawText(Canvas.Handle, PChar(Caption), -1, R, DT_LEFT or DT_NOPREFIX or
190 | DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly);
191 | end;
192 |
193 | procedure TTiledHintWindow.TileImage(Bitmap: TBitmap; R: TRect);
194 | var
195 | X, Y: Integer;
196 | begin
197 | try
198 | for X := 0 to (R.Right-R.Left) div Bitmap.Width do
199 | for Y := 0 to (R.Bottom-R.Top) div Bitmap.Height do
200 | Canvas.Draw(X * Bitmap.Width, Y * Bitmap.Height, Bitmap);
201 | finally
202 | end;
203 | end;
204 |
205 | end.
206 |
207 |
--------------------------------------------------------------------------------
/demos/TrayDraw/CtDraw.pas:
--------------------------------------------------------------------------------
1 | unit CtDraw;
2 |
3 | interface
4 |
5 | uses
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 | ExtCtrls, StdCtrls, ExtDlgs, CoolTrayIcon;
8 |
9 | type
10 | TDrawForm = class(TForm)
11 | PaintBox1: TPaintBox;
12 | Button2: TButton;
13 | CoolTrayIcon1: TCoolTrayIcon;
14 | Button3: TButton;
15 | Button4: TButton;
16 | OpenPictureDialog1: TOpenPictureDialog;
17 | Shape1: TShape;
18 | CheckBox1: TCheckBox;
19 | Button1: TButton;
20 | procedure FormCreate(Sender: TObject);
21 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
22 | procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
23 | Shift: TShiftState; X, Y: Integer);
24 | procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
25 | Shift: TShiftState; X, Y: Integer);
26 | procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
27 | X, Y: Integer);
28 | procedure Button1Click(Sender: TObject);
29 | procedure Button2Click(Sender: TObject);
30 | procedure Button3Click(Sender: TObject);
31 | procedure Button4Click(Sender: TObject);
32 | procedure PaintBox1Paint(Sender: TObject);
33 | procedure CheckBox1Click(Sender: TObject);
34 | private
35 | StartX, StartY: Integer;
36 | CurrentX, CurrentY: Integer;
37 | Drawing: Boolean;
38 | DrawBitmap: TBitmap;
39 | procedure UpdateIcon;
40 | procedure CopyToBitmap(const Bmp: TBitmap);
41 | procedure SetSolidPen;
42 | procedure SetFeatherPen;
43 | procedure Clear;
44 | end;
45 |
46 | var
47 | DrawForm: TDrawForm;
48 |
49 | implementation
50 |
51 | {$R *.DFM}
52 |
53 | procedure TDrawForm.FormCreate(Sender: TObject);
54 | begin
55 | DrawBitmap := TBitmap.Create;
56 | DrawBitmap.Width := 16;
57 | DrawBitmap.Height := 16;
58 | // Clear;
59 | end;
60 |
61 |
62 | procedure TDrawForm.FormClose(Sender: TObject; var Action: TCloseAction);
63 | begin
64 | DrawBitmap.Free;
65 | end;
66 |
67 |
68 | procedure TDrawForm.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
69 | Shift: TShiftState; X, Y: Integer);
70 | begin
71 | StartX := X;
72 | StartY := Y;
73 | Drawing := True;
74 | end;
75 |
76 |
77 | procedure TDrawForm.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
78 | Shift: TShiftState; X, Y: Integer);
79 | begin
80 | SetSolidPen;
81 | PaintBox1.Canvas.MoveTo(StartX, StartY);
82 | PaintBox1.Canvas.LineTo(X, Y);
83 | CurrentX := 0;
84 | CurrentY := 0;
85 | Drawing := False;
86 | CopyToBitmap(DrawBitmap);
87 | UpdateIcon;
88 | end;
89 |
90 |
91 | procedure TDrawForm.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
92 | X, Y: Integer);
93 | begin
94 | if Drawing then
95 | with PaintBox1.Canvas do
96 | begin
97 | // Erase old line
98 | if (CurrentX <> 0) and (CurrentY <> 0) then
99 | begin
100 | SetFeatherPen;
101 | MoveTo(StartX, StartY);
102 | LineTo(CurrentX, CurrentY);
103 | end;
104 | // Draw new line
105 | SetFeatherPen;
106 | MoveTo(StartX, StartY);
107 | LineTo(X, Y);
108 | CurrentX := X;
109 | CurrentY := Y;
110 | end;
111 | end;
112 |
113 |
114 | procedure TDrawForm.Clear;
115 | begin
116 | PaintBox1.Canvas.Brush.Color := clWhite;
117 | PaintBox1.Canvas.FillRect(Rect(0, 0, PaintBox1.Width, PaintBox1.Height));
118 | if not DrawBitmap.Empty then
119 | begin
120 | CopyToBitmap(DrawBitmap);
121 | UpdateIcon;
122 | end;
123 | end;
124 |
125 |
126 | procedure TDrawForm.SetSolidPen;
127 | begin
128 | with PaintBox1.Canvas do
129 | begin
130 | Pen.Mode := pmCopy;
131 | Pen.Style := psSolid;
132 | Pen.Width := 8;
133 | Pen.Color := clBlack;
134 | end;
135 | end;
136 |
137 |
138 | procedure TDrawForm.SetFeatherPen;
139 | begin
140 | with PaintBox1.Canvas do
141 | begin
142 | Pen.Mode := pmNotXor;
143 | Pen.Style := psDot;
144 | Pen.Width := 1;
145 | Pen.Color := clBlack;
146 | end;
147 | end;
148 |
149 |
150 | procedure TDrawForm.CopyToBitmap(const Bmp: TBitmap);
151 | var
152 | DrawCanvas: TCanvas;
153 | begin
154 | DrawCanvas := TCanvas.Create;
155 | try
156 | DrawCanvas.Handle := PaintBox1.Canvas.Handle;
157 | Bmp.Width := PaintBox1.Width;
158 | Bmp.Height := PaintBox1.Height;
159 | Bmp.Canvas.CopyRect(PaintBox1.ClientRect, DrawCanvas, PaintBox1.ClientRect);
160 | // Resize to 16x16
161 | Bmp.Canvas.StretchDraw(Rect(0, 0, 16, 16), Bmp);
162 | finally
163 | DrawCanvas.Free;
164 | end;
165 | end;
166 |
167 |
168 | procedure TDrawForm.UpdateIcon;
169 | var
170 | Ico: TIcon;
171 | MaskColor: TColor;
172 | begin
173 | Ico := TIcon.Create;
174 | try
175 | if CheckBox1.Checked then
176 | // Find transparent color (bottom left pixel)
177 | MaskColor := DrawBitmap.Canvas.Pixels[0, DrawBitmap.Height-1]
178 | else
179 | // Not transparent
180 | MaskColor := clNone;
181 |
182 | if CoolTrayIcon1.BitmapToIcon(DrawBitmap, Ico, MaskColor) then
183 | begin
184 | // OK, let's assign the icon
185 | CoolTrayIcon1.Icon.Assign(Ico);
186 | CoolTrayIcon1.Refresh;
187 | end;
188 | finally
189 | Ico.Free;
190 | end;
191 | end;
192 |
193 |
194 | procedure TDrawForm.Button1Click(Sender: TObject);
195 | begin
196 | MessageDlg('This is just a silly demo of how CoolTrayIcon can render ' +
197 | 'a tray icon from a bitmap.' + #13#13 +
198 | 'Use the mouse to draw some lines or load a bitmap. ' +
199 | 'Watch how the tray icon changes.',
200 | mtInformation, [mbOK], 0);
201 | end;
202 |
203 |
204 | procedure TDrawForm.Button2Click(Sender: TObject);
205 | begin
206 | Clear;
207 | end;
208 |
209 |
210 | procedure TDrawForm.Button3Click(Sender: TObject);
211 | var
212 | Bmp: TBitmap;
213 | begin
214 | if OpenPictureDialog1.Execute then
215 | begin
216 | Bmp := TBitmap.Create;
217 | try
218 | Bmp.LoadFromFile(OpenPictureDialog1.Filename);
219 | PaintBox1.Canvas.StretchDraw(PaintBox1.ClientRect, Bmp);
220 | CopyToBitmap(DrawBitmap);
221 | UpdateIcon;
222 | finally
223 | Bmp.Free;
224 | end;
225 | end;
226 | end;
227 |
228 |
229 | procedure TDrawForm.Button4Click(Sender: TObject);
230 | begin
231 | Close;
232 | end;
233 |
234 |
235 | procedure TDrawForm.PaintBox1Paint(Sender: TObject);
236 | begin
237 | with PaintBox1 do
238 | Canvas.CopyRect(ClientRect, DrawBitmap.Canvas, ClientRect);
239 | end;
240 |
241 |
242 | procedure TDrawForm.CheckBox1Click(Sender: TObject);
243 | begin
244 | UpdateIcon;
245 | end;
246 |
247 | end.
248 |
249 |
--------------------------------------------------------------------------------
/docs/SimpleTimer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SimpleTimer, ver. 2.0.3
5 |
6 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | SimpleTimer, ver. 2.0.3
24 |
25 |
26 | [Properties] [Methods] [Events] [Stand-alone Methods]
27 |
28 | [How To Use] [Known Bugs] [Comments]
29 |
30 |
31 |
32 |
33 | SimpleTimer is a timer class. It has the same timer resolution as TTimer, but it is more
34 | lightweight because it's derived from TObject in stead of TComponent. Furthermore, the same
35 | handle is shared between multiple instances of SimpleTimer. This makes it ideal for developers
36 | who need a timer in their own components or applications, but want to keep the resource
37 | usage minimal.
38 |
39 |
40 |
41 | Properties
42 |
43 |
44 |
45 | | Enabled |
46 | property Enabled: Boolean;
47 | Enables (starts) or disables (stops) the timer. |
48 | Default False |
49 |
50 |
51 | | Interval |
52 | property Interval: Cardinal;
53 | The interval of the timer in millisecs.
54 | NOTE: Specifying a value of 0 will cause the timer to stop, but will not set the
55 | Enabled property to false. |
56 | Default 1000 |
57 |
58 |
59 | | AutoDisable |
60 | property AutoDisable: Boolean;
61 | If true, the timer will disable itself (Enabled is set to False) immediately after the next
62 | time it fires. Useful when you want a one-shot timer. |
63 | Default False |
64 |
65 |
66 |
67 |
68 |
69 | Methods
70 |
71 |
72 |
73 | | Create |
74 | constructor Create;
75 | Creates a new TSimpleTimer object. |
76 |
77 |
78 | | CreateEx |
79 | constructor CreateEx(AInterval: Cardinal; AOnTimer: TNotifyEvent);
80 | Creates a new TSimpleTimer object with the specified Interval property and OnTimer event. |
81 |
82 |
83 | | Destroy |
84 | destructor Destroy; override;
85 | Destroys the TSimpleTimer object. |
86 |
87 |
88 |
89 |
90 |
91 | Events
92 |
93 |
94 |
95 | | OnTimer |
96 | property OnTimer: TNotifyEvent;
97 | Called when the timer fires. |
98 |
99 |
100 |
101 |
102 |
103 | Stand-alone Methods
104 |
105 |
106 |
107 | | GetSimpleTimerCount |
108 | function GetSimpleTimerCount: Cardinal;
109 | Returns the number of TSimpleTimer objects currently allocated. |
110 |
111 |
112 | | GetSimpleTimerActiveCount |
113 | function GetSimpleTimerActiveCount: Cardinal;
114 | Returns the number of TSimpleTimer objects that are currently active (enabled). |
115 |
116 |
117 |
118 |
119 |
120 | How To Use
121 |
122 | This example creates a SimpleTimer object, initializing Interval to 500 milliseconds and
123 | the OnTimer event to TForm1.TimerProc1, then starts the timer:
124 | procedure TForm1.FormCreate(Sender: TObject);
125 | begin
126 | SimpleTimer1 := TSimpleTimer.CreateEx(500, TimerProc1);
127 | SimpleTimer1.Enabled := True;
128 | end;
129 |
130 | This is what TimerProc1 might look like:
131 | procedure TForm1.TimerProc1(Sender: TObject);
132 | begin
133 | ListBox1.Items.Add('SimpleTimer1 fired');
134 | end;
135 |
136 |
137 | Remember to destroy the SimpleTimer object when your app. terminates.
138 |
139 |
140 |
141 | Known Bugs
142 |
143 |
144 | - You may experience occasionally that you lose a timer event when you work with
145 | small intervals (approx. below 100 ms.). This is normal, and the same thing happens
146 | with a TTimer object. If you want precision you need a multimedia timer, not
147 | TTimer or TSimpleTimer which use the low-priority WM_TIMER message. WinXP has better
148 | handling of timers and will generally lose fewer timer events than other Windows versions.
149 |
150 |
151 |
152 |
153 |
154 | Comments
155 |
156 | SimpleTimer is free for personal and commercial use. Feel free to use and improve it,
157 | but please include all original files if you redistribute the zip-file.
158 | If you have any comments or corrections I would very much like to hear them.
159 |
160 |
161 |
162 | Get the latest version from
163 | http://subsimple.com/delphi.asp.
164 |
165 |
166 |
167 | Troels Jakobsen
168 | troels.jakobsen@gmail.com
169 |
170 |
171 |
172 |
173 |
--------------------------------------------------------------------------------
/Source/SimpleTimer.pas:
--------------------------------------------------------------------------------
1 | {*****************************************************************}
2 | { SimpleTimer is a timer class. It has the same timer resolution }
3 | { as TTimer, but it is more lightweight because it's derived from }
4 | { TObject in stead of TComponent. Furthermore, the same handle is }
5 | { shared between multiple instances of SimpleTimer. }
6 | { This makes it ideal for developers who need a timer in their }
7 | { own components or applications, but want to keep the resource }
8 | { usage minimal. }
9 | { }
10 | { The unit is freeware. Feel free to use and improve it. }
11 | { I would be pleased to hear what you think. }
12 | { }
13 | { Troels Jakobsen - troels.jakobsen@gmail.com }
14 | { Copyright (c) 2006 }
15 | {*****************************************************************}
16 |
17 | unit SimpleTimer;
18 |
19 | { Some methods have moved to the Classes unit in D6 and are thus deprecated.
20 | Using the following compiler directives we handle that situation. }
21 | {$DEFINE DELPHI_6_UP}
22 | {$IFDEF VER80} {$UNDEF DELPHI_6_UP} {$ENDIF} // D1
23 | {$IFDEF VER90} {$UNDEF DELPHI_6_UP} {$ENDIF} // D2
24 | {$IFDEF VER100} {$UNDEF DELPHI_6_UP} {$ENDIF} // D3
25 | {$IFDEF VER120} {$UNDEF DELPHI_6_UP} {$ENDIF} // D4
26 | {$IFDEF VER130} {$UNDEF DELPHI_6_UP} {$ENDIF} // D5
27 | {$IFDEF VER93} {$UNDEF DELPHI_6_UP} {$ENDIF} // BCB1
28 | {$IFDEF VER110} {$UNDEF DELPHI_6_UP} {$ENDIF} // BCB3
29 | {$IFDEF VER125} {$UNDEF DELPHI_6_UP} {$ENDIF} // BCB4
30 | {$IFDEF VER135} {$UNDEF DELPHI_6_UP} {$ENDIF} // BCB5
31 |
32 | interface
33 |
34 | uses
35 | Windows, Classes;
36 |
37 | type
38 | TSimpleTimer = class(TObject)
39 | private
40 | FId: UINT;
41 | FEnabled: Boolean;
42 | FInterval: Cardinal;
43 | FAutoDisable: Boolean;
44 | FTag: Integer;
45 | FOnTimer: TNotifyEvent;
46 | procedure SetEnabled(Value: Boolean);
47 | procedure SetInterval(Value: Cardinal);
48 | procedure SetOnTimer(Value: TNotifyEvent);
49 | procedure Initialize(AInterval: Cardinal; AOnTimer: TNotifyEvent);
50 | protected
51 | function Start: Boolean;
52 | function Stop(Disable: Boolean): Boolean;
53 | public
54 | constructor Create;
55 | constructor CreateEx(AInterval: Cardinal; AOnTimer: TNotifyEvent);
56 | destructor Destroy; override;
57 | property Enabled: Boolean read FEnabled write SetEnabled;
58 | property Interval: Cardinal read FInterval write SetInterval default 1000;
59 | property AutoDisable: Boolean read FAutoDisable write FAutoDisable;
60 | property Tag: Integer read Ftag write Ftag default 0;
61 | property OnTimer: TNotifyEvent read FOnTimer write SetOnTimer;
62 | end;
63 |
64 | function GetSimpleTimerCount: Cardinal;
65 | function GetSimpleTimerActiveCount: Cardinal;
66 |
67 |
68 | implementation
69 |
70 | uses
71 | Messages{$IFNDEF DELPHI_6_UP}, Forms {$ENDIF};
72 |
73 | type
74 | TSimpleTimerHandler = class(TObject)
75 | private
76 | RefCount: Cardinal;
77 | ActiveCount: Cardinal;
78 | FWindowHandle: HWND;
79 | procedure WndProc(var Msg: TMessage);
80 | public
81 | constructor Create;
82 | destructor Destroy; override;
83 | procedure AddTimer;
84 | procedure RemoveTimer;
85 | end;
86 |
87 | var
88 | SimpleTimerHandler: TSimpleTimerHandler = nil;
89 |
90 |
91 | function GetSimpleTimerCount: Cardinal;
92 | begin
93 | if Assigned(SimpleTimerHandler) then
94 | Result := SimpleTimerHandler.RefCount
95 | else
96 | Result := 0;
97 | end;
98 |
99 |
100 | function GetSimpleTimerActiveCount: Cardinal;
101 | begin
102 | if Assigned(SimpleTimerHandler) then
103 | Result := SimpleTimerHandler.ActiveCount
104 | else
105 | Result := 0;
106 | end;
107 |
108 | {--------------- TSimpleTimerHandler ------------------}
109 |
110 | constructor TSimpleTimerHandler.Create;
111 | begin
112 | inherited Create;
113 | {$IFDEF DELPHI_6_UP}
114 | FWindowHandle := Classes.AllocateHWnd(WndProc);
115 | {$ELSE}
116 | FWindowHandle := AllocateHWnd(WndProc);
117 | {$ENDIF}
118 | end;
119 |
120 |
121 | destructor TSimpleTimerHandler.Destroy;
122 | begin
123 | {$IFDEF DELPHI_6_UP}
124 | Classes.DeallocateHWnd(FWindowHandle);
125 | {$ELSE}
126 | DeallocateHWnd(FWindowHandle);
127 | {$ENDIF}
128 | inherited Destroy;
129 | end;
130 |
131 |
132 | procedure TSimpleTimerHandler.AddTimer;
133 | begin
134 | Inc(RefCount);
135 | end;
136 |
137 |
138 | procedure TSimpleTimerHandler.RemoveTimer;
139 | begin
140 | if RefCount > 0 then
141 | Dec(RefCount);
142 | end;
143 |
144 |
145 | procedure TSimpleTimerHandler.WndProc(var Msg: TMessage);
146 | var
147 | Timer: TSimpleTimer;
148 | begin
149 | if Msg.Msg = WM_TIMER then
150 | begin
151 | {$WARNINGS OFF}
152 | Timer := TSimpleTimer(Msg.wParam);
153 | {$WARNINGS ON}
154 | if Timer.FAutoDisable then
155 | Timer.Stop(True);
156 | // Call OnTimer event method if assigned
157 | if Assigned(Timer.FOnTimer) then
158 | Timer.FOnTimer(Timer);
159 | end
160 | else
161 | Msg.Result := DefWindowProc(FWindowHandle, Msg.Msg, Msg.wParam, Msg.lParam);
162 | end;
163 |
164 | {---------------- Container management ----------------}
165 |
166 | procedure AddTimer;
167 | begin
168 | if not Assigned(SimpleTimerHandler) then
169 | // Create new handler
170 | SimpleTimerHandler := TSimpleTimerHandler.Create;
171 | SimpleTimerHandler.AddTimer;
172 | end;
173 |
174 |
175 | procedure RemoveTimer;
176 | begin
177 | if Assigned(SimpleTimerHandler) then
178 | begin
179 | SimpleTimerHandler.RemoveTimer;
180 | if SimpleTimerHandler.RefCount = 0 then
181 | begin
182 | // Destroy handler
183 | SimpleTimerHandler.Free;
184 | SimpleTimerHandler := nil;
185 | end;
186 | end;
187 | end;
188 |
189 | {------------------- TSimpleTimer ---------------------}
190 |
191 | constructor TSimpleTimer.Create;
192 | begin
193 | inherited Create;
194 | Initialize(1000, nil);
195 | end;
196 |
197 |
198 | constructor TSimpleTimer.CreateEx(AInterval: Cardinal; AOnTimer: TNotifyEvent);
199 | begin
200 | inherited Create;
201 | Initialize(AInterval, AOnTimer);
202 | end;
203 |
204 |
205 | destructor TSimpleTimer.Destroy;
206 | begin
207 | if FEnabled then
208 | Stop(True);
209 | RemoveTimer; // Container management
210 | inherited Destroy;
211 | end;
212 |
213 |
214 | procedure TSimpleTimer.Initialize(AInterval: Cardinal; AOnTimer: TNotifyEvent);
215 | begin
216 | {$WARNINGS OFF}
217 | FId := UINT(Self); // Use Self as id in call to SetTimer and callback method
218 | {$WARNINGS ON}
219 | FAutoDisable := False;
220 | FEnabled := False;
221 | FInterval := AInterval;
222 | SetOnTimer(AOnTimer);
223 | AddTimer; // Container management
224 | end;
225 |
226 |
227 | procedure TSimpleTimer.SetEnabled(Value: Boolean);
228 | begin
229 | if Value then
230 | Start
231 | else
232 | Stop(True);
233 | end;
234 |
235 |
236 | procedure TSimpleTimer.SetInterval(Value: Cardinal);
237 | begin
238 | if Value <> FInterval then
239 | begin
240 | FInterval := Value;
241 | if FEnabled then
242 | if FInterval <> 0 then
243 | Start
244 | else
245 | Stop(False);
246 | end;
247 | end;
248 |
249 |
250 | procedure TSimpleTimer.SetOnTimer(Value: TNotifyEvent);
251 | begin
252 | FOnTimer := Value;
253 | if (not Assigned(Value)) and (FEnabled) then
254 | Stop(False);
255 | end;
256 |
257 |
258 | function TSimpleTimer.Start: Boolean;
259 | begin
260 | if FInterval = 0 then
261 | begin
262 | Result := False;
263 | Exit;
264 | end;
265 | if FEnabled then
266 | Stop(True);
267 | // Result := (SetTimer(SimpleTimerHandler.FWindowHandle, FId, FInterval, @TimerProc) <> 0);
268 | Result := (SetTimer(SimpleTimerHandler.FWindowHandle, FId, FInterval, nil) <> 0);
269 | if Result then
270 | begin
271 | FEnabled := True;
272 | Inc(SimpleTimerHandler.ActiveCount);
273 | end
274 | { else
275 | raise EOutOfResources.Create(SNoTimers); }
276 | end;
277 |
278 |
279 | function TSimpleTimer.Stop(Disable: Boolean): Boolean;
280 | begin
281 | if Disable then
282 | FEnabled := False;
283 | Result := KillTimer(SimpleTimerHandler.FWindowHandle, FId);
284 | if Result and (SimpleTimerHandler.ActiveCount > 0) then
285 | Dec(SimpleTimerHandler.ActiveCount);
286 | end;
287 |
288 |
289 | initialization
290 |
291 | finalization
292 | if Assigned(SimpleTimerHandler) then
293 | begin
294 | SimpleTimerHandler.Free;
295 | SimpleTimerHandler := nil;
296 | end;
297 |
298 | end.
299 |
300 |
--------------------------------------------------------------------------------
/docs/TextTrayIcon.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TextTrayIcon, ver. 1.2.1
5 |
6 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | TextTrayIcon, ver. 1.2.1
24 |
25 |
26 | [Properties] [Methods] [Events]
27 |
28 | [Hints] [Known Bugs] [Comments]
29 |
30 |
31 |
32 |
33 | TextTrayIcon is a tray icon component. It is an extended version of the CoolTrayIcon
34 | component, so you need CoolTrayIcon to make it work.
35 |
36 |
37 |
38 | TextTrayIcon allows you to easily show custom text inside the tray icon. If you need
39 | tray icons with just regular icons I suggest you use CoolTrayIcon in stead.
40 |
41 |
42 |
43 | This document describes only the added features of TextTrayIcon. For an explanation of
44 | all the standard features of this tray icon component, see the CoolTrayIcon documentation.
45 |
46 |
47 |
48 | Properties
49 |
50 |
51 |
52 | | Text |
53 | property Text: String;
54 | The text to show in the tray icon. The text is always centered horizontally and vertically.
55 | NOTE: You can have multiple lines of text. Separate the lines with
56 | #13 (CR). |
57 |
|
58 |
59 |
60 | | Font |
61 | property Font: TFont;
62 | The font to use when drawing the text. |
63 |
|
64 |
65 |
66 | | Color |
67 | property Color: TColor;
68 | The (background) color of the tray icon. Use clBtnFace to show it in the color of
69 | the task bar. |
70 | Default clBtnFace |
71 |
72 |
73 | | Border |
74 | property Border: Boolean;
75 | Whether to draw a border at the edges of the tray icon.
76 | This is a rectangle 1 px. wide using the color specified by BorderColor. |
77 | Default false |
78 |
79 |
80 | | BorderColor |
81 | property BorderColor: TColor;
82 | The color of the tray icon's border rectangle. |
83 | Default clBlack |
84 |
85 |
86 | | BackgroundIcon |
87 | property BackgroundIcon: TIcon;
88 | If no background icon is specified the tray icon will be rendered using the text,
89 | font, color, and border properties you've specified.
90 | If a background icon is specified then it will be rendered beneath the text as if the
91 | tray icon was transparent. In other words: the background color is ignored and the
92 | background icon is shown in stead. |
93 | Default true |
94 |
95 |
96 | | Options |
97 | You will likely prefer to adjust the text inside the
98 | tray icon. Use the following layout options for that purpose:
99 |
100 |
101 | | OffsetX |
102 | property OffsetX: Integer;
103 | Adjusts the text X pixels horizontally. |
104 |
105 |
106 | | OffsetY |
107 | property OffsetY: Integer;
108 | Adjusts the text Y pixels vertically. |
109 |
110 |
111 | | LineDistance |
112 | property LineDistance: Integer;
113 | Adds or deletes pixels between multiple lines of text.
114 | A value of -2 is a good idea in most cases of multiline text. |
115 |
116 |
117 | |
118 |
|
119 |
120 |
121 |
122 |
123 |
124 | Methods
125 |
126 |
127 |
128 | | Draw |
129 | procedure Draw;
130 | Redraws the tray icon using the current colors, font, and
131 | border properties described above.
132 | NOTE: The tray icon is automatically redrawn when one of those
133 | properties change.
134 | NOTE: Calling Draw directly (or by assigning to one of the properties mentioned)
135 | will set CycleIcons to false, as it doesn't make sense to draw an icon and then
136 | immediately replace it with a new one. |
137 |
138 |
139 |
140 |
141 |
142 | Events
143 |
144 | No new events.
145 |
146 |
147 |
148 | Hints
149 |
150 |
151 | - What are some good rules for showing text in a tray icon?
152 | You only have 16x16 pixels to draw inside, so use only 1 or 2 lines of text. Use
153 | high contrast colors, like white background and black text, perhaps with a border.
154 | Don't use fonts with serifs. For multiline text I think the font 'Small Fonts'
155 | approx. size 6 looks best. Set OffsetY to -1 and LineDistance to -2.
156 | NOTE: It's easy to experiment if you enable the DesignPreview property.
157 |
158 |
159 | - How do I start my app. with the tray icon visible and the main form invisible?
160 | At design time set IconVisible to true and set the form's Visible property to false.
161 | Set the ShowMainForm parameter to false in the OnStartup event. See the StartHidden demo.
162 |
163 |
164 | - What is the proper way to restore the form?
165 | ALWAYS use the method ShowMainForm! This method contains important calls that affect
166 | how the form and the application display themselves. Simply setting the form visible
167 | or calling Application.Restore is not enough. A common symptom is the form with tabpages
168 | that don't update themselves because ShowMainForm wasn't used.
169 |
170 |
171 |
172 |
173 |
174 | Known Bugs
175 |
176 |
187 | See the bugs documentation for the CoolTrayIcon component.
188 |
189 |
190 |
191 | Comments
192 |
193 | The TextTrayIcon component is free for personal and commercial use
194 | (along with the CoolTrayIcon component). Feel free to use and improve it,
195 | but please include all original files if you redistribute the zip-file.
196 | If you have any comments or corrections to the component I would very much like
197 | to hear them.
198 |
199 |
200 |
201 | The component should work on any Windows platform (Win9x, ME, NT, 2000, XP, 2003, Vista).
202 | If you experience any problems related to the operating system you use, please tell me.
203 | Also, it should work in Delphi 3 and up (Delphi 2?) and C++Builder 3 and up.
204 | Again, tell me if I'm wrong.
205 |
206 |
207 |
208 | Get the latest version from
209 | http://subsimple.com/delphi.asp.
210 |
211 |
212 |
213 | Troels Jakobsen
214 | troels.jakobsen@gmail.com
215 |
216 |
217 |
218 |
219 |
--------------------------------------------------------------------------------
/demos/MinimizeAnimation/TrayAnimation.pas:
--------------------------------------------------------------------------------
1 | unit TrayAnimation;
2 |
3 | { D5 and below don't support alpha-blending (transparent forms). }
4 | {$DEFINE DELPHI_6_UP}
5 | {$IFDEF VER80} {$UNDEF DELPHI_6_UP} {$ENDIF}
6 | {$IFDEF VER90} {$UNDEF DELPHI_6_UP} {$ENDIF}
7 | {$IFDEF VER100} {$UNDEF DELPHI_6_UP} {$ENDIF}
8 | {$IFDEF VER120} {$UNDEF DELPHI_6_UP} {$ENDIF}
9 | {$IFDEF VER130} {$UNDEF DELPHI_6_UP} {$ENDIF}
10 |
11 | interface
12 |
13 | uses
14 | Windows, Classes, Graphics, Forms;
15 |
16 | type
17 | TWindowFader = class(TThread)
18 | private
19 | BlendValue: Integer;
20 | procedure Fade;
21 | public
22 | FadeOut: Boolean;
23 | procedure Execute; override;
24 | end;
25 |
26 | TWindowImploder = class(TThread)
27 | private
28 | X, Y, W, H: Integer;
29 | procedure Implode;
30 | public
31 | Imploding: Boolean;
32 | procedure Execute; override;
33 | end;
34 |
35 | TWindowOutlineImploder = class(TThread)
36 | private
37 | X, Y, W, H: Integer;
38 | DesktopCanvas: TCanvas;
39 | procedure Implode;
40 | public
41 | Imploding: Boolean;
42 | constructor Create;
43 | destructor Destroy; override;
44 | procedure Execute; override;
45 | end;
46 |
47 |
48 | procedure FloatingRectangles(Minimizing, OverrideUserSettings: Boolean);
49 |
50 | implementation
51 |
52 | uses
53 | Math, ShellApi, Messages, Main;
54 |
55 | {----------------- Stand-alone methods ----------------}
56 |
57 | procedure FloatingRectangles(Minimizing, OverrideUserSettings: Boolean);
58 | var
59 | RectFrom, RectTo: TRect;
60 | GotRectTo: Boolean;
61 | abd: TAppBarData;
62 | HTaskbar, HTrayWnd: HWND;
63 | ResetRegistry: Boolean;
64 | ai: TAnimationInfo;
65 |
66 | procedure SetAnimation(Animation: Boolean);
67 | begin
68 | FillChar(ai, SizeOf(ai), 0);
69 | ai.cbSize := SizeOf(ai);
70 | if Animation then
71 | ai.iMinAnimate := 1
72 | else
73 | ai.iMinAnimate := 0;
74 | SystemParametersInfo(SPI_SETANIMATION, 0, @ai, SPIF_SENDCHANGE);
75 | end;
76 |
77 | begin
78 | // Check if user wants window animation
79 | ResetRegistry := False;
80 | if OverrideUserSettings then
81 | begin
82 | FillChar(ai, SizeOf(ai), 0);
83 | ai.cbSize := SizeOf(ai);
84 | SystemParametersInfo(SPI_GETANIMATION, 0, @ai, SPIF_SENDCHANGE);
85 | if ai.iMinAnimate = 0 then
86 | begin
87 | // Temporarily enable window animation
88 | ResetRegistry := True;
89 | SetAnimation(True);
90 | end;
91 | end;
92 |
93 | RectFrom := MainForm.BoundsRect;
94 | GotRectTo := False;
95 |
96 | // Get the traybar's bounding rectangle
97 | HTaskbar := FindWindow('Shell_TrayWnd', nil);
98 | if HTaskbar <> 0 then
99 | begin
100 | HTrayWnd := FindWindowEx(HTaskbar, 0, 'TrayNotifyWnd', nil);
101 | if HTrayWnd <> 0 then
102 | if GetWindowRect(HTrayWnd, RectTo) then
103 | GotRectTo := True;
104 | end;
105 |
106 | // If that fails, invent a rectangle in the corner where the traybar is
107 | if not GotRectTo then
108 | begin
109 | FillChar(abd, SizeOf(abd), 0);
110 | abd.cbSize := SizeOf(abd);
111 | if SHAppBarMessage(ABM_GETTASKBARPOS, abd) = 0 then Exit;
112 | with Screen, abd.rc do
113 | if (Top > 0) or (Left > 0) then
114 | RectTo := Rect(Width-32, Height-32, Width, Height)
115 | else if (Bottom < Height) then
116 | RectTo := Rect(Width-32, 0, Width, 32)
117 | else if (Right < Width) then
118 | RectTo := Rect(0, Height-32, 32, Height);
119 | end;
120 |
121 | if Minimizing then
122 | DrawAnimatedRects(MainForm.Handle, IDANI_CAPTION, RectFrom, RectTo)
123 | else
124 | DrawAnimatedRects(MainForm.Handle, IDANI_CAPTION, RectTo, RectFrom);
125 |
126 | if ResetRegistry then
127 | SetAnimation(False); // Disable window animation
128 | end;
129 |
130 | {-------------------- TWindowFader --------------------}
131 |
132 | procedure TWindowFader.Execute;
133 | begin
134 | {$IFDEF DELPHI_6_UP}
135 | BlendValue := MainForm.AlphaBlendValue;
136 | {$ENDIF}
137 | while not Terminated do
138 | begin
139 | if FadeOut then
140 | Dec(BlendValue, 25)
141 | else
142 | Inc(BlendValue, 25);
143 | Sleep(10);
144 | // Application.ProcessMessages;
145 | Synchronize(Fade);
146 | if (BlendValue <= 0) or (BlendValue >= 255) then
147 | Terminate;
148 | end;
149 | end;
150 |
151 |
152 | procedure TWindowFader.Fade;
153 | begin
154 | {$IFDEF DELPHI_6_UP}
155 | if (BlendValue >= 0) and (BlendValue <= 255) then
156 | MainForm.AlphaBlendValue := BlendValue;
157 | {$ENDIF}
158 | end;
159 |
160 | {------------------ TWindowImploder -------------------}
161 |
162 | procedure TWindowImploder.Execute;
163 | const
164 | minW = 120;
165 | minH = 25;
166 | deltaGrowth = 0.2;
167 | var
168 | maxW, maxH: Integer;
169 | deltaW, deltaH: Integer;
170 | begin
171 | with MainForm do
172 | begin
173 | X := Left;
174 | Y := Top;
175 | W := Width;
176 | H := Height;
177 | if Imploding then
178 | begin
179 | // Store current form size
180 | StartX := Left;
181 | StartY := Top;
182 | StartW := Width;
183 | StartH := Height;
184 | end;
185 | // Remember previous form size
186 | maxW := StartW;
187 | maxH := StartH;
188 | end;
189 |
190 | while not Terminated do
191 | begin
192 | deltaW := Round((W-minW) * deltaGrowth);
193 | deltaH := Round((H-minH) * deltaGrowth);
194 | if deltaW = 0 then
195 | Inc(deltaW);
196 | if Odd(deltaW) then
197 | Inc(deltaW);
198 | if deltaH = 0 then
199 | Inc(deltaH);
200 | if Odd(deltaH) then
201 | Inc(deltaH);
202 | if Imploding then
203 | begin
204 | W := W - deltaW;
205 | H := H - deltaH;
206 | X := X + (deltaW div 2);
207 | Y := Y + (deltaH div 2);
208 | end
209 | else
210 | begin
211 | W := W + deltaW;
212 | H := H + deltaH;
213 | X := X - (deltaW div 2);
214 | Y := Y - (deltaH div 2);
215 | end;
216 | Sleep(10);
217 |
218 | if (Imploding and ((W <= minW) or (H <= minH) or (deltaW = 0))) or
219 | (not Imploding and ((W >= maxW) or (H >= maxH) or (deltaH = 0))) then
220 | Terminate;
221 |
222 | if not Terminated then
223 | Synchronize(Implode);
224 | Application.ProcessMessages;
225 | end;
226 |
227 | if not Imploding then
228 | begin
229 | with MainForm do
230 | SetWindowPos(Handle, 0, StartX, StartY, StartW, StartH, SWP_NOZORDER);
231 | Application.ProcessMessages;
232 | end;
233 | end;
234 |
235 |
236 | procedure TWindowImploder.Implode;
237 | begin
238 | SetWindowPos(MainForm.Handle, 0, X, Y, W, H, SWP_NOZORDER);
239 | end;
240 |
241 | {--------------- TWindowOutlineImploder ---------------}
242 |
243 | constructor TWindowOutlineImploder.Create;
244 | begin
245 | inherited Create(False);
246 | DesktopCanvas := TCanvas.Create;
247 | with DesktopCanvas do
248 | begin
249 | Handle := GetDC(0); // HDC of desktop
250 | // Handle := GetWindowDC(GetDesktopWindow);
251 | Pen.Mode := pmNotXor;
252 | Pen.Style := psDot;
253 | Pen.Width := 2;
254 | Pen.Color := clGray;
255 | // Brush.Color := clGray;
256 | // Brush.Style := bsDiagCross;
257 | Brush.Style := bsClear;
258 | end;
259 | end;
260 |
261 |
262 | destructor TWindowOutlineImploder.Destroy;
263 | begin
264 | // ReleaseDC(GetDesktopWindow, DesktopCanvas.Handle);
265 | ReleaseDC(0, DesktopCanvas.Handle);
266 | DesktopCanvas.Handle := 0;
267 | DesktopCanvas.Free;
268 | DesktopCanvas := nil;
269 | inherited Destroy;
270 | end;
271 |
272 |
273 | procedure TWindowOutlineImploder.Execute;
274 | const
275 | minW = 25;
276 | minH = 25;
277 | deltaGrowth = 0.25;
278 | var
279 | maxW, maxH: Integer;
280 | deltaW, deltaH: Integer;
281 | begin
282 | with MainForm do
283 | begin
284 | if Imploding then
285 | begin
286 | X := Left;
287 | Y := Top;
288 | W := Width;
289 | H := Height;
290 | // Store current form size
291 | StartX := Left;
292 | StartY := Top;
293 | StartW := Width;
294 | StartH := Height;
295 | CoolTrayIcon1.HideMainForm;
296 | end
297 | else
298 | begin
299 | X := StartX + ((StartW-minW) div 2);
300 | Y := StartY + ((StartH-minH) div 2);
301 | W := minW;
302 | H := minH;
303 | end;
304 | // Remember previous form size
305 | maxW := StartW;
306 | maxH := StartH;
307 | end;
308 |
309 | while not Terminated do
310 | begin
311 | deltaW := Round((W-minW) * deltaGrowth);
312 | deltaH := Round((H-minH) * deltaGrowth);
313 | if deltaW = 0 then
314 | Inc(deltaW);
315 | if Odd(deltaW) then
316 | Inc(deltaW);
317 | if deltaH = 0 then
318 | Inc(deltaH);
319 | if Odd(deltaH) then
320 | Inc(deltaH);
321 | if Imploding then
322 | begin
323 | W := W - deltaW;
324 | H := H - deltaH;
325 | X := X + (deltaW div 2);
326 | Y := Y + (deltaH div 2);
327 | end
328 | else
329 | begin
330 | W := W + deltaW;
331 | H := H + deltaH;
332 | X := X - (deltaW div 2);
333 | Y := Y - (deltaH div 2);
334 | end;
335 | Synchronize(Implode);
336 |
337 | if (Imploding and ((W <= minW) or (H <= minH) or (deltaW = 0))) or
338 | (not Imploding and ((W >= maxW) or (H >= maxH) or (deltaH = 0))) then
339 | Terminate;
340 | end;
341 | end;
342 |
343 |
344 | procedure TWindowOutlineImploder.Implode;
345 | {var
346 | R: TRect;}
347 | begin
348 | if not Terminated then
349 | if (DesktopCanvas <> nil) and (DesktopCanvas.Handle <> 0) then
350 | begin
351 | // R := Rect(X, Y, X+W, Y+H);
352 | // InvalidateRect(DesktopCanvas.Handle, @R, True);
353 | // PostMessage(DesktopCanvas.Handle, WM_SETREDRAW, 1, 0);
354 | // RedrawWindow(DesktopCanvas.Handle, 0, 0, RDW_ERASE or RDW_INVALIDATE or RDW_ERASENOW);
355 | // UpdateWindow(DesktopCanvas.Handle);
356 | DesktopCanvas.Rectangle(X, Y, X+W, Y+H);
357 | Sleep(10);
358 | DesktopCanvas.Rectangle(X, Y, X+W, Y+H);
359 | end;
360 | end;
361 |
362 | end.
363 |
364 |
--------------------------------------------------------------------------------
/demos/CoolTrayTest/CtMain.pas:
--------------------------------------------------------------------------------
1 | unit CtMain;
2 |
3 | interface
4 |
5 | uses
6 | Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls,
7 | ExtCtrls, Menus, ImgList, CoolTrayIcon;
8 |
9 | type
10 | TMainForm = class(TForm)
11 | Button1: TButton;
12 | Button2: TButton;
13 | Button3: TButton;
14 | PopupMenu1: TPopupMenu;
15 | ShowWindow1: TMenuItem;
16 | HideWindow1: TMenuItem;
17 | N1: TMenuItem;
18 | Exit1: TMenuItem;
19 | ImageList1: TImageList;
20 | rdoCycle: TRadioGroup;
21 | GroupBox1: TGroupBox;
22 | Label1: TLabel;
23 | Label2: TLabel;
24 | GroupBox2: TGroupBox;
25 | Label3: TLabel;
26 | Edit1: TEdit;
27 | CheckBox1: TCheckBox;
28 | CheckBox2: TCheckBox;
29 | CheckBox3: TCheckBox;
30 | CheckBox4: TCheckBox;
31 | CheckBox5: TCheckBox;
32 | CheckBox6: TCheckBox;
33 | Label7: TLabel;
34 | ComboBox1: TComboBox;
35 | TrayIcon1: TCoolTrayIcon;
36 | Edit2: TEdit;
37 | Label4: TLabel;
38 | ImageList2: TImageList;
39 | ImageList3: TImageList;
40 | ImageList4: TImageList;
41 | ImageList5: TImageList;
42 | ImageList6: TImageList;
43 | Button4: TButton;
44 | N2: TMenuItem;
45 | BalloonHint1: TMenuItem;
46 | GroupBox3: TGroupBox;
47 | Label5: TLabel;
48 | Label6: TLabel;
49 | Button5: TButton;
50 | Button6: TButton;
51 | ImageList7: TImageList;
52 | Button7: TButton;
53 | procedure FormCreate(Sender: TObject);
54 | procedure ShowWindow1Click(Sender: TObject);
55 | procedure HideWindow1Click(Sender: TObject);
56 | procedure Exit1Click(Sender: TObject);
57 | procedure Button1Click(Sender: TObject);
58 | procedure Button2Click(Sender: TObject);
59 | procedure Edit1Change(Sender: TObject);
60 | procedure CheckBox1Click(Sender: TObject);
61 | procedure CheckBox2Click(Sender: TObject);
62 | procedure TrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
63 | Shift: TShiftState; X, Y: Integer);
64 | procedure TrayIcon1MouseMove(Sender: TObject; Shift: TShiftState;
65 | X, Y: Integer);
66 | procedure CheckBox3Click(Sender: TObject);
67 | procedure CheckBox4Click(Sender: TObject);
68 | procedure CheckBox5Click(Sender: TObject);
69 | procedure ComboBox1Change(Sender: TObject);
70 | procedure rdoCycleClick(Sender: TObject);
71 | procedure TrayIcon1Cycle(Sender: TObject; NextIndex: Integer);
72 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
73 | procedure Button4Click(Sender: TObject);
74 | procedure TrayIcon1MouseExit(Sender: TObject);
75 | procedure TrayIcon1MouseEnter(Sender: TObject);
76 | procedure TrayIcon1Startup(Sender: TObject; var ShowMainForm: Boolean);
77 | procedure TrayIcon1BalloonHintClick(Sender: TObject);
78 | procedure Button5Click(Sender: TObject);
79 | procedure Button6Click(Sender: TObject);
80 | procedure Button7Click(Sender: TObject);
81 | private
82 | // Some extra stuff necessary for the "Close to tray" option:
83 | SessionEnding: Boolean;
84 | procedure WMQueryEndSession(var Message: TMessage); message WM_QUERYENDSESSION;
85 | end;
86 |
87 | var
88 | MainForm: TMainForm;
89 |
90 | implementation
91 |
92 | {$R *.DFM}
93 |
94 | procedure TMainForm.FormCreate(Sender: TObject);
95 | begin
96 | Edit1Change(Self);
97 | CheckBox1Click(Self);
98 | CheckBox2Click(Self);
99 | CheckBox3Click(Self);
100 | CheckBox4Click(Self);
101 | CheckBox5Click(Self);
102 | rdoCycleClick(Self);
103 | ComboBox1.ItemIndex := 0;
104 | end;
105 |
106 |
107 | procedure TMainForm.ShowWindow1Click(Sender: TObject);
108 | begin
109 | TrayIcon1.ShowMainForm; // ALWAYS use this method to restore!!!
110 | end;
111 |
112 |
113 | procedure TMainForm.HideWindow1Click(Sender: TObject);
114 | begin
115 | Application.Minimize; // Will hide dialogs and popup windows as well (this demo has none)
116 | TrayIcon1.HideMainForm;
117 | end;
118 |
119 |
120 | procedure TMainForm.Exit1Click(Sender: TObject);
121 | begin
122 | // We kill the "Close to tray" feature to be able to exit.
123 | if CheckBox6.Checked then
124 | CheckBox6.Checked := False;
125 | Close;
126 | end;
127 |
128 |
129 | procedure TMainForm.Button1Click(Sender: TObject);
130 | begin
131 | HideWindow1Click(Self);
132 | end;
133 |
134 |
135 | procedure TMainForm.Button2Click(Sender: TObject);
136 | begin
137 | TrayIcon1.IconVisible := not TrayIcon1.IconVisible;
138 | end;
139 |
140 |
141 | procedure TMainForm.Button6Click(Sender: TObject);
142 | begin
143 | if IsWindowVisible(Application.Handle) then
144 | TrayIcon1.HideTaskbarIcon
145 | else
146 | TrayIcon1.ShowTaskbarIcon;
147 | end;
148 |
149 |
150 | procedure TMainForm.Button4Click(Sender: TObject);
151 | begin
152 | TrayIcon1.ShowBalloonHint('Balloon hint',
153 | 'Use the balloon hint to display important information.' + #13 +
154 | 'The text can be max. 255 chars. and the title max. 64 chars.',
155 | bitInfo, 10);
156 | end;
157 |
158 |
159 | procedure TMainForm.Button5Click(Sender: TObject);
160 | begin
161 | TrayIcon1.HideBalloonHint;
162 | end;
163 |
164 |
165 | procedure TMainForm.Button7Click(Sender: TObject);
166 | begin
167 | TrayIcon1.SetFocus;
168 | end;
169 |
170 |
171 | procedure TMainForm.Edit1Change(Sender: TObject);
172 | begin
173 | TrayIcon1.Hint := Edit1.Text;
174 | end;
175 |
176 |
177 | procedure TMainForm.CheckBox1Click(Sender: TObject);
178 | begin
179 | TrayIcon1.ShowHint := CheckBox1.Checked;
180 | end;
181 |
182 |
183 | procedure TMainForm.CheckBox2Click(Sender: TObject);
184 | begin
185 | { Setting the popupmenu's AutoPopup to false will prevent the menu from displaying
186 | when you click the tray icon. You can still show the menu programmatically,
187 | using the Popup or PopupAtCursor methods. }
188 | if Assigned(PopupMenu1) then
189 | PopupMenu1.AutoPopup := CheckBox2.Checked;
190 | end;
191 |
192 |
193 | procedure TMainForm.CheckBox3Click(Sender: TObject);
194 | begin
195 | TrayIcon1.LeftPopup := CheckBox3.Checked;
196 | end;
197 |
198 |
199 | procedure TMainForm.CheckBox4Click(Sender: TObject);
200 | begin
201 | TrayIcon1.Enabled := CheckBox4.Checked;
202 | end;
203 |
204 |
205 | procedure TMainForm.CheckBox5Click(Sender: TObject);
206 | begin
207 | TrayIcon1.MinimizeToTray := CheckBox5.Checked;
208 | end;
209 |
210 |
211 | procedure TMainForm.ComboBox1Change(Sender: TObject);
212 | begin
213 | TrayIcon1.Behavior := TBehavior(ComboBox1.ItemIndex);
214 | end;
215 |
216 |
217 | procedure TMainForm.TrayIcon1MouseDown(Sender: TObject;
218 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
219 | begin
220 | if Assigned(PopupMenu1) then
221 | if not PopupMenu1.AutoPopup then
222 | begin
223 | SetForegroundWindow(Application.Handle); // Move focus from tray icon to this form
224 | MessageDlg('The popup menu is disabled.', mtInformation, [mbOk], 0);
225 | end;
226 | end;
227 |
228 |
229 | procedure TMainForm.TrayIcon1MouseMove(Sender: TObject; Shift: TShiftState;
230 | X, Y: Integer);
231 | var
232 | Pt: TPoint;
233 | begin
234 | Label1.Caption := 'Mouse pos.: ' + IntToStr(X) + ',' + IntToStr(Y);
235 | Label2.Caption := 'Key status: ';
236 | if ssCtrl in Shift then
237 | Label2.Caption := Label2.Caption + ' Ctrl ';
238 | if ssAlt in Shift then
239 | Label2.Caption := Label2.Caption + ' Alt ';
240 | if ssShift in Shift then
241 | Label2.Caption := Label2.Caption + ' Shift ';
242 | // Get client coords.
243 | Pt := TrayIcon1.GetClientIconPos(X, Y);
244 | Label6.Caption := 'Client pos.: ' + IntToStr(Pt.X) + ',' + IntToStr(Pt.Y);
245 | end;
246 |
247 |
248 | procedure TMainForm.rdoCycleClick(Sender: TObject);
249 | begin
250 | case rdoCycle.ItemIndex of
251 | 0: begin
252 | TrayIcon1.CycleIcons := False;
253 | TrayIcon1.IconList := nil;
254 | ImageList1.GetIcon(0, TrayIcon1.Icon);
255 | Edit2.Text := IntToStr(TrayIcon1.IconIndex);
256 | end;
257 | 1: begin
258 | TrayIcon1.IconList := ImageList1;
259 | TrayIcon1.CycleInterval := 400;
260 | TrayIcon1.CycleIcons := True;
261 | end;
262 | 2: begin
263 | TrayIcon1.IconList := ImageList2;
264 | TrayIcon1.CycleInterval := 400;
265 | TrayIcon1.CycleIcons := True;
266 | end;
267 | 3: begin
268 | TrayIcon1.IconList := ImageList3;
269 | TrayIcon1.CycleInterval := 300;
270 | TrayIcon1.CycleIcons := True;
271 | end;
272 | 4: begin
273 | TrayIcon1.IconList := ImageList4;
274 | TrayIcon1.CycleInterval := 100;
275 | TrayIcon1.CycleIcons := True;
276 | end;
277 | 5: begin
278 | TrayIcon1.IconList := ImageList5;
279 | TrayIcon1.CycleInterval := 400;
280 | TrayIcon1.CycleIcons := True;
281 | end;
282 | 6: begin
283 | TrayIcon1.IconList := ImageList6;
284 | TrayIcon1.CycleInterval := 100;
285 | TrayIcon1.CycleIcons := True;
286 | end;
287 | 7: begin
288 | TrayIcon1.IconList := ImageList7;
289 | TrayIcon1.CycleInterval := 150;
290 | TrayIcon1.CycleIcons := True;
291 | end;
292 | end;
293 | end;
294 |
295 |
296 | procedure TMainForm.TrayIcon1Cycle(Sender: TObject; NextIndex: Integer);
297 | begin
298 | Edit2.Text := IntToStr(TrayIcon1.IconIndex);
299 | end;
300 |
301 |
302 | procedure TMainForm.WMQueryEndSession(var Message: TMessage);
303 | { This method is a hack. It intercepts the WM_QUERYENDSESSION message.
304 | This way we can decide if we want to ignore the "Close to tray" option.
305 | Otherwise, when selected, the option would make Windows unable to shut down. }
306 | begin
307 | SessionEnding := True;
308 | Message.Result := 1;
309 | end;
310 |
311 |
312 | procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
313 | begin
314 | CanClose := ((not CheckBox6.Checked) or SessionEnding);
315 | if not CanClose then
316 | begin
317 | TrayIcon1.HideMainForm;
318 | TrayIcon1.IconVisible := True;
319 | end;
320 | end;
321 |
322 |
323 | procedure TMainForm.TrayIcon1MouseEnter(Sender: TObject);
324 | begin
325 | Label5.Caption := 'ENTER';
326 | end;
327 |
328 |
329 | procedure TMainForm.TrayIcon1MouseExit(Sender: TObject);
330 | begin
331 | Label5.Caption := 'EXIT';
332 | end;
333 |
334 |
335 | procedure TMainForm.TrayIcon1Startup(Sender: TObject; var ShowMainForm: Boolean);
336 | begin
337 | // ShowMainForm := False;
338 | end;
339 |
340 |
341 | procedure TMainForm.TrayIcon1BalloonHintClick(Sender: TObject);
342 | begin
343 | SetForegroundWindow(Application.Handle); // Move focus from tray icon to this form
344 | ShowMessage('POP!');
345 | end;
346 |
347 | end.
348 |
349 |
--------------------------------------------------------------------------------
/Source/CoolTrayIcon.inc:
--------------------------------------------------------------------------------
1 | {$T-} // Use untyped pointers as we override TNotifyIconData with TNotifyIconDataEx
2 |
3 | {$IFDEF VER80} {$DEFINE DELPHI_1} {$ENDIF}
4 | {$IFDEF VER90} {$DEFINE DELPHI_2} {$ENDIF}
5 | {$IFDEF VER100} {$DEFINE DELPHI_3} {$ENDIF}
6 | {$IFDEF VER120} {$DEFINE DELPHI_4} {$ENDIF}
7 | {$IFDEF VER130} {$DEFINE DELPHI_5} {$ENDIF}
8 | {$IFDEF VER130} {$DEFINE DELPHI_5} {$ENDIF}
9 | {$IFDEF VER140} // Delphi 6.0
10 | {$DEFINE Delphi2_UP}
11 | {$DEFINE Delphi3_UP}
12 | {$DEFINE Delphi4_UP}
13 | {$DEFINE Delphi5_UP}
14 | {$DEFINE Delphi6_UP}
15 | {$ENDIF}
16 |
17 | {$IFDEF VER150} // Delphi 7.0
18 | {$DEFINE Delphi2_UP}
19 | {$DEFINE Delphi3_UP}
20 | {$DEFINE Delphi4_UP}
21 | {$DEFINE Delphi5_UP}
22 | {$DEFINE Delphi6_UP}
23 | {$DEFINE Delphi7_UP}
24 | {$ENDIF}
25 |
26 | {$IFDEF VER170} // Delphi 9.0
27 | {$DEFINE Delphi2_UP}
28 | {$DEFINE Delphi3_UP}
29 | {$DEFINE Delphi4_UP}
30 | {$DEFINE Delphi5_UP}
31 | {$DEFINE Delphi6_UP}
32 | {$DEFINE Delphi7_UP}
33 | {$DEFINE Delphi9_UP}
34 | {$ENDIF}
35 |
36 | {$IFDEF VER180} // Delphi 10.0
37 | {$DEFINE Delphi2_UP}
38 | {$DEFINE Delphi3_UP}
39 | {$DEFINE Delphi4_UP}
40 | {$DEFINE Delphi5_UP}
41 | {$DEFINE Delphi6_UP}
42 | {$DEFINE Delphi7_UP}
43 | {$DEFINE Delphi9_UP}
44 | {$DEFINE Delphi10_UP}
45 | {$ENDIF}
46 |
47 | {$IFDEF VER185} // Delphi 11.0
48 | {$DEFINE Delphi2_UP}
49 | {$DEFINE Delphi3_UP}
50 | {$DEFINE Delphi4_UP}
51 | {$DEFINE Delphi5_UP}
52 | {$DEFINE Delphi6_UP}
53 | {$DEFINE Delphi7_UP}
54 | {$DEFINE Delphi9_UP}
55 | {$DEFINE Delphi10_UP}
56 | {$DEFINE Delphi11_UP}
57 | {$ENDIF}
58 |
59 | {$IFDEF VER190} // Delphi 11.0
60 | {$DEFINE Delphi2_UP}
61 | {$DEFINE Delphi3_UP}
62 | {$DEFINE Delphi4_UP}
63 | {$DEFINE Delphi5_UP}
64 | {$DEFINE Delphi6_UP}
65 | {$DEFINE Delphi7_UP}
66 | {$DEFINE Delphi9_UP}
67 | {$DEFINE Delphi10_UP}
68 | {$DEFINE Delphi11_UP}
69 | {$ENDIF}
70 |
71 | {$IFDEF VER200} // Delphi 12.0 (2009)
72 | {$DEFINE Delphi2_UP}
73 | {$DEFINE Delphi3_UP}
74 | {$DEFINE Delphi4_UP}
75 | {$DEFINE Delphi5_UP}
76 | {$DEFINE Delphi6_UP}
77 | {$DEFINE Delphi7_UP}
78 | {$DEFINE Delphi9_UP}
79 | {$DEFINE Delphi10_UP}
80 | {$DEFINE Delphi11_UP}
81 | {$DEFINE Delphi12_UP}
82 | {$ENDIF}
83 |
84 | {$IFDEF VER210} // Delphi 14.0 (2010)
85 | {$DEFINE Delphi2_UP}
86 | {$DEFINE Delphi3_UP}
87 | {$DEFINE Delphi4_UP}
88 | {$DEFINE Delphi5_UP}
89 | {$DEFINE Delphi6_UP}
90 | {$DEFINE Delphi7_UP}
91 | {$DEFINE Delphi9_UP}
92 | {$DEFINE Delphi10_UP}
93 | {$DEFINE Delphi11_UP}
94 | {$DEFINE Delphi12_UP}
95 | {$DEFINE Delphi14_UP}
96 | {$ENDIF}
97 |
98 | {$IFDEF VER220} // Delphi 15.0 (XE)
99 | {$DEFINE Delphi2_UP}
100 | {$DEFINE Delphi3_UP}
101 | {$DEFINE Delphi4_UP}
102 | {$DEFINE Delphi5_UP}
103 | {$DEFINE Delphi6_UP}
104 | {$DEFINE Delphi7_UP}
105 | {$DEFINE Delphi9_UP}
106 | {$DEFINE Delphi10_UP}
107 | {$DEFINE Delphi11_UP}
108 | {$DEFINE Delphi12_UP}
109 | {$DEFINE Delphi14_UP}
110 | {$DEFINE Delphi15_UP}
111 | {$ENDIF}
112 |
113 | {$IFDEF VER230} // Delphi XE2 (16.0)
114 | {$DEFINE Delphi2_UP}
115 | {$DEFINE Delphi3_UP}
116 | {$DEFINE Delphi4_UP}
117 | {$DEFINE Delphi5_UP}
118 | {$DEFINE Delphi6_UP}
119 | {$DEFINE Delphi7_UP}
120 | {$DEFINE Delphi9_UP}
121 | {$DEFINE Delphi10_UP}
122 | {$DEFINE Delphi11_UP}
123 | {$DEFINE Delphi12_UP}
124 | {$DEFINE Delphi14_UP}
125 | {$DEFINE Delphi15_UP}
126 | {$DEFINE Delphi16_UP}
127 | {$ENDIF}
128 |
129 | {$IFDEF VER240} // Delphi XE3 (17.0)
130 | {$DEFINE Delphi2_UP}
131 | {$DEFINE Delphi3_UP}
132 | {$DEFINE Delphi4_UP}
133 | {$DEFINE Delphi5_UP}
134 | {$DEFINE Delphi6_UP}
135 | {$DEFINE Delphi7_UP}
136 | {$DEFINE Delphi9_UP}
137 | {$DEFINE Delphi10_UP}
138 | {$DEFINE Delphi11_UP}
139 | {$DEFINE Delphi12_UP}
140 | {$DEFINE Delphi14_UP}
141 | {$DEFINE Delphi15_UP}
142 | {$DEFINE Delphi16_UP}
143 | {$DEFINE Delphi17_UP}
144 | {$ENDIF}
145 | {$IFDEF VER250} // Delphi XE4 (18.0)
146 | {$DEFINE Delphi2_UP}
147 | {$DEFINE Delphi3_UP}
148 | {$DEFINE Delphi4_UP}
149 | {$DEFINE Delphi5_UP}
150 | {$DEFINE Delphi6_UP}
151 | {$DEFINE Delphi7_UP}
152 | {$DEFINE Delphi9_UP}
153 | {$DEFINE Delphi10_UP}
154 | {$DEFINE Delphi11_UP}
155 | {$DEFINE Delphi12_UP}
156 | {$DEFINE Delphi14_UP}
157 | {$DEFINE Delphi15_UP}
158 | {$DEFINE Delphi16_UP}
159 | {$DEFINE Delphi17_UP}
160 | {$DEFINE Delphi18_UP}
161 | {$ENDIF}
162 | {$IFDEF VER250} // Delphi XE4 (18.0)
163 | {$DEFINE Delphi2_UP}
164 | {$DEFINE Delphi3_UP}
165 | {$DEFINE Delphi4_UP}
166 | {$DEFINE Delphi5_UP}
167 | {$DEFINE Delphi6_UP}
168 | {$DEFINE Delphi7_UP}
169 | {$DEFINE Delphi9_UP}
170 | {$DEFINE Delphi10_UP}
171 | {$DEFINE Delphi11_UP}
172 | {$DEFINE Delphi12_UP}
173 | {$DEFINE Delphi14_UP}
174 | {$DEFINE Delphi15_UP}
175 | {$DEFINE Delphi16_UP}
176 | {$DEFINE Delphi17_UP}
177 | {$DEFINE Delphi18_UP}
178 | {$ENDIF}
179 | {$IFDEF VER260} // Delphi XE5 (19.0)
180 | {$DEFINE Delphi2_UP}
181 | {$DEFINE Delphi3_UP}
182 | {$DEFINE Delphi4_UP}
183 | {$DEFINE Delphi5_UP}
184 | {$DEFINE Delphi6_UP}
185 | {$DEFINE Delphi7_UP}
186 | {$DEFINE Delphi9_UP}
187 | {$DEFINE Delphi10_UP}
188 | {$DEFINE Delphi11_UP}
189 | {$DEFINE Delphi12_UP}
190 | {$DEFINE Delphi14_UP}
191 | {$DEFINE Delphi15_UP}
192 | {$DEFINE Delphi16_UP}
193 | {$DEFINE Delphi17_UP}
194 | {$DEFINE Delphi18_UP}
195 | {$DEFINE Delphi19_UP}
196 | {$ENDIF}
197 | {$IFDEF VER270} // Delphi XE6 (20.0)
198 | {$DEFINE Delphi2_UP}
199 | {$DEFINE Delphi3_UP}
200 | {$DEFINE Delphi4_UP}
201 | {$DEFINE Delphi5_UP}
202 | {$DEFINE Delphi6_UP}
203 | {$DEFINE Delphi7_UP}
204 | {$DEFINE Delphi9_UP}
205 | {$DEFINE Delphi10_UP}
206 | {$DEFINE Delphi11_UP}
207 | {$DEFINE Delphi12_UP}
208 | {$DEFINE Delphi14_UP}
209 | {$DEFINE Delphi15_UP}
210 | {$DEFINE Delphi16_UP}
211 | {$DEFINE Delphi17_UP}
212 | {$DEFINE Delphi18_UP}
213 | {$DEFINE Delphi19_UP}
214 | {$DEFINE Delphi20_UP}
215 | {$ENDIF}
216 | {$IFDEF VER280} // Delphi XE7 (21.0)
217 | {$DEFINE Delphi2_UP}
218 | {$DEFINE Delphi3_UP}
219 | {$DEFINE Delphi4_UP}
220 | {$DEFINE Delphi5_UP}
221 | {$DEFINE Delphi6_UP}
222 | {$DEFINE Delphi7_UP}
223 | {$DEFINE Delphi9_UP}
224 | {$DEFINE Delphi10_UP}
225 | {$DEFINE Delphi11_UP}
226 | {$DEFINE Delphi12_UP}
227 | {$DEFINE Delphi14_UP}
228 | {$DEFINE Delphi15_UP}
229 | {$DEFINE Delphi16_UP}
230 | {$DEFINE Delphi17_UP}
231 | {$DEFINE Delphi18_UP}
232 | {$DEFINE Delphi19_UP}
233 | {$DEFINE Delphi20_UP}
234 | {$DEFINE Delphi21_UP}
235 | {$ENDIF}
236 | {$IFDEF VER290} // Delphi XE8 (22.0)
237 | {$DEFINE Delphi2_UP}
238 | {$DEFINE Delphi3_UP}
239 | {$DEFINE Delphi4_UP}
240 | {$DEFINE Delphi5_UP}
241 | {$DEFINE Delphi6_UP}
242 | {$DEFINE Delphi7_UP}
243 | {$DEFINE Delphi9_UP}
244 | {$DEFINE Delphi10_UP}
245 | {$DEFINE Delphi11_UP}
246 | {$DEFINE Delphi12_UP}
247 | {$DEFINE Delphi14_UP}
248 | {$DEFINE Delphi15_UP}
249 | {$DEFINE Delphi16_UP}
250 | {$DEFINE Delphi17_UP}
251 | {$DEFINE Delphi18_UP}
252 | {$DEFINE Delphi19_UP}
253 | {$DEFINE Delphi20_UP}
254 | {$DEFINE Delphi21_UP}
255 | {$DEFINE Delphi22_UP}
256 | {$ENDIF}
257 | {$IFDEF VER300} // Delphi 10 (23.0)
258 | {$DEFINE Delphi2_UP}
259 | {$DEFINE Delphi3_UP}
260 | {$DEFINE Delphi4_UP}
261 | {$DEFINE Delphi5_UP}
262 | {$DEFINE Delphi6_UP}
263 | {$DEFINE Delphi7_UP}
264 | {$DEFINE Delphi9_UP}
265 | {$DEFINE Delphi10_UP}
266 | {$DEFINE Delphi11_UP}
267 | {$DEFINE Delphi12_UP}
268 | {$DEFINE Delphi14_UP}
269 | {$DEFINE Delphi15_UP}
270 | {$DEFINE Delphi16_UP}
271 | {$DEFINE Delphi17_UP}
272 | {$DEFINE Delphi18_UP}
273 | {$DEFINE Delphi19_UP}
274 | {$DEFINE Delphi20_UP}
275 | {$DEFINE Delphi21_UP}
276 | {$DEFINE Delphi22_UP}
277 | {$DEFINE Delphi23_UP}
278 | {$ENDIF}
279 | {$IFDEF VER310} // Delphi 10.1 Berlin (24.0)
280 | {$DEFINE Delphi2_UP}
281 | {$DEFINE Delphi3_UP}
282 | {$DEFINE Delphi4_UP}
283 | {$DEFINE Delphi5_UP}
284 | {$DEFINE Delphi6_UP}
285 | {$DEFINE Delphi7_UP}
286 | {$DEFINE Delphi9_UP}
287 | {$DEFINE Delphi10_UP}
288 | {$DEFINE Delphi11_UP}
289 | {$DEFINE Delphi12_UP}
290 | {$DEFINE Delphi14_UP}
291 | {$DEFINE Delphi15_UP}
292 | {$DEFINE Delphi16_UP}
293 | {$DEFINE Delphi17_UP}
294 | {$DEFINE Delphi18_UP}
295 | {$DEFINE Delphi19_UP}
296 | {$DEFINE Delphi20_UP}
297 | {$DEFINE Delphi21_UP}
298 | {$DEFINE Delphi22_UP}
299 | {$DEFINE Delphi23_UP}
300 | {$DEFINE Delphi24_UP}
301 | {$ENDIF}
302 | {$IFDEF VER320} // Delphi 10.2 Tokyo (25.0)
303 | {$DEFINE Delphi2_UP}
304 | {$DEFINE Delphi3_UP}
305 | {$DEFINE Delphi4_UP}
306 | {$DEFINE Delphi5_UP}
307 | {$DEFINE Delphi6_UP}
308 | {$DEFINE Delphi7_UP}
309 | {$DEFINE Delphi9_UP}
310 | {$DEFINE Delphi10_UP}
311 | {$DEFINE Delphi11_UP}
312 | {$DEFINE Delphi12_UP}
313 | {$DEFINE Delphi14_UP}
314 | {$DEFINE Delphi15_UP}
315 | {$DEFINE Delphi16_UP}
316 | {$DEFINE Delphi17_UP}
317 | {$DEFINE Delphi18_UP}
318 | {$DEFINE Delphi19_UP}
319 | {$DEFINE Delphi20_UP}
320 | {$DEFINE Delphi21_UP}
321 | {$DEFINE Delphi22_UP}
322 | {$DEFINE Delphi23_UP}
323 | {$DEFINE Delphi24_UP}
324 | {$DEFINE Delphi25_UP}
325 | {$ENDIF}
326 | {$IFDEF VER330} // Delphi 10.3 Rio (26.0)
327 | {$DEFINE Delphi2_UP}
328 | {$DEFINE Delphi3_UP}
329 | {$DEFINE Delphi4_UP}
330 | {$DEFINE Delphi5_UP}
331 | {$DEFINE Delphi6_UP}
332 | {$DEFINE Delphi7_UP}
333 | {$DEFINE Delphi9_UP}
334 | {$DEFINE Delphi10_UP}
335 | {$DEFINE Delphi11_UP}
336 | {$DEFINE Delphi12_UP}
337 | {$DEFINE Delphi14_UP}
338 | {$DEFINE Delphi15_UP}
339 | {$DEFINE Delphi16_UP}
340 | {$DEFINE Delphi17_UP}
341 | {$DEFINE Delphi18_UP}
342 | {$DEFINE Delphi19_UP}
343 | {$DEFINE Delphi20_UP}
344 | {$DEFINE Delphi21_UP}
345 | {$DEFINE Delphi22_UP}
346 | {$DEFINE Delphi23_UP}
347 | {$DEFINE Delphi24_UP}
348 | {$DEFINE Delphi25_UP}
349 | {$DEFINE Delphi26_UP}
350 | {$ENDIF}
351 | {$IFDEF VER340} // Delphi 10.4 Sydney (27.0)
352 | {$DEFINE Delphi2_UP}
353 | {$DEFINE Delphi3_UP}
354 | {$DEFINE Delphi4_UP}
355 | {$DEFINE Delphi5_UP}
356 | {$DEFINE Delphi6_UP}
357 | {$DEFINE Delphi7_UP}
358 | {$DEFINE Delphi9_UP}
359 | {$DEFINE Delphi10_UP}
360 | {$DEFINE Delphi11_UP}
361 | {$DEFINE Delphi12_UP}
362 | {$DEFINE Delphi14_UP}
363 | {$DEFINE Delphi15_UP}
364 | {$DEFINE Delphi16_UP}
365 | {$DEFINE Delphi17_UP}
366 | {$DEFINE Delphi18_UP}
367 | {$DEFINE Delphi19_UP}
368 | {$DEFINE Delphi20_UP}
369 | {$DEFINE Delphi21_UP}
370 | {$DEFINE Delphi22_UP}
371 | {$DEFINE Delphi23_UP}
372 | {$DEFINE Delphi24_UP}
373 | {$DEFINE Delphi25_UP}
374 | {$DEFINE Delphi26_UP}
375 | {$DEFINE Delphi27_UP}
376 | {$ENDIF}
377 | {$IFDEF VER93} {$DEFINE BCB_1} {$ENDIF}
378 | {$IFDEF VER110} {$DEFINE BCB_3} {$ENDIF}
379 | {$IFDEF VER125} {$DEFINE BCB_4} {$ENDIF}
380 | {$IFDEF VER135} {$DEFINE BCB_5} {$ENDIF}
381 |
382 | { Some methods have moved to the Classes unit in D6 and are thus deprecated.
383 | Using the following compiler directives we handle that situation. }
384 | {$DEFINE DELPHI_6_UP}
385 | {$IFDEF DELPHI_1} {$UNDEF DELPHI_6_UP} {$ENDIF}
386 | {$IFDEF DELPHI_2} {$UNDEF DELPHI_6_UP} {$ENDIF}
387 | {$IFDEF DELPHI_3} {$UNDEF DELPHI_6_UP} {$ENDIF}
388 | {$IFDEF DELPHI_4} {$UNDEF DELPHI_6_UP} {$ENDIF}
389 | {$IFDEF DELPHI_5} {$UNDEF DELPHI_6_UP} {$ENDIF}
390 | {$IFDEF BCB_1} {$UNDEF DELPHI_6_UP} {$ENDIF}
391 | {$IFDEF BCB_3} {$UNDEF DELPHI_6_UP} {$ENDIF}
392 | {$IFDEF BCB_4} {$UNDEF DELPHI_6_UP} {$ENDIF}
393 | {$IFDEF BCB_5} {$UNDEF DELPHI_6_UP} {$ENDIF}
394 |
395 | { The TCustomImageList class only exists from D4, so we need special handling
396 | for D2 and D3. We define another compiler directive for this. }
397 | {$DEFINE DELPHI_4_UP}
398 | {$IFDEF DELPHI_1} {$UNDEF DELPHI_4_UP} {$ENDIF}
399 | {$IFDEF DELPHI_2} {$UNDEF DELPHI_4_UP} {$ENDIF}
400 | {$IFDEF DELPHI_3} {$UNDEF DELPHI_4_UP} {$ENDIF}
401 | {$IFDEF BCB_1} {$UNDEF DELPHI_4_UP} {$ENDIF}
402 | {$IFDEF BCB_3} {$UNDEF DELPHI_4_UP} {$ENDIF}
403 |
404 | { I tried to hack around the problem that in some versions of NT4 the tray icon
405 | will not display properly upon logging off, then logging on. It appears to be
406 | a VCL problem. The solution is probably to substitute Delphi's AllocateHWnd
407 | method, but I haven't gotten around to experimenting with that.
408 | For now, leave WINNT_SERVICE_HACK undefined (no special NT handling). }
409 | {$UNDEF WINNT_SERVICE_HACK}
410 |
--------------------------------------------------------------------------------
/Source/TextTrayIcon.pas:
--------------------------------------------------------------------------------
1 | {*****************************************************************}
2 | { This is a component for placing icons in the notification area }
3 | { of the Windows taskbar (aka. the traybar). }
4 | { }
5 | { It is an expanded version of my CoolTrayIcon component, which }
6 | { you will need to make this work. The expanded features allow }
7 | { you to easily draw text in the tray icon. }
8 | { }
9 | { The component is freeware. Feel free to use and improve it. }
10 | { I would be pleased to hear what you think. }
11 | { }
12 | { Troels Jakobsen - troels.jakobsen@gmail.com }
13 | { Copyright (c) 2006 }
14 | { }
15 | { Portions by Jouni Airaksinen - mintus@codefield.com }
16 | {*****************************************************************}
17 |
18 | unit TextTrayIcon;
19 |
20 | interface
21 |
22 | uses
23 | CoolTrayIcon, Windows, Graphics, Classes, Controls;
24 |
25 | type
26 | TOffsetOptions = class(TPersistent)
27 | private
28 | FOffsetX,
29 | FOffsetY,
30 | FLineDistance: Integer;
31 | FOnChange: TNotifyEvent; // Procedure var.
32 | procedure SetOffsetX(Value: Integer);
33 | procedure SetOffsetY(Value: Integer);
34 | procedure SetLineDistance(Value: Integer);
35 | protected
36 | procedure Changed; dynamic;
37 | published
38 | property OffsetX: Integer read FOffsetX write SetOffsetX;
39 | property OffsetY: Integer read FOffsetY write SetOffsetY;
40 | property LineDistance: Integer read FLineDistance write SetLineDistance;
41 | property OnChange: TNotifyEvent read FOnChange write FOnChange;
42 | end;
43 |
44 | TTextTrayIcon = class(TCoolTrayIcon)
45 | private
46 | FFont: TFont;
47 | FColor: TColor;
48 | FInvertTextColor: TColor;
49 | FBorder: Boolean;
50 | FBorderColor: TColor;
51 | FText: String;
52 | FTextBitmap: TBitmap;
53 | FOffsetOptions: TOffsetOptions;
54 | FBackgroundIcon: TIcon;
55 | procedure FontChanged(Sender: TObject);
56 | procedure SplitText(const Strings: TList);
57 | procedure OffsetOptionsChanged(OffsetOptions: TObject);
58 | procedure SetBackgroundIcon(Value: TIcon);
59 | protected
60 | procedure Loaded; override;
61 | function LoadDefaultIcon: Boolean; override;
62 | function LoadDefaultBackgroundIcon: Boolean; virtual;
63 | procedure Paint; virtual;
64 | procedure SetText(Value: String);
65 | procedure SetTextBitmap(Value: TBitmap);
66 | procedure SetFont(Value: TFont);
67 | procedure SetColor(Value: TColor);
68 | procedure SetBorder(Value: Boolean);
69 | procedure SetBorderColor(Value: TColor);
70 | procedure SetOffsetOptions(Value: TOffsetOptions);
71 | function TransparentBitmapToIcon(const Bitmap: TBitmap; const Icon: TIcon;
72 | MaskColor: TColor): Boolean;
73 | public
74 | constructor Create(AOwner: TComponent); override;
75 | destructor Destroy; override;
76 | procedure Draw;
77 | published
78 | property BackgroundIcon: TIcon read FBackgroundIcon write SetBackgroundIcon;
79 | property Text: String read FText write SetText;
80 | property Font: TFont read FFont write SetFont;
81 | property Color: TColor read FColor write SetColor default clBtnFace;
82 | property Border: Boolean read FBorder write SetBorder;
83 | property BorderColor: TColor read FBorderColor write SetBorderColor
84 | default clBlack;
85 | property Options: TOffsetOptions read FOffsetOptions write SetOffsetOptions;
86 | end;
87 |
88 |
89 | implementation
90 |
91 | uses
92 | SysUtils;
93 |
94 | {------------------- TOffsetOptions -------------------}
95 |
96 | procedure TOffsetOptions.Changed;
97 | begin
98 | if Assigned(FOnChange) then FOnChange(Self);
99 | end;
100 |
101 |
102 | procedure TOffsetOptions.SetOffsetX(Value: Integer);
103 | begin
104 | if Value <> FOffsetX then
105 | begin
106 | FOffsetX := Value;
107 | Changed;
108 | end;
109 | end;
110 |
111 |
112 | procedure TOffsetOptions.SetOffsetY(Value: Integer);
113 | begin
114 | if Value <> FOffsetY then
115 | begin
116 | FOffsetY := Value;
117 | Changed;
118 | end;
119 | end;
120 |
121 |
122 | procedure TOffsetOptions.SetLineDistance(Value: Integer);
123 | begin
124 | if Value <> FLineDistance then
125 | begin
126 | FLineDistance := Value;
127 | Changed;
128 | end;
129 | end;
130 |
131 | {------------------- TTextTrayIcon --------------------}
132 |
133 | constructor TTextTrayIcon.Create(AOwner: TComponent);
134 | begin
135 | inherited Create(AOwner);
136 | FBackgroundIcon := TIcon.Create;
137 | FTextBitmap := TBitmap.Create;
138 | FFont := TFont.Create;
139 | FFont.OnChange := FontChanged;
140 | FColor := clBtnFace;
141 | FBorderColor := clBlack;
142 | FOffsetOptions := TOffsetOptions.Create;
143 | FOffsetOptions.OnChange := OffsetOptionsChanged;
144 |
145 | { Assign a default bg. icon if BackgroundIcon property is empty.
146 | This will assign a bg. icon to the component when it is created for
147 | the very first time. When the user assigns another icon it will not
148 | be overwritten next time the project loads.
149 | This is similar to the default Icon in parent class CoolTrayIcon. }
150 | { On second thought: do we really want a default bg. icon? Probably not.
151 | For this reason the class method LoadDefaultBackgroundIcon will
152 | return false. }
153 | if (csDesigning in ComponentState) then
154 | if FBackgroundIcon.Handle = 0 then
155 | if LoadDefaultBackgroundIcon then
156 | begin
157 | FBackgroundIcon.Handle := LoadIcon(0, IDI_WINLOGO);
158 | Draw;
159 | end;
160 | end;
161 |
162 |
163 | destructor TTextTrayIcon.Destroy;
164 | begin
165 | try
166 | FFont.Free;
167 | FTextBitmap.Free;
168 | FOffsetOptions.Free;
169 | try
170 | if FBackgroundIcon <> nil then
171 | FBackgroundIcon.Free;
172 | except
173 | on Exception do
174 | // Do nothing; the background icon seems to be invalid
175 | end;
176 | finally
177 | inherited Destroy;
178 | end;
179 | end;
180 |
181 |
182 | procedure TTextTrayIcon.Loaded;
183 | begin
184 | inherited Loaded; // Always call inherited Loaded first
185 | // No extra handling needed
186 | end;
187 |
188 |
189 | function TTextTrayIcon.LoadDefaultIcon: Boolean;
190 | { We don't want a default icon, so we override this method inherited
191 | from CoolTrayIcon. }
192 | begin
193 | Result := False; // No thanks, no default icon
194 | end;
195 |
196 |
197 | function TTextTrayIcon.LoadDefaultBackgroundIcon: Boolean;
198 | { This method is called to determine whether to assign a default bg. icon
199 | to the component. Descendant classes can override the method to change
200 | this behavior. }
201 | begin
202 | Result := False; // No thanks, no default bg. icon
203 | end;
204 |
205 |
206 | procedure TTextTrayIcon.FontChanged(Sender: TObject);
207 | { This method is invoked when user assigns to Font (but not when Font is set
208 | directly to another TFont var.) }
209 | begin
210 | Draw;
211 | end;
212 |
213 |
214 | procedure TTextTrayIcon.SetText(Value: String);
215 | begin
216 | FText := Value;
217 | Draw;
218 | end;
219 |
220 |
221 | procedure TTextTrayIcon.SetTextBitmap(Value: TBitmap);
222 | begin
223 | FTextBitmap := Value; // Assign?
224 | Draw;
225 | end;
226 |
227 |
228 | procedure TTextTrayIcon.SetFont(Value: TFont);
229 | begin
230 | FFont.Assign(Value);
231 | Draw;
232 | end;
233 |
234 |
235 | procedure TTextTrayIcon.SetColor(Value: TColor);
236 | begin
237 | FColor := Value;
238 | Draw;
239 | end;
240 |
241 |
242 | procedure TTextTrayIcon.SetBorder(Value: Boolean);
243 | begin
244 | FBorder := Value;
245 | Draw;
246 | end;
247 |
248 |
249 | procedure TTextTrayIcon.SetBorderColor(Value: TColor);
250 | begin
251 | FBorderColor := Value;
252 | Draw;
253 | end;
254 |
255 |
256 | procedure TTextTrayIcon.SetOffsetOptions(Value: TOffsetOptions);
257 | { This method will only be invoked if the user creates a new
258 | TOffsetOptions object. User will probably just set the values
259 | of the existing TOffsetOptions object. }
260 | begin
261 | FOffsetOptions.Assign(Value);
262 | Draw;
263 | end;
264 |
265 |
266 | procedure TTextTrayIcon.OffsetOptionsChanged(OffsetOptions: TObject);
267 | { This method will be invoked when the user changes the values of the
268 | existing TOffsetOptions object. }
269 | begin
270 | Draw;
271 | end;
272 |
273 |
274 | procedure TTextTrayIcon.SetBackgroundIcon(Value: TIcon);
275 | begin
276 | FBackgroundIcon.Assign(Value);
277 | Draw;
278 | end;
279 |
280 |
281 | procedure TTextTrayIcon.Draw;
282 | var
283 | Ico: TIcon;
284 | rc: Boolean;
285 | begin
286 | CycleIcons := False; // We cannot cycle and draw at the same time
287 | Paint; // Render FTextBitmap
288 | Ico := TIcon.Create;
289 | if (Assigned(FBackgroundIcon)) and not (FBackgroundIcon.Empty) then
290 | // Draw text transparently on background icon
291 | rc := TransparentBitmapToIcon(FTextBitmap, Ico, FColor)
292 | else
293 | begin
294 | // Just draw text; no background icon
295 | if FColor <> clNone then
296 | FInvertTextColor := clNone;
297 | rc := BitmapToIcon(FTextBitmap, Ico, FInvertTextColor);
298 | end;
299 |
300 | if rc then
301 | begin
302 | Icon.Assign(Ico);
303 | // Refresh; // Always refresh after icon assignment
304 | Ico.Free;
305 | end;
306 | end;
307 |
308 |
309 | function TTextTrayIcon.TransparentBitmapToIcon(const Bitmap: TBitmap;
310 | const Icon: TIcon; MaskColor: TColor): Boolean;
311 | { Render an icon from a 16x16 bitmap. Return false if error.
312 | MaskColor is a color that will be rendered transparently. Use clNone for
313 | no transparency. }
314 | var
315 | BitmapImageList: TImageList;
316 | Bmp: TBitmap;
317 | FInvertColor: TColor;
318 | begin
319 | BitmapImageList := TImageList.CreateSize(16, 16);
320 | try
321 | Result := False;
322 | BitmapImageList.AddIcon(FBackgroundIcon);
323 | Bmp := TBitmap.Create;
324 |
325 | if (FColor = clNone) or (FColor = FFont.Color) then
326 | FInvertColor := ColorToRGB(FFont.Color) xor $00FFFFFF
327 | else
328 | FInvertColor := MaskColor;
329 |
330 | Bmp.Canvas.Brush.Color := FInvertColor;
331 | BitmapImageList.GetBitmap(0, Bmp);
332 | Bitmap.Transparent := True;
333 | Bitmap.TransParentColor := FInvertTextColor;
334 | Bmp.Canvas.Draw(0, 0, Bitmap);
335 |
336 | BitmapImageList.AddMasked(Bmp, FInvertColor);
337 | BitmapImageList.GetIcon(1, Icon);
338 | Bmp.Free;
339 | Result := True;
340 | finally
341 | BitmapImageList.Free;
342 | end;
343 | end;
344 |
345 |
346 | procedure TTextTrayIcon.Paint;
347 | var
348 | Bitmap: TBitmap;
349 | Left, Top, LinesTop, LineHeight: Integer;
350 | Substr: PChar;
351 | Strings: TList;
352 | I: Integer;
353 | begin
354 | Bitmap := TBitmap.Create;
355 | try
356 | Bitmap.Width := 16;
357 | Bitmap.Height := 16;
358 | // Bitmap.Canvas.TextFlags := 2; // ETO_OPAQUE
359 |
360 | // Render background rectangle
361 | if (FColor = clNone) or (FColor = FFont.Color) then
362 | FInvertTextColor := ColorToRGB(FFont.Color) xor $00FFFFFF
363 | else
364 | FInvertTextColor := FColor;
365 | Bitmap.Canvas.Brush.Color := FInvertTextColor;
366 | Bitmap.Canvas.FillRect(Rect(0, 0, 16, 16));
367 |
368 | // Render text; check for line breaks
369 | Bitmap.Canvas.Font.Assign(FFont);
370 | Substr := StrPos(PChar(FText), #13);
371 | if Substr = nil then
372 | begin
373 | // No line breaks
374 | Left := (15 - Bitmap.Canvas.TextWidth(FText)) div 2;
375 | if FOffsetOptions <> nil then
376 | Left := Left + FOffsetOptions.OffsetX;
377 | Top := (15 - Bitmap.Canvas.TextHeight(FText)) div 2;
378 | if FOffsetOptions <> nil then
379 | Top := Top + FOffsetOptions.OffsetY;
380 | Bitmap.Canvas.TextOut(Left, Top, FText);
381 | end
382 | else
383 | begin
384 | // Line breaks
385 | Strings := TList.Create;
386 | SplitText(Strings);
387 | LineHeight := Bitmap.Canvas.TextHeight(Substr);
388 | if FOffsetOptions <> nil then
389 | LineHeight := LineHeight + FOffsetOptions.LineDistance;
390 | LinesTop := (15 - (LineHeight * Strings.Count)) div 2;
391 | if FOffsetOptions <> nil then
392 | LinesTop := LinesTop + FOffsetOptions.OffsetY;
393 | for I := 0 to Strings.Count -1 do
394 | begin
395 | Substr := Strings[I];
396 | Left := (15 - Bitmap.Canvas.TextWidth(Substr)) div 2;
397 | if FOffsetOptions <> nil then
398 | Left := Left + FOffsetOptions.OffsetX;
399 | Top := LinesTop + (LineHeight * I);
400 | Bitmap.Canvas.TextOut(Left, Top, Substr);
401 | end;
402 | for I := 0 to Strings.Count -1 do
403 | StrDispose(PWideChar(Strings[I]));
404 | Strings.Free;
405 | end;
406 |
407 | // Render border
408 | if FBorder then
409 | begin
410 | Bitmap.Canvas.Brush.Color := FBorderColor;
411 | Bitmap.Canvas.FrameRect(Rect(0, 0, 16, 16));
412 | end;
413 |
414 | // Assign the final bitmap
415 | FTextBitmap.Assign(Bitmap);
416 |
417 | finally
418 | Bitmap.Free;
419 | end;
420 | end;
421 |
422 |
423 | procedure TTextTrayIcon.SplitText(const Strings: TList);
424 |
425 | function PeekedString(S: String): String;
426 | var
427 | P: Integer;
428 | begin
429 | P := Pos(#13, S);
430 | if P = 0 then
431 | Result := S
432 | else
433 | Result := Copy(S, 1, P-1);
434 | end;
435 |
436 | var
437 | Substr: String;
438 | P: Integer;
439 | S: PChar;
440 | begin
441 | Strings.Clear;
442 | Substr := FText;
443 | repeat
444 | P := Pos(#13, Substr);
445 | if P = 0 then
446 | begin
447 | S := StrNew(PChar(Substr));
448 | Strings.Add(S);
449 | end
450 | else
451 | begin
452 | S := StrNew(PChar(PeekedString(Substr)));
453 | Strings.Add(S);
454 | Delete(Substr, 1, P);
455 | end;
456 | until P = 0;
457 | end;
458 |
459 | end.
460 |
461 |
--------------------------------------------------------------------------------
/demos/demo.dsk:
--------------------------------------------------------------------------------
1 | [Closed Files]
2 | File_0=TSourceModule,'E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\source\CoolTrayIcon.pas',0,1,188,1,193,0,0,,
3 | File_1=TSourceModule,'E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\source\TextTrayIcon.pas',0,1,23,26,23,0,0,,
4 | File_2=TSourceModule,'c:\program files\codegear\rad studio\6.0\SOURCE\WIN32\RTL\SYS\SysUtils.pas',0,1,7858,64,7872,0,0,,
5 | File_3=TSourceModule,'c:\program files\codegear\rad studio\6.0\source\Win32\rtl\common\Classes.pas',0,1,156,1,165,0,0,,
6 | File_4=TSourceModule,'D:\tool\net\wget\WinWget_src\src\fMain.pas',0,1,1,1,1,0,0,,
7 | File_5=TSourceModule,'D:\MyDocs\work\AutoTestTool\int2Hex\Unit1.pas',0,1,1,18,50,0,0,,
8 | File_6=TSourceModule,'D:\MyDocs\work\AutoTestTool\acTimer\frmMain.pas',0,1,51,37,58,0,0,,
9 | File_7=TSourceModule,'E:\soft\develop\delphi\example\ftp\TFTPCode\Unit1.cpp',0,1,26,26,51,0,0,,
10 | File_8=TSourceModule,'D:\MyDocs\work\AutoTestTool\TestTool\Main.pas',0,1,131,1,346,0,0,,
11 | File_9=TSourceModule,'D:\MyDocs\work\AutoTestTool\TestTool\UntFun.pas',0,1,1,16,24,0,0,,
12 |
13 | [Modules]
14 | Module0=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\TrayDraw.dproj
15 | Module1=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\CtDraw.pas
16 | Module2=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TextTrayTest.dproj
17 | Module3=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TtMain.pas
18 | Module4=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\StartHidden.dproj
19 | Module5=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\Main.pas
20 | Module6=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\MinimizeAnimation.dproj
21 | Module7=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\Main.pas
22 | Module8=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHintDemo.dproj
23 | Module9=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHint.pas
24 | Module10=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\CustomHint.dproj
25 | Module11=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\Main.pas
26 | Module12=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolService\CoolService.dproj
27 | Module13=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CoolTrayTest.dproj
28 | Module14=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CtMain.pas
29 | Count=15
30 | EditWindowCount=1
31 |
32 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\TrayDraw.dproj]
33 | ModuleType=TBaseProject
34 |
35 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\CtDraw.pas]
36 | ModuleType=TSourceModule
37 | FormState=1
38 | FormOnTop=1
39 |
40 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TextTrayTest.dproj]
41 | ModuleType=TBaseProject
42 |
43 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TtMain.pas]
44 | ModuleType=TSourceModule
45 | FormState=1
46 | FormOnTop=1
47 |
48 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\StartHidden.dproj]
49 | ModuleType=TBaseProject
50 |
51 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\Main.pas]
52 | ModuleType=TSourceModule
53 | FormState=1
54 | FormOnTop=1
55 |
56 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\MinimizeAnimation.dproj]
57 | ModuleType=TBaseProject
58 |
59 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\Main.pas]
60 | ModuleType=TSourceModule
61 | FormState=1
62 | FormOnTop=1
63 |
64 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHintDemo.dproj]
65 | ModuleType=TBaseProject
66 |
67 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHint.pas]
68 | ModuleType=TSourceModule
69 | FormState=1
70 | FormOnTop=1
71 |
72 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\CustomHint.dproj]
73 | ModuleType=TBaseProject
74 |
75 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\Main.pas]
76 | ModuleType=TSourceModule
77 | FormState=1
78 | FormOnTop=1
79 |
80 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolService\CoolService.dproj]
81 | ModuleType=TBaseProject
82 |
83 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CoolTrayTest.dproj]
84 | ModuleType=TBaseProject
85 |
86 | [E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CtMain.pas]
87 | ModuleType=TSourceModule
88 | FormState=1
89 | FormOnTop=1
90 |
91 | [EditWindow0]
92 | ViewCount=15
93 | CurrentEditView=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\TrayDraw.dpr
94 | View0=0
95 | View1=1
96 | View2=2
97 | View3=3
98 | View4=4
99 | View5=5
100 | View6=6
101 | View7=7
102 | View8=8
103 | View9=9
104 | View10=10
105 | View11=11
106 | View12=12
107 | View13=13
108 | View14=14
109 | PercentageSizes=1
110 | Create=1
111 | Visible=1
112 | Docked=0
113 | State=0
114 | Left=1693
115 | Top=1170
116 | Width=6519
117 | Height=8645
118 | MaxLeft=-9
119 | MaxTop=-12
120 | ClientWidth=6450
121 | ClientHeight=8313
122 | DockedToMainForm=0
123 | MessageView=MessageView@EditWindow0
124 | BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0
125 | TopPanelSize=0
126 | LeftPanelSize=0
127 | LeftPanelClients=BorlandEditorCodeExplorer@EditWindow0
128 | LeftPanelData=0000080088880100000019000000426F726C616E64456469746F72436F64654578706C6F726572B40C00000000000000E601000000000000FFFFFFFF
129 | RightPanelSize=0
130 | BottomPanelSize=1655
131 | BottomPanelClients=MessageView@EditWindow0
132 | BottomPanelData=00000800C8C80000000000000000000000000000000000000000000100000000000000000B0000004D65737361676556696577FFFFFFFF
133 | BottomMiddlePanelSize=0
134 | BottomMiddlePanelClients=DockSite0,ToDo List
135 | BottomMiddelPanelData=00000800F8F80200000009000000446F636B53697465300E000000546F446F4C69737457696E646F778F1F00000000000002BB07000000000000FFFFFFFF
136 |
137 | [View0]
138 | CustomEditViewType=TEditView
139 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CtMain.pas
140 | CursorX=1
141 | CursorY=1
142 | TopLine=1
143 | LeftCol=1
144 | Elisions=
145 | Bookmarks=
146 | EditViewName=Borland.FormDesignerView
147 |
148 | [View1]
149 | CustomEditViewType=TEditView
150 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CoolTrayTest.dpr
151 | CursorX=1
152 | CursorY=1
153 | TopLine=1
154 | LeftCol=1
155 | Elisions=
156 | Bookmarks=
157 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolTrayTest\CoolTrayTest.dpr
158 |
159 | [View2]
160 | CustomEditViewType=TEditView
161 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolService\CoolService.dpr
162 | CursorX=1
163 | CursorY=1
164 | TopLine=1
165 | LeftCol=1
166 | Elisions=
167 | Bookmarks=
168 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CoolService\CoolService.dpr
169 |
170 | [View3]
171 | CustomEditViewType=TEditView
172 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\Main.pas
173 | CursorX=1
174 | CursorY=1
175 | TopLine=1
176 | LeftCol=1
177 | Elisions=
178 | Bookmarks=
179 | EditViewName=Borland.FormDesignerView
180 |
181 | [View4]
182 | CustomEditViewType=TEditView
183 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\CustomHint.dpr
184 | CursorX=1
185 | CursorY=1
186 | TopLine=1
187 | LeftCol=1
188 | Elisions=
189 | Bookmarks=
190 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint1\CustomHint.dpr
191 |
192 | [View5]
193 | CustomEditViewType=TEditView
194 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHint.pas
195 | CursorX=1
196 | CursorY=1
197 | TopLine=1
198 | LeftCol=1
199 | Elisions=
200 | Bookmarks=
201 | EditViewName=Borland.FormDesignerView
202 |
203 | [View6]
204 | CustomEditViewType=TEditView
205 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHintDemo.dpr
206 | CursorX=1
207 | CursorY=1
208 | TopLine=1
209 | LeftCol=1
210 | Elisions=
211 | Bookmarks=
212 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\CustomHint2\BigHintDemo.dpr
213 |
214 | [View7]
215 | CustomEditViewType=TEditView
216 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\Main.pas
217 | CursorX=1
218 | CursorY=1
219 | TopLine=1
220 | LeftCol=1
221 | Elisions=
222 | Bookmarks=
223 | EditViewName=Borland.FormDesignerView
224 |
225 | [View8]
226 | CustomEditViewType=TEditView
227 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\MinimizeAnimation.dpr
228 | CursorX=1
229 | CursorY=1
230 | TopLine=1
231 | LeftCol=1
232 | Elisions=
233 | Bookmarks=
234 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\MinimizeAnimation\MinimizeAnimation.dpr
235 |
236 | [View9]
237 | CustomEditViewType=TEditView
238 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\Main.pas
239 | CursorX=1
240 | CursorY=1
241 | TopLine=1
242 | LeftCol=1
243 | Elisions=
244 | Bookmarks=
245 | EditViewName=Borland.FormDesignerView
246 |
247 | [View10]
248 | CustomEditViewType=TEditView
249 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\StartHidden.dpr
250 | CursorX=1
251 | CursorY=1
252 | TopLine=1
253 | LeftCol=1
254 | Elisions=
255 | Bookmarks=
256 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\StartHidden\StartHidden.dpr
257 |
258 | [View11]
259 | CustomEditViewType=TEditView
260 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TtMain.pas
261 | CursorX=1
262 | CursorY=1
263 | TopLine=1
264 | LeftCol=1
265 | Elisions=
266 | Bookmarks=
267 | EditViewName=Borland.FormDesignerView
268 |
269 | [View12]
270 | CustomEditViewType=TEditView
271 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TextTrayTest.dpr
272 | CursorX=1
273 | CursorY=1
274 | TopLine=1
275 | LeftCol=1
276 | Elisions=
277 | Bookmarks=
278 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TextTrayTest\TextTrayTest.dpr
279 |
280 | [View13]
281 | CustomEditViewType=TEditView
282 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\CtDraw.pas
283 | CursorX=1
284 | CursorY=1
285 | TopLine=1
286 | LeftCol=1
287 | Elisions=
288 | Bookmarks=
289 | EditViewName=Borland.FormDesignerView
290 |
291 | [View14]
292 | CustomEditViewType=TEditView
293 | Module=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\TrayDraw.dpr
294 | CursorX=1
295 | CursorY=1
296 | TopLine=1
297 | LeftCol=1
298 | Elisions=
299 | Bookmarks=
300 | EditViewName=E:\soft\develop\delphi\component\trayicon\TCoolTrayIcon\CoolTrayIcon4.4.0\{app}\demos\TrayDraw\TrayDraw.dpr
301 |
302 | [Watches]
303 | Count=0
304 |
305 | [WatchWindow]
306 | WatchColumnWidth=120
307 | WatchShowColumnHeaders=1
308 | PercentageSizes=1
309 | Create=1
310 | Visible=0
311 | Docked=0
312 | State=0
313 | Left=0
314 | Top=3510
315 | Width=2630
316 | Height=1933
317 | MaxLeft=-9
318 | MaxTop=-12
319 | ClientWidth=2561
320 | ClientHeight=1638
321 | TBDockHeight=160
322 | LRDockWidth=2552
323 | Dockable=1
324 | StayOnTop=0
325 |
326 | [Breakpoints]
327 | Count=0
328 |
329 | [AddressBreakpoints]
330 | Count=0
331 |
332 | [Main Window]
333 | PercentageSizes=1
334 | Create=1
335 | Visible=1
336 | Docked=0
337 | State=0
338 | Left=0
339 | Top=0
340 | Width=10000
341 | Height=973
342 | MaxLeft=-9
343 | MaxTop=-12
344 | ClientWidth=9931
345 | ClientHeight=640
346 | BottomPanelSize=0
347 |
348 | [ProjectManager]
349 | PercentageSizes=1
350 | Create=1
351 | Visible=1
352 | Docked=1
353 | State=0
354 | Left=0
355 | Top=0
356 | Width=1719
357 | Height=3498
358 | MaxLeft=-1
359 | MaxTop=-1
360 | ClientWidth=1719
361 | ClientHeight=3498
362 | TBDockHeight=271
363 | LRDockWidth=3733
364 | Dockable=1
365 | StayOnTop=0
366 |
367 | [ToolForm]
368 | PercentageSizes=1
369 | Create=1
370 | Visible=1
371 | Docked=0
372 | State=0
373 | Left=8212
374 | Top=5271
375 | Width=1788
376 | Height=4544
377 | MaxLeft=-9
378 | MaxTop=-12
379 | ClientWidth=1719
380 | ClientHeight=4249
381 | TBDockHeight=5813
382 | LRDockWidth=1406
383 | Dockable=1
384 | StayOnTop=0
385 |
386 | [TemplateView]
387 | PercentageSizes=1
388 | Create=1
389 | Visible=0
390 | Docked=0
391 | State=0
392 | Left=8212
393 | Top=5271
394 | Width=1788
395 | Height=4557
396 | MaxLeft=-9
397 | MaxTop=-12
398 | ClientWidth=1719
399 | ClientHeight=4261
400 | TBDockHeight=369
401 | LRDockWidth=269
402 | Dockable=1
403 | StayOnTop=0
404 | Name=120
405 | Description=334
406 | filter=1
407 |
408 | [DebugLogView]
409 | PercentageSizes=1
410 | Create=1
411 | Visible=0
412 | Docked=0
413 | State=0
414 | Left=2630
415 | Top=7857
416 | Width=3490
417 | Height=2143
418 | MaxLeft=-9
419 | MaxTop=-12
420 | ClientWidth=3420
421 | ClientHeight=1847
422 | TBDockHeight=296
423 | LRDockWidth=3620
424 | Dockable=1
425 | StayOnTop=0
426 |
427 | [ThreadStatusWindow]
428 | PercentageSizes=1
429 | Create=1
430 | Visible=0
431 | Docked=0
432 | State=0
433 | Left=0
434 | Top=7857
435 | Width=2630
436 | Height=2143
437 | MaxLeft=-9
438 | MaxTop=-12
439 | ClientWidth=2561
440 | ClientHeight=1847
441 | TBDockHeight=148
442 | LRDockWidth=5417
443 | Dockable=1
444 | StayOnTop=0
445 | Column0Width=145
446 | Column1Width=100
447 | Column2Width=115
448 | Column3Width=250
449 |
450 | [LocalVarsWindow]
451 | PercentageSizes=1
452 | Create=1
453 | Visible=0
454 | Docked=0
455 | State=0
456 | Left=0
457 | Top=5443
458 | Width=2630
459 | Height=2414
460 | MaxLeft=-9
461 | MaxTop=-12
462 | ClientWidth=2561
463 | ClientHeight=2118
464 | TBDockHeight=197
465 | LRDockWidth=2552
466 | Dockable=1
467 | StayOnTop=0
468 |
469 | [CallStackWindow]
470 | PercentageSizes=1
471 | Create=1
472 | Visible=0
473 | Docked=0
474 | State=0
475 | Left=0
476 | Top=1170
477 | Width=2630
478 | Height=2340
479 | MaxLeft=-9
480 | MaxTop=-12
481 | ClientWidth=2561
482 | ClientHeight=2044
483 | TBDockHeight=160
484 | LRDockWidth=2552
485 | Dockable=1
486 | StayOnTop=0
487 |
488 | [TFileExplorerForm]
489 | PercentageSizes=1
490 | Create=1
491 | Visible=0
492 | Docked=0
493 | State=0
494 | Left=17
495 | Top=800
496 | Width=2161
497 | Height=6897
498 | MaxLeft=-9
499 | MaxTop=-12
500 | ClientWidth=2092
501 | ClientHeight=6601
502 | TBDockHeight=4581
503 | LRDockWidth=2274
504 | Dockable=1
505 | StayOnTop=0
506 |
507 | [FindReferencsForm]
508 | PercentageSizes=1
509 | Create=1
510 | Visible=1
511 | Docked=1
512 | State=0
513 | Left=0
514 | Top=0
515 | Width=4384
516 | Height=1983
517 | MaxLeft=-1
518 | MaxTop=-1
519 | ClientWidth=4384
520 | ClientHeight=1983
521 | TBDockHeight=5086
522 | LRDockWidth=5304
523 | Dockable=1
524 | StayOnTop=0
525 |
526 | [RefactoringForm]
527 | PercentageSizes=1
528 | Create=1
529 | Visible=1
530 | Docked=1
531 | State=0
532 | Left=0
533 | Top=0
534 | Width=4384
535 | Height=1983
536 | MaxLeft=-1
537 | MaxTop=-1
538 | ClientWidth=4384
539 | ClientHeight=1983
540 | TBDockHeight=3830
541 | LRDockWidth=5304
542 | Dockable=1
543 | StayOnTop=0
544 |
545 | [ToDo List]
546 | PercentageSizes=1
547 | Create=1
548 | Visible=0
549 | Docked=1
550 | State=0
551 | Left=0
552 | Top=0
553 | Width=3672
554 | Height=948
555 | MaxLeft=-1
556 | MaxTop=-1
557 | ClientWidth=3672
558 | ClientHeight=948
559 | TBDockHeight=948
560 | LRDockWidth=3672
561 | Dockable=1
562 | StayOnTop=0
563 | Column0Width=270
564 | Column1Width=30
565 | Column2Width=100
566 | Column3Width=70
567 | Column4Width=70
568 | SortOrder=4
569 | ShowHints=1
570 | ShowChecked=1
571 |
572 | [DataExplorer]
573 | PercentageSizes=1
574 | Create=1
575 | Visible=1
576 | Docked=1
577 | State=0
578 | Left=0
579 | Top=0
580 | Width=1719
581 | Height=3498
582 | MaxLeft=-1
583 | MaxTop=-1
584 | ClientWidth=1719
585 | ClientHeight=3498
586 | TBDockHeight=4877
587 | LRDockWidth=7144
588 | Dockable=1
589 | StayOnTop=0
590 |
591 | [PropertyInspector]
592 | PercentageSizes=1
593 | Create=1
594 | Visible=1
595 | Docked=0
596 | State=0
597 | Left=0
598 | Top=4631
599 | Width=1693
600 | Height=5172
601 | MaxLeft=-9
602 | MaxTop=-12
603 | ClientWidth=1623
604 | ClientHeight=4877
605 | TBDockHeight=5813
606 | LRDockWidth=1545
607 | Dockable=1
608 | StayOnTop=0
609 | SplitPos=102
610 |
611 | [ModelViewTool]
612 | PercentageSizes=1
613 | Create=1
614 | Visible=1
615 | Docked=1
616 | State=0
617 | Left=0
618 | Top=0
619 | Width=1719
620 | Height=3498
621 | MaxLeft=-1
622 | MaxTop=-1
623 | ClientWidth=1719
624 | ClientHeight=3498
625 | TBDockHeight=4877
626 | LRDockWidth=5304
627 | Dockable=1
628 | StayOnTop=0
629 |
630 | [BreakpointWindow]
631 | PercentageSizes=1
632 | Create=1
633 | Visible=0
634 | Docked=0
635 | State=0
636 | Left=6111
637 | Top=7857
638 | Width=3889
639 | Height=2143
640 | MaxLeft=-9
641 | MaxTop=-12
642 | ClientWidth=3819
643 | ClientHeight=1847
644 | TBDockHeight=197
645 | LRDockWidth=6398
646 | Dockable=1
647 | StayOnTop=0
648 | Column0Width=200
649 | Column1Width=75
650 | Column2Width=200
651 | Column3Width=200
652 | Column4Width=75
653 | Column5Width=75
654 |
655 | [StructureView]
656 | PercentageSizes=1
657 | Create=1
658 | Visible=1
659 | Docked=0
660 | State=0
661 | Left=0
662 | Top=1170
663 | Width=1693
664 | Height=3473
665 | MaxLeft=-9
666 | MaxTop=-12
667 | ClientWidth=1623
668 | ClientHeight=3177
669 | TBDockHeight=3473
670 | LRDockWidth=1667
671 | Dockable=1
672 | StayOnTop=0
673 |
674 | [MessageView@EditWindow0]
675 | PercentageSizes=1
676 | Create=1
677 | Visible=1
678 | Docked=1
679 | State=0
680 | Left=0
681 | Top=22
682 | Width=6450
683 | Height=1490
684 | MaxLeft=-1
685 | MaxTop=-1
686 | ClientWidth=6450
687 | ClientHeight=1490
688 | TBDockHeight=1490
689 | LRDockWidth=2769
690 | Dockable=1
691 | StayOnTop=0
692 |
693 | [BorlandEditorCodeExplorer@EditWindow0]
694 | PercentageSizes=1
695 | Create=1
696 | Visible=0
697 | Docked=1
698 | State=0
699 | Left=0
700 | Top=0
701 | Width=1467
702 | Height=8264
703 | MaxLeft=-1
704 | MaxTop=-1
705 | ClientWidth=1467
706 | ClientHeight=8264
707 | TBDockHeight=8264
708 | LRDockWidth=1467
709 | Dockable=1
710 | StayOnTop=0
711 |
712 | [DockHosts]
713 | DockHostCount=2
714 |
715 | [DockSite0]
716 | HostDockSite=DockBottomCenterPanel
717 | DockSiteType=1
718 | PercentageSizes=1
719 | Create=1
720 | Visible=0
721 | Docked=1
722 | State=0
723 | Left=0
724 | Top=0
725 | Width=4384
726 | Height=2291
727 | MaxLeft=-1
728 | MaxTop=-1
729 | ClientWidth=4384
730 | ClientHeight=2291
731 | TBDockHeight=2291
732 | LRDockWidth=4384
733 | Dockable=1
734 | StayOnTop=0
735 | TabPosition=1
736 | ActiveTabID=RefactoringForm
737 | TabDockClients=RefactoringForm,FindReferencsForm
738 |
739 | [DockSite1]
740 | DockSiteType=1
741 | PercentageSizes=1
742 | Create=1
743 | Visible=1
744 | Docked=0
745 | State=0
746 | Left=8212
747 | Top=1170
748 | Width=1788
749 | Height=4101
750 | MaxLeft=-9
751 | MaxTop=-12
752 | ClientWidth=1719
753 | ClientHeight=3805
754 | TBDockHeight=3190
755 | LRDockWidth=1441
756 | Dockable=1
757 | StayOnTop=0
758 | TabPosition=1
759 | ActiveTabID=ProjectManager
760 | TabDockClients=ProjectManager,ModelViewTool,DataExplorer
761 |
762 | [ActiveProject]
763 | ActiveProject=8
764 |
765 |
--------------------------------------------------------------------------------
/docs/CoolTrayIcon.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CoolTrayIcon, ver. 4.4.0
5 |
6 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | CoolTrayIcon, ver. 4.4.0
25 |
26 |
27 | [Properties] [Methods] [Events]
28 |
29 | [Hints] [Known Bugs] [Comments]
30 |
31 |
32 |
33 |
34 | CoolTrayIcon is a tray icon component. It allows you to easily implement tray icons
35 | in your own applications, with various appearances and behaviors.
36 |
37 |
38 |
43 |
44 |
45 | Properties
46 |
47 |
48 |
49 | | Icon |
50 | property Icon: TIcon;
51 | The icon to display in the tray. This icon is 16x16 pixels and can be up to 16 colors (4 bit)
52 | in Win9x and WinNT 4, 4 billion colors (32 bit) in WinXP, and WinME and Win2000
53 | support icons of a color depth up to the user's display mode. I don't know about
54 | Win2003 and Vista, but my guess is 32 bit support.
55 | If you use an icon file (*.ico) containing more than one icon, Delphi will use the first icon.
56 | If it's not 16x16 pixels it will be scaled, which probably won't look good.
57 |
63 | |
64 |
|
65 |
66 |
67 | | IconVisible |
68 | property IconVisible: Boolean;
69 | Whether to display the icon. This property has no effect in design mode. |
70 | Default false |
71 |
72 |
73 | | Hint |
74 | type THintString = ShortString;
75 | property Hint: THintString;
76 | The tray icon's hint (max 128 chars), which is displayed when you move the mouse cursor
77 | over the tray icon. Use #13 as a separator in multi-line hints.
78 | NOTE: WinNT doesn't appear to support multi-line hints.
79 | NOTE: On some older Windows versions (before IE 5) the hint is max 64 chars.
80 | NOTE: The time until the hint window closes is determined by Windows,
81 | so don't bother trying to change the interval, because you can't. Setting
82 | Application.HintPause and Application.HintHidePause has no effect.
83 | |
84 |
|
85 |
86 |
87 | | ShowHint |
88 | property ShowHint: Boolean;
89 | Whether to show the hint. |
90 | Default true |
91 |
92 |
93 | | PopupMenu |
94 | property PopupMenu: TPopupMenu;
95 | The popup menu you want to display when the icon is clicked. |
96 | Default true |
97 |
98 |
99 | | LeftPopup |
100 | property LeftPopup: Boolean;
101 | Whether you want the popup menu to pop up when you click the left mouse button.
102 | Default is false, meaning only the right button will work.
103 | NOTE: LeftPopup must be false (or the popup menu unassigned) if you want to
104 | double click the tray icon without displaying the popup menu.
105 | LeftPopup must be false if you want CoolTrayIcon to handle a menu that has a default
106 | menu item. |
107 | Default false |
108 |
109 |
110 | | Enabled |
111 | property Enabled: Boolean;
112 | Works like Enabled for other controls, enabling/disabling keyboard and mouse input.
113 | Useful when you want to temporarily disable the popup menu, say while you are displaying
114 | an about box or some other modal window. |
115 | Default true |
116 |
117 |
118 | | IconList |
119 | property IconList: TCustomImageList;
120 | An ImageList containing icons. If it contains other images than icons, the tray icon
121 | won't change when using CycleIcons, but no error occurs.
122 | NOTE: When you assign to IconList IconIndex is set to 0.
123 | NOTE: In D2 and D3 the property is of type TImageList in stead of TCustomImageList. |
124 |
|
125 |
126 |
127 | | IconIndex |
128 | property IconIndex: Integer;
129 | The current icon in the assigned iconlist (or 0 if no iconlist is assigned). |
130 |
|
131 |
132 |
133 | | CycleIcons |
134 | property CycleIcons: Boolean;
135 | Animates the tray icon by cycling through all the icons stored in IconList and assigning them
136 | to Icon. When you set CycleIcons to true, it will begin with the first icon in IconList.
137 | NOTE: CycleIcons can be true even though you have no IconList.
138 | No cycling will occur in that case, but the cycle timer is still active, which will consume
139 | some resources. |
140 | Default false |
141 |
142 |
143 | | CycleInterval |
144 | property CycleInterval: Cardinal;
145 | The time interval in milisecs. before selecting a new icon from IconList. |
146 |
|
147 |
148 |
149 | | DesignPreview |
150 | property DesignPreview: Boolean;
151 | Enables you to preview the tray icon in design mode. You can watch what the icon looks like,
152 | see its hint, enable/disable it, test the popupmenu, and animate it via CycleIcons.
153 | NOTE: Set DesignPreview to false to avoid the design time icon appearing when you run
154 | your program. This is only a problem in the Delphi IDE, not in the finished exe-file.
155 | I couldn't find a way to kill the design icon in run-time, so you'll have to do it yourself.
156 | NOTE: Setting DesignPreview in run-time has no effect. |
157 | Default false |
158 |
159 |
160 | | Handle |
161 | property Handle: HWND;
162 | The tray icon's handle. |
163 | Read-only |
164 |
165 |
173 |
174 | | WantEnterExitEvents |
175 | property WantEnterExitEvents: Boolean;
176 | Whether you would like to receive the OnMouseEnter and OnMouseExit events.
177 | These events require an internal timer to be active, so if you have no use for them
178 | set WantEnterExitEvents to false to minimize resource usage. |
179 | Default false |
180 |
181 |
182 | | Behavior |
183 | type TBehavior = (bhWin95, bhWin2000);
184 | property Behavior: TBehavior;
185 | This property does not affect the tray icon's behavior in any visible way.
186 | It determines which messages are dispatched to the application when the user interacts
187 | with the tray icon (specifically, right mouse clicks result in a WM_RBUTTONDOWN followed
188 | by a WM_RBUTTONUP message in Win95 mode, but in Win2000 mode a WM_CONTEXTMENU, NIN_SELECT,
189 | or NIN_KEYSELECT message is dispatched. For details, see the Remarks section on
190 | this page).
191 | Probably the only case where you should consider changing the value of this property, is
192 | when you send messages to the tray icon programmatically, using PostMessage or SendMessage.
193 | NOTE: This property is public, not published. |
194 | Default bhWin95 |
195 |
196 |
197 | | MinimizeToTray |
198 | This property applies only when the owner of the
199 | tray icon component is a form.
200 | property MinimizeToTray: Boolean;
201 | Whether you want to hide the main form instead of minimizing it. The form will hide
202 | and the tray icon will show. |
203 | Default false |
204 |
205 |
206 |
207 |
208 |
209 | Methods
210 |
211 |
212 |
213 | | Refresh |
214 | function Refresh: Boolean;
215 | Redraws the tray icon.
216 |
219 | You probably don't need to ever call this method.
220 | |
221 | Returns true or false |
222 |
223 |
224 | | ShowBalloonHint |
225 | type TBalloonHintIcon = (bitNone, bitInfo, bitWarning, bitError, bitCustom);
226 | type TBalloonHintTimeOut = 10..60;
227 | function ShowBalloonHint(Title: String; Text: String; IconType: TBalloonHintIcon; TimeoutSecs: TBalloonHintTimeOut): Boolean;
228 | Shows a balloon hint (a kind of "sticky" popup hint).
229 | You can use up to 64 chars for the title and up to 255 chars for the text.
230 | The hint is visible for 10-60 seconds, or until the user clicks it (or until you
231 | programmatically hide it). You cannot show a balloon hint if the tray icon is not showing,
232 | and hiding the tray icon hides any balloon hint.
233 | NOTE: Balloon hints are not available in Win95 and Win98. Calling this method
234 | in those Windows versions has no effect.
235 | NOTE: From WinXP SP 2 the balloon hint supports a custom icon, which is the
236 | tray icon itself (the Icon property). To do this, set IconType to bitCustom.
237 | If you want the balloon hint to show a custom icon which is not the same as Icon,
238 | you must change Icon before calling ShowBalloonHint, then change Icon back again.
239 | NOTE: The HideBalloonHint method is automatically called by ShowBalloonHint,
240 | so you don't get multiple balloon hints.
241 | NOTE: There appears to be a bug with the timeout value in WinXP.
242 | See bugs section. |
243 | Returns true or false |
244 |
245 |
246 | | HideBalloonHint |
247 | function HideBalloonHint: Boolean;
248 | Hides the balloon hint (if any). |
249 | Returns true or false |
250 |
251 |
252 | | Popup |
253 | procedure Popup(X, Y: Integer);
254 | Shows the associated popupmenu (if any) at the specified screen coordinates. |
255 |
|
256 |
257 |
258 | | PopupAtCursor |
259 | procedure PopupAtCursor;
260 | Shows the associated popupmenu (if any) at the current cursor coordinates.
261 | This method is usually called automatically in response to an OnClick event, but you can
262 | call it manually if you want the popupmenu to appear at other times. |
263 |
|
264 |
265 |
266 | | BitmapToIcon |
267 | function BitmapToIcon(const Bitmap: TBitmap; const Icon: TIcon; MaskColor: TColor): Boolean;
268 | Renders and returns an existing icon based on the specified bitmap.
269 | The bitmap should be 16x16 pixels. Specify a color to be shown transparently or clNone
270 | for no transparency.
271 | NOTE: Bitmaps that are not exactly 16x16 will be scaled up or down. |
272 | Returns true or false |
273 |
274 |
275 | | GetTooltipHandle |
276 | function GetTooltipHandle: HWND;
277 | All tray icons share the same tooltip window (the hint popup).
278 | This method returns the tooltip handle. |
279 | Returns handle or 0 if error |
280 |
281 |
282 | | GetBalloonHintHandle |
283 | function GetBalloonHintHandle: HWND;
284 | All applications share the same balloon hint (if supported by the Windows version).
285 | This method returns the balloon hint handle. |
286 | Returns handle or 0 if error |
287 |
288 |
289 | | GetClientIconPos |
290 | function GetClientIconPos(X, Y: Integer): TPoint;
291 | Returns the cursor position inside the tray icon.
292 | Will return coordinates between (-1,-1) and (16,16).
293 | You would expect the coordinates to vary between 0 and 15, but Windows adds a border
294 | 1 pixel wide to all tray icons, which is appparently considered to be part of the tray icons.
295 | Depending on whether the tray icon has other tray icons as neighbours to the left, right,
296 | top, or bottom, the border is inserted as Windows sees fit.
297 | So in other words, this method is not exact. You should expect a variation of 2 pixels.
298 | If anyone sees a way to patch this, let me know. |
299 | Returns position in a TPoint |
300 |
301 |
302 | | SetFocus |
303 | function SetFocus: Boolean;
304 | Sets focus to the tray icon (if it is visible).
305 | NOTE: Supported from ver. 5.0 of Internet Explorer. |
306 | Returns true or false |
307 |
308 |
309 | | ShowMainForm |
310 | This method applies only when the owner of the
311 | tray icon component is a form.
312 | procedure ShowMainForm;
313 | Shows the main form.
314 | NOTE: It is important that you use this method when displaying the form,
315 | as it contains important calls that affect how the form and the application display
316 | themselves. See the demo app. |
317 |
|
318 |
319 |
320 | | HideMainForm |
321 | This method applies only when the owner of the
322 | tray icon component is a form.
323 | procedure HideMainForm;
324 | Hides the main form. |
325 |
|
326 |
327 |
328 | | ShowTaskbarIcon |
329 | This method applies only when the owner of the
330 | tray icon component is a form.
331 | procedure ShowTaskbarIcon;
332 | Shows the application's taskbar icon (not to be confused with the tray icon).
333 | |
|
334 |
335 |
336 | | HideTaskbarIcon |
337 | This method applies only when the owner of the
338 | tray icon component is a form.
339 | procedure HideTaskbarIcon;
340 | Hides the application's taskbar icon (not to be confused with the tray icon).
341 | NOTE: If you display a child form the taskbar icon will become visible again
342 | automatically. This is standard Windows behavior. |
343 |
|
344 |
345 |
346 |
347 |
348 |
349 | Events
350 |
351 |
352 |
353 | | OnClick |
354 | TNotifyEvent;
355 | Works like the similar event for window controls.
356 | NOTE: The Click event corresponds to a MouseDown followed by a MouseUp.
357 | If no DblClick event is assigned the Click event fires immediately (ie. after
358 | the MouseUp). Otherwise it will wait for a small period of time to see if the
359 | user clicks again, in which case we have a double click. If no DblClick event
360 | is assigned a double click will actually cause the Click event to fire.
361 | This is intentional. |
362 |
363 |
364 | | OnDblClick |
365 | TNotifyEvent;
366 | Works like the similar event for window controls. |
367 |
368 |
369 | | OnMouseDown |
370 | TMouseEvent;
371 | Works like the similar event for window controls. |
372 |
373 |
374 | | OnMouseUp |
375 | TMouseEvent;
376 | Works like the similar event for window controls. |
377 |
378 |
379 | | OnMouseMove |
380 | TMouseMoveEvent;
381 | Works like the similar event for window controls. |
382 |
383 |
384 | | OnMouseEnter |
385 | TNotifyEvent;
386 | Fired after the cursor enters the tray icon. Requires
387 | the WantEnterExitEvents property to be true. |
388 |
389 |
390 | | OnMouseExit |
391 | TNotifyEvent;
392 | Fired after the cursor leaves the tray icon. Requires
393 | the WantEnterExitEvents property to be true. |
394 |
395 |
396 | | OnCycle |
397 | procedure(Sender: TObject; NextIndex: Integer) of object;
398 | Fired just before the icon changes via CycleIcons.
399 | Returns the next index in the assigned imagelist. |
400 |
401 |
402 | | OnBalloonHintShow |
403 | TNotifyEvent;
404 | Fired after the balloon hint shows itself. This doesn't have to occur immediately
405 | after you call the ShowBalloonHint method. In case another application is already
406 | showing a balloon hint, your application must wait for it to close before it gets
407 | to show the balloon hint itself. This event will tell you when it has shown the hint.
408 | NOTE: Not supported in Win2000. See bugs section.
409 | |
410 |
411 |
412 | | OnBalloonHintHide |
413 | TNotifyEvent;
414 | Fired after the balloon hint closes because another application needs to show a
415 | balloon hint, or because you called either the ShowBalloonHint or the
416 | HideBalloonHint method.
417 | NOTE: Not supported in Win2000. |
418 |
419 |
420 | | OnBalloonHintTimeout |
421 | TNotifyEvent;
422 | Fired after the balloon hint closes because it timed out.
423 | NOTE: Not supported in Win2000. |
424 |
425 |
426 | | OnBalloonHintClick |
427 | TNotifyEvent;
428 | Fired when the user clicks the balloon hint.
429 | NOTE: Not supported in Win2000. |
430 |
431 |
432 | | OnMinimizeToTray |
433 | This event applies only when the owner of the
434 | tray icon component is a form.
435 | TNotifyEvent;
436 | Fired when the application is about to minimize to tray. Useful if you want to do special
437 | processing, like animation effects, when the app. gets minimized (hidden).
438 | NOTE: MinimizeToTray must be true for this event to fire. |
439 |
440 |
441 | | OnStartup |
442 | This event applies only when the owner of the
443 | tray icon component is a form.
444 | procedure(Sender: TObject; var ShowMainForm: Boolean) of object;
445 | Fired initially at application startup when the main form is about to display.
446 | Set the ShowMainForm parameter to false if you don't want the form to display.
447 | NOTE: May fire multiple times for an MDI form (once for every child form
448 | created at startup).
449 | NOTE: This event occurs before the form's OnCreate method (if used with a form).
450 | NOTE: Replaces the StartMinimized property found in earlier versions. |
451 |
452 |
453 |
454 |
455 |
456 | Hints
457 |
458 |
459 | - How do I start my app. with the tray icon visible and the main form invisible?
460 | At design time set IconVisible to true and set the form's Visible property to false.
461 | Set the ShowMainForm parameter to false in the OnStartup event. See the StartHidden demo.
462 |
463 |
464 | - What is the proper way to restore the form?
465 | ALWAYS use the method ShowMainForm! This method contains important calls that affect
466 | how the form and the application display themselves. Simply setting the form visible
467 | or calling Application.Restore is not enough. A common symptom is the form with tabpages
468 | that don't update themselves because ShowMainForm wasn't used.
469 |
470 |
471 | - I used the OnStartup event to hide the form, but I can still see a quick flash on
472 | the taskbar when the app. is starting?
473 | If it bothers you you can set the Application.ShowMainForm property in the main
474 | project source, like this:
475 | .....
476 | Application.Initialize;
477 | Application.ShowMainForm := False;
478 | .....
479 |
480 |
481 | - Why does the tray icon not appear in my NT/2000/XP service app.?
482 | Set the service's Interactive property to true, set ServiceType to stWin32, and set the tray icon's
483 | IconVisible property to true.
484 | See also the bugs section concerning services in NT4.
485 |
486 |
487 | - I want multiple tray icons in my app.?
488 | Just create a CoolTrayIcon object for each tray icon you want. The component is optimized
489 | to share resources between the tray icons.
490 |
491 |
492 | - How do I send a message to the tray icon through code?
493 | Use PostMessage or SendMessage and specify the message as the LParam parameter.
494 | Here's an example of sending a WM_LBUTTONDOWN message, invoking the tray icon's
495 | OnMouseDown event:
496 | PostMessage(CoolTrayIcon1.Handle, WM_TRAYNOTIFY, Integer(CoolTrayIcon1), WM_LBUTTONDOWN);
497 |
498 |
499 | - I want to hide ALL windows, including dialogs and popup forms?
500 | Minimize the app. before calling HideMainForm, like this:
501 |
502 | Application.Minimize;
503 | CoolTrayIcon1.HideMainForm;
504 |
505 |
506 | - I want to override the "hide inactive tray icons" feature in WinXP?
507 | Calling the tray icon's Refresh method at regular intervals should do the trick (I think).
508 | Anyway, it's not a good idea to override standard Windows behavior.
509 |
510 |
511 | - When does the OnStartup event occur?
512 | The OnStartup event occurs before the owner form's OnCreate event.
513 |
514 |
515 | - How do I show the balloon hint for less than 10 seconds?
516 | Set a timer to close the hint prematurely, using the HideBalloonHint method.
517 |
518 |
519 | - How do I check if balloon hints are available (since they don't work in Win95 and Win98)?
520 | This should work in D4 and up:
521 | uses ComCtrls;
522 | if (GetComCtlVersion < ComCtlVersionIE4) or
523 | ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
524 | (Win32MinorVersion <> 90)) then
525 | // Balloon hints NOT supported
526 |
527 |
528 | - Can I use the ballon hints without the tray icon?
529 | Take a look at the zBalloon component.
530 |
531 |
532 |
533 |
534 |
535 | Known Bugs
536 |
537 |
538 |
544 |
550 |
551 | - It appears there's a bug in WinXP (apparently both with SP 1 and SP 2 versions of
552 | WinXP - possibly it's a general bug independent of service packs).
553 | The bug makes the balloon hint appear for a random amount of time, no matter which timeout
554 | value you specify in the call to ShowBalloonHint. I haven't verified this with Microsoft,
555 | but it is not a problem in other Windows versions. Also, other tray icon components
556 | suffer from this problem, so it is most likely an issue with WinXP. Please tell me if
557 | you have this problem and you are not running WinXP SP 1 or SP 2.
558 |
559 |
560 |
561 | - Some people report that the balloon hint events never fire. This is a Win2000 issue.
562 | It doesn't appear to matter which service pack, Internet Explorer version, or comctl32.dll
563 | version you use. This makes me suspect that Win2000 simply does not support these events.
564 |
565 |
566 |
567 | - The tray icon may disappear in NT4 if it is used in an interactive service and
568 | you log off, then log back on. I've been trying to fix this, but have so far been
569 | unsuccessful.
570 | An explanation for why the problem occurs can be found
571 | here.
572 | (BTW: some service packs, like SP6 seem to fix this problem).
573 |
574 |
575 | - It is possible to disable balloon hints in Windows. If the balloon hint doesn't
576 | display when it's supposed to (and if you're not using Win9x), you should verify this setting.
577 |
578 |
579 | - Occasionally someone reports that an application using CoolTrayIcon prevents the
580 | user from logging off or shutting down until he manually terminates the application.
581 | I've more or less come to the conclusion that this is not a bug in CoolTrayIcon.
582 | More likely it's a bug in some other third party component. At least it seems
583 | people always get this error when they use CoolTrayIcon together with other
584 | third party components. If you get this error try removing the other components
585 | one at a time and see if that doesn't solve the problem (or even simpler - run my
586 | demo app. and see if it has the problem). Afterwards, if you still have reason to
587 | believe CoolTrayIcon is the problem, don't hesitate to tell me, but please perform
588 | this simple test of exclusion first. (NOTE: It would seem various components in
589 | Delphi's FastNet collection have this problem - independently of CoolTrayIcon).
590 |
591 | Also make sure you use CoolTrayIcon correctly. If your app. "closes to tray"
592 | (goes to the tray when the user clicks the form's close button) you need to handle
593 | the WM_QUERYENDSESSION message manually, or the app. (unsurprisingly) won't terminate
594 | when Windows shuts down. See the source in the CoolTrayTest demo for a solution.
595 |
596 |
597 |
605 |
606 | - If you're using CoolTrayIcon with an ActionList (associated with popup menu items),
607 | you'll find that actions based on TCustomAction (like TFileExit) don't execute if the
608 | form that owns the tray icon is invisible. I'm guessing TCustomAction is designed to
609 | behave like this. However, this problem doesn't occur with standard actions.
610 |
611 |
612 |
613 |
614 |
615 | Comments
616 |
617 | The CoolTrayIcon component is free for personal and commercial use.
618 | Feel free to use and improve it, but please include all original files if you
619 | redistribute the zip-file. If you have any comments or corrections to the component
620 | I would very much like to hear them. A lot of Delphi programmers have already told me
621 | they like the component and use it, which is a huge boost for my ego. Thanks a lot,
622 | guys - especially those of you who gave suggestions and pointed out the bugs.
623 |
624 |
625 |
626 | If you use the component some credit somewhere in your application would be a nice gesture,
627 | but it is not a requirement.
628 |
629 |
630 |
631 | The component should work on any Windows platform (Win9x, ME, NT, 2000, XP, 2003, Vista).
632 | If you experience any problems related to the operating system you use, please tell me.
633 | Also, it should work in Delphi 3 and up (Delphi 2?) and C++Builder 3 and up.
634 | Again, tell me if I'm wrong.
635 |
636 |
637 |
638 | A word about services: CoolTrayIcon does not require its
639 | owner to be a form. This allows you to use it for non-windowed apps. such as services.
640 | Some of the properties, methods, and events don't make sense without a form, but rather
641 | than creating a superclass without these properties/methods/events I've simply let them
642 | stay in CoolTrayIcon itself. You can use them in your service app., but they will not do
643 | anything. I figured the component would be more flexible and easier to extend into
644 | subclasses this way.
645 |
646 |
647 |
648 | Get the latest version from
649 | http://subsimple.com/delphi.asp.
650 |
651 |
652 |
653 | Troels Jakobsen
654 | troels.jakobsen@gmail.com
655 |
656 |
657 |
658 |
659 |
--------------------------------------------------------------------------------