CoolTrayIcon, ver. 3.0.0

[Properties] [Methods] [Events]
[Known Bugs] [Hints] [Comments]

CoolTrayIcon is a tray icon component. It allows you to easily implement tray icons in your own applications, with various appearances and behaviors.

Properties

Hint The tray icon's hint (max 64 chars), which is displayed when you move the mouse cursor over the tray icon.
NOTE: The time until the hint window closes is determined by Windows, so don't bother trying to change the interval. You can't.

ShowHint Whether to show the hint. Default true
Icon The icon to display in the tray. This icon is 16x16 pixels and max. 16 colors. 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 call the method Refresh (see below) to redraw it.

IconVisible Whether to display the icon. This property has no effect in design mode. Default true
PopupMenu The popup menu you want to display when the icon is clicked. Default true
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 CoolTrayIcon to handle a menu that has a default menu item.
Default false
StartMinimized Should the main form be hidden when the application starts up?
NOTE: Remember to set the form's Visible property to false if StartMinimized is true.
Default false
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. Default true
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.
NOTE: When you assign to IconList IconIndex is set to 0.

IconIndex The current icon in the assigned iconlist (or 0 if no iconlist is assigned).
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.
NOTE: CycleIcons can be true even though you have no IconList. No cycling will occur in that case, but the cycle timer is still active, which will consume some resources.
Default false
CycleInterval The time interval in milisecs. before selecting a new icon from IconList.
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.
Default false
MinimizeToTray Do you want to hide the main form instead of minimizing it? Default false
Handle The tray icon's handle.
WindowHandle The tray icon's window handle.

Methods

ShowMainForm Show the main form.
NOTE: It is important that you use this method when displaying the form, as it contains important calls that affect how the form and the application display themselves. See the demo app.

HideMainForm Hide the main form.
Refresh Redraw the tray icon. May be necessary when changing the icon, depending on how you do it (see above). Returns true or false
ShowBalloonHint Show a balloon hint (a kind of "sticky" popup hint).
NOTE: Balloon hints are available in WinME, Win2000, and WinXP only. Calling this method in other Windows versions has no effect.
NOTE: You can use a max. of 64 chars for the title and max. 255 chars for the text. The hint is visible for 10-60 seconds, or until the user clicks it.
Returns true or false
BitmapToIcon Renders and returns an existing icon based on the bitmap given as parameter. The bitmap should be 16x16 pixels. Specify a color to be shown transparently or clNone for no transparency.
NOTE: Bitmaps that are not exactly 16x16 will be scaled up or down.
Returns true or false

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 next index in the assigned imagelist.

Known Bugs

Hints

Comments

The CoolTrayIcon component is freeware. Feel free to use and improve it, but please include all original files if you redistribute the zip-file. If you have any comments or corrections to the component I would very much like to hear them. A lot of Delphi programmers have already told me they like the component and use it, which is a huge boost for my ego. Thanks a lot, guys - especially those of you who gave suggestions and pointed out the bugs.

The component should work on any Windows platform (Win9x, ME, NT, 2000, XP). The demo exe-file may have to be recompiled (?), though I don't think so. If you experience any problems related to the operating system you use, please tell me. Also, it should work in Delphi 4 and up (2 and 3?) and C++Builder 3 and up. Again, tell me if I'm wrong.

Get the latest version from http://www3.ewebcity.com/troels/delphi.asp.

Troels Jakobsen
delphiuser@get2net.dk