TTrayIcon( unit KOL.pas ) TObj _TObj
TTrayIcon = object( TObj )
Object to place (and change) a single icon onto taskbar tray.
type TTrayIcon = object( TObj )
Object to place (and change) a single icon onto taskbar tray.
type TOnTrayIconMouse = procedure( Sender: PObj; Message: Word ) of object;
Event type to be called when Applet receives a message from an icon, added to the taskbar tray.
Constructor
function NewTrayIcon( Wnd: PControl; Icon: HIcon ): PTrayIcon;
Constructor of TTrayIcon object. Pass main form or applet as Wnd parameter.
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 no more 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.
TTrayIcon methods
Destructor. Use Free method instead (as usual).
procedure ForceActive( SleepTime, Timeout: DWORD );
Sets Active := TRUE unil it becomes TRUE or Timeout exceeds, sleeping for SleepTime milliseconds between attempts. E.g.: Trayicon1.ForceActive(100, 5000);
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.
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.)