TTrayIcon( unit KOL.pas ) ï TObj ï _TObj

TTrayIcon = object( TObj )

Object to place (and change) a single icon onto taskbar tray.

### TTrayIcon properties

property Icon: HIcon;
Icon to be shown on taskbar tray. If not set, value of Active property has no effect. It is also possible to assign a value to Icon property after assigning True to Active to install icon first time or to replace icon with another one (e.g. to get animation effect).
Previously allocated icon (if any) is not deleted using DeleteObject. This is normal for icons, loaded from resource (e.g., by LoadIcon API call). But if icon was created (e.g.) by CreateIconIndirect, your code is responsible for destroying of it).

property Active: Boolean;
Set it to True to show assigned Icon on taskbar tray. Default is False. Has no effect if Icon property is not assigned. TrayIcon is deactivated automatically when Applet is finishing (but only if Applet window is used as a "parent" for tray icon object).

property Tooltip: KOLString;
Tooltip string, showing automatically when mouse is moving over installed icon. Though "huge string" type is used, only first 63 characters are considered. Also note, that only in most recent versions of Windows multiline tooltips are supported.

property AutoRecreate: Boolean;
If set to TRUE, auto-recreating of tray icon is proveded in case, when Explorer is restarted for some (unpredictable) reasons. Otherwise, your tray icon is disappeared forever, and if this is the single way to communicate with your application, the user nomore can achieve it.

property NoAutoDeactivate: Boolean;
If set to true, tray icon is not removed from tray automatically on WM_CLOSE message receive by owner control. Set Active := FALSE in your code for such case before accepting closing the form.

property Wnd: HWnd;
A window to use as a base window for tray icon messages. Overrides parent Control handle is assigned. Note, that if Wnd property used, message handling is not done automatically, and you should do this in your code, or at least for one tray icon object, call AttachProc2Wnd.

#### Properties, inherited from TObj

### TTrayIcon methods

destructor Destroy; virtual; N
Destructor. Use Free method instead (as usual).

procedure AttachProc2Wnd;
Call this method for a tray icon object in case if Wnd used rather then control. It is enough to call this method once for each Wnd used, even if several other tray icons are also based on the same Wnd. See also DetachProc2Wnd method.

procedure DetachProc2Wnd;
Call this method to detach window procedure attached via AttachProc2Wnd. Do it once for a Wnd, used as a base to handle tray icon messages. Caution! If you do not call this method before destroying Wnd, the application will not functioning normally.

#### Methods, inherited from TObj

### TTrayIcon events

property OnMouse: TOnTrayIconMouse;
Is called then mouse message is taking place concerning installed icon. Only type of message can be obtained (e.g. WM_MOUSEMOVE, WM_LBUTTONDOWN etc.)

#### Events, inherited from TObj

### TTrayIcon fields

#### Fields, inherited from TObj

### TTrayIcon tasks

When You create invisible application, which should be represented by only the tray icon, prepare a handle for the window, resposible for messages handling. Remember, that window handle is created automatically only when a window is showing first time. If window's property Visible is set to False, You should to call CreateWindow manually. <br> There is a known bug exist with similar invisible tray-iconized applications. When a menu is activated in response to tray mouse event, if there was not active window, belonging to the application, the menu is not disappeared when mouse is clicked anywhere else. This bug is occure in Windows9x/ME. To avoid it, activate first your form window. This last window shoud have status visible (but, certainly, there are no needs to place it on visible part of screen - change its position, so it will not be visible for user, if You wish). <br> Also, to make your application "invisible" but until special event is occure, use Applet separate from the main form, and make for both Visible := False. This allows for You to make your form visible any time You wish, and without making application button visible if You do not wish.

[ Index ]

This help is generated 14-Jun-2010 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov
Modified (C) 2003 by Alexander Bartov