📄 cooltrayicon.txt
字号:
TCoolTrayIcon, ver. 2.1.1
This is a component for placing icons in the notification area
of the Windows taskbar (aka. the traybar).
I based the initial code on other people's work. However, I've
added so much functionality that I think at this point I'm
entitled to take most of the credit myself. Which I do ;-)
Personally I think it's a pretty darn cool component.
The component is freeware. Feel free to use and improve it.
I would be pleased to hear what you think.
Properties:
- Hint: the tray icon's hint (max 64 chars).
NOTE: The time before the hint window closes is determined by
Windows, so don't bother changing the interval yourself.
You can't.
- ShowHint: whether to show the hint.
- Icon: the icon to display in the tray. This icon is 16x16
pixels. If you use an icon file (*.ico) containing more than
one icon, Delphi will use the first icon (if it's 32x32 it
will be scaled down, which probably won't look good).
NOTE: Assigning a new TIcon object to Icon will cause the icon
in the tray to redraw. However, this is not the case if you
change Icon through the TIcon.Assign method, or change it
through TIcon.Handle. In those cases you must use the method
Refresh (see below) to redraw it.
- IconVisible: whether to display the icon. This property has
no effect in design mode.
- PopupMenu: the popup menu you want to display when the icon is
clicked.
- LeftPopup: do you want the popup menu to pop up when you click
the left mouse button? Default is false, meaning only the right
button will work.
NOTE: LeftPopup must be false (or the popup menu unassigned) if
you want to double click the tray icon without displaying the
popup menu. LeftPopup must be false if you want TCoolTrayIcon to
handle a menu that has a default menu item.
- StartMinimized: do you want the main form to be hidden when the
application starts up? Default is false.
NOTE: If StartMinimized is true, setting the Position property
for the main form has no effect. Don't blame me, Borland made
it that way.
- Enabled: default true. Works like Enabled for other controls,
enabling/disabling keyboard and mouse input. Useful when you
want to temporarily disable the popup menu, say while you are
displaying an about box or some other modal window.
- Handle: the tray icon's handle.
- CycleIcons: animate tray icon by cycling through all the icons
stored in IconList and assigning them to Icon. When you set
CycleIcons to true, it will begin with the first icon in
IconList.
- CycleInterval: the time interval in milisecs. before selecting
a new icon from IconList.
- IconList: an ImageList containing icons. If it contains other
images than icons, the tray icon won't change when using
CycleIcons, but no error occurs.
- DesignPreview: when true, enables you to preview the tray icon
in design mode. You can watch what the icon looks like, see
its hint, enable/disable it, test the popupmenu, and animate
it via CycleIcons.
NOTE: Set DesignPreview to false to avoid the design time icon
appearing when you run your program. This is only a problem in
the Delphi IDE (not in the finished exe file). I couldn't find
a way to kill the design icon in run-time, so you'll have to
do it yourself.
NOTE: Setting DesignPreview in run-time has no effect.
- MinimizeToTray: do you want to hide the main form instead of
minimizing it? Default is false.
Methods:
- ShowMainForm, HideMainForm: show/hide the main form.
- Refresh: redraw the tray icon. May be necessary when changing
the icon, depending on how you do it (see above).
Events:
- OnClick, OnDblClick, OnMouseDown, OnMouseUp, OnMouseMove:
work like the similar events for other controls.
- OnCycle: fired just before the icon changes via CycleIcons.
Returns the current index in the assigned imagelist.
Known bugs:
- The OnMouseXXX events will only report the key status
(TShiftStatus) correctly if the main form has focus. You can
see this if you start the demo and then put another window in
the foreground. Hold CTRL down, say, and move the mouse over
the tray icon. The CTRL key is apparently ignored when the
demo is not in the foreground. I don't know why; it's probably
just the way Windows works.
History:
- ver. 2.1.1: Added notification method to properly detect whether
the associated popup menu and imagelist are deleted. Thanks to
Hui Jin Ong for pointing it out to me and making suggestions.
- ver. 2.1.0: Added property MinimizeToTray. This was done by
hooking into the application's message processing.
- ver. 2.0.0: Name is now TCoolTrayIcon. Added icon cycling and
design preview capabilities. Added method Refresh. Fixed a bug
that caused some controls to not redraw when starting your app.
as invisible.
- ver. 1.0.3: Added property Enabled. Also fixed a bug reported by
David Knaack, which caused a runtime error if you double-clicked
when no popup menu was assigned to the icon.
- ver. 1.0.2: Added a Handle property, and enabled handling of
default menu items. (Partially) fixed a bug so the icon will
update itself when a new icon is assigned.
- ver. 1.0.1: The associated popup menu now behaves as it is
supposed to. Also fixed that forms using the tray icon didn't
go in front of other windows when restored. Thanks to Chris Hope
for telling me.
- ver. 1.0.0: First release. Component was called TTrayIcon at
this time.
If you have any comments or corrections, I would very much like to
hear them. If you develop some cool tray animations you want to
share, send them to me :-)
Troels Jakobsen
tjak@get2net.dk
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -