# TextTrayIcon, ver. 1.2.1

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

TextTrayIcon is a tray icon component. It is an extended version of the CoolTrayIcon component, so you need CoolTrayIcon to make it work.

TextTrayIcon allows you to easily show custom text inside the tray icon. If you need tray icons with just regular icons I suggest you use CoolTrayIcon in stead.

This document describes only the added features of TextTrayIcon. For an explanation of all the standard features of this tray icon component, see the CoolTrayIcon documentation.

## Properties

Text | property Text: String; The text to show in the tray icon. The text is always centered horizontally and vertically. NOTE: You can have multiple lines of text. Separate the lines with #13 (CR). |
Font | property Font: TFont; The font to use when drawing the text. |
Color | property Color: TColor; The (background) color of the tray icon. Use clBtnFace to show it in the color of the task bar. | Default clBtnFace
Border | property Border: Boolean; Whether to draw a border at the edges of the tray icon. This is a rectangle 1 px. wide using the color specified by BorderColor. | Default false
BorderColor | property BorderColor: TColor; The color of the tray icon's border rectangle. | Default clBlack
BackgroundIcon | property BackgroundIcon: TIcon; If no background icon is specified the tray icon will be rendered using the text, font, color, and border properties you've specified. If a background icon is specified then it will be rendered beneath the text as if the tray icon was transparent. In other words: the background color is ignored and the background icon is shown in stead. | Default true
Options | You will likely prefer to adjust the text inside the tray icon. Use the following layout options for that purpose:
OffsetX | property OffsetX: Integer; Adjusts the text X pixels horizontally.
OffsetY | property OffsetY: Integer; Adjusts the text Y pixels vertically.
LineDistance | property LineDistance: Integer; Adds or deletes pixels between multiple lines of text. A value of -2 is a good idea in most cases of multiline text.

## Methods

Draw | procedure Draw; Redraws the tray icon using the current colors, font, and border properties described above. NOTE: The tray icon is automatically redrawn when one of those properties change. NOTE: Calling Draw directly (or by assigning to one of the properties mentioned) will set CycleIcons to false, as it doesn't make sense to draw an icon and then immediately replace it with a new one.

## Events

No new events.

## Hints

- What are some good rules for showing text in a tray icon?
  You only have 16x16 pixels to draw inside, so use only 1 or 2 lines of text. Use high contrast colors, like white background and black text, perhaps with a border. Don't use fonts with serifs. For multiline text I think the font 'Small Fonts' approx. size 6 looks best. Set OffsetY to -1 and LineDistance to -2. NOTE: It's easy to experiment if you enable the DesignPreview property.
- How do I start my app. with the tray icon visible and the main form invisible?
  At design time set IconVisible to true and set the form's Visible property to false. Set the ShowMainForm parameter to false in the OnStartup event. See the StartHidden demo.
- What is the proper way to restore the form?
  ALWAYS use the method ShowMainForm! This method contains important calls that affect how the form and the application display themselves. Simply setting the form visible or calling Application.Restore is not enough. A common symptom is the form with tabpages that don't update themselves because ShowMainForm wasn't used.

## Known Bugs

See the bugs documentation for the CoolTrayIcon component.

## Comments

The TextTrayIcon component is free for personal and commercial use (along with the CoolTrayIcon component). 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.

The component should work on any Windows platform (Win9x, ME, NT, 2000, XP, 2003, Vista). If you experience any problems related to the operating system you use, please tell me. Also, it should work in Delphi 3 and up (Delphi 2?) and C++Builder 3 and up. Again, tell me if I'm wrong.

Get the latest version from http://subsimple.com/delphi.asp.

Troels Jakobsen
troels.jakobsen@gmail.com