Difference between revisions of "How to use a TrayIcon"

From Lazarus wiki
Jump to navigationJump to search
m
Line 9: Line 9:
 
'''Linux (Gnome, KDE, IceWM, etc)''' - Multiple system tray icons per application are supported. The image of the icon is acctually a very small Window, and can be painted and receive events just like any other TForm descendent.
 
'''Linux (Gnome, KDE, IceWM, etc)''' - Multiple system tray icons per application are supported. The image of the icon is acctually a very small Window, and can be painted and receive events just like any other TForm descendent.
  
'''Linux (WindowMaker)''' - Does not support system tray icons out-of-the-box. There is a Dock software that provides support for it here: [http://icculus.org/openbox/2/docker/]
+
'''Linux (WindowMaker, Openbox, etc)''' - Does not support system tray icons out-of-the-box. However, There are at least two softwares that provides support for it: [http://icculus.org/openbox/2/docker/ Docker] and [http://freshmeat.net/projects/wmsystray/ WMSystray]
  
 
'''Mac OS X''' - This system doesn´t really support System Tray Icons. However, all Mac OS X applications do have a Taskbar Icon witch behaves very much like a Systray Icon. It can receive messages and be painted at will. One and only one of these taskbar icons exist per application. On the next version, this component will try to abstract this Taskbar Icon into something compatible with Windows and Linux.
 
'''Mac OS X''' - This system doesn´t really support System Tray Icons. However, all Mac OS X applications do have a Taskbar Icon witch behaves very much like a Systray Icon. It can receive messages and be painted at will. One and only one of these taskbar icons exist per application. On the next version, this component will try to abstract this Taskbar Icon into something compatible with Windows and Linux.
Line 32: Line 32:
  
 
===Documentation===
 
===Documentation===
 +
 +
Bellow is a list of all methods, properties and events of the component. They have the same names and work the same way on the visual component and on the non-visual object.
 +
 +
====Methods====
 +
 +
'''Show'''
 +
 +
procedure Show;
 +
 +
works on: All target platforms
 +
 +
'''Hide'''
 +
 +
procedure Hide;
 +
 +
works on: All target platforms
 +
 +
====Properties====
 +
 +
'''Hint'''
 +
 +
property Hint: string;
 +
 +
works on: Only Windows
 +
 +
'''ShowHint'''
 +
 +
property ShowHint: Boolean;
 +
 +
works on: Only Windows
 +
 +
'''PopUpMenu'''
 +
 +
property PopUpMenu: TPopUpMenu;
 +
 +
works on: All target platforms
 +
 +
====Events====
 +
 +
'''OnClick'''
 +
 +
works on: All target platforms
 +
 +
'''OnDblClick'''
 +
 +
works on: All target platforms
 +
 +
'''OnMouseDown'''
 +
 +
works on: All target platforms
 +
 +
'''OnMouseUp'''
 +
 +
works on: All target platforms
  
 
===Screenshot===
 
===Screenshot===

Revision as of 19:33, 19 January 2006

About

TrayIcon is a multiplatform System Tray component. It is expected to work on Windows and all UNIXes, including Mac OS X.

A difficulty on the development on this component is the many differences on the system tray implementation on varios OSes and even Window Managers on Linux. To solve this, the component tryes to implement the minimal set of features common to all target platforms. Bellow is a list of the features implemented on each platform:

Windows - Multiple system tray icons per application are supported. The image of the icon can be alterred using a HICON handle. Events to the icon are sent via a special message on the user reserved space of messages (>= WM_USER) to the Window witch owns the Icon. No paint events are sent to the Window.

Linux (Gnome, KDE, IceWM, etc) - Multiple system tray icons per application are supported. The image of the icon is acctually a very small Window, and can be painted and receive events just like any other TForm descendent.

Linux (WindowMaker, Openbox, etc) - Does not support system tray icons out-of-the-box. However, There are at least two softwares that provides support for it: Docker and WMSystray

Mac OS X - This system doesn´t really support System Tray Icons. However, all Mac OS X applications do have a Taskbar Icon witch behaves very much like a Systray Icon. It can receive messages and be painted at will. One and only one of these taskbar icons exist per application. On the next version, this component will try to abstract this Taskbar Icon into something compatible with Windows and Linux.

With this in mind a approach which supports almost all Platforms was created:

  • Only one Systray Icon is supported per application, and all applications that use the component have it initialized on the startup of the program. This way you will use the SystrayIcon object, and not it´s class. (Required by Mac OS X)
  • Painting is done via a TIcon object. (Required by Windows)

The following extra features are already available or will be, but they won´t work on all platforms.

  • Multiple Systray Icons. Won´t work on Mac OS X.
  • OnPaint event and Canvas property to draw the icon freely. Won´t work on Windows.

Quick Use Guide

Two interfaces are supplied, a visual component and a non-visual object. The object is compatible with Delphi, while the visual component isn´t. They have exactly the same features.

The non-visual object is called SystrayIcon, and the visual component is TTrayIcon.

Documentation

Bellow is a list of all methods, properties and events of the component. They have the same names and work the same way on the visual component and on the non-visual object.

Methods

Show

procedure Show;

works on: All target platforms

Hide

procedure Hide;

works on: All target platforms

Properties

Hint

property Hint: string;

works on: Only Windows

ShowHint

property ShowHint: Boolean;

works on: Only Windows

PopUpMenu

property PopUpMenu: TPopUpMenu;

works on: All target platforms

Events

OnClick

works on: All target platforms

OnDblClick

works on: All target platforms

OnMouseDown

works on: All target platforms

OnMouseUp

works on: All target platforms

Screenshot

Author

Felipe Monteiro de Carvalho

Andrew

License

Modifyed LGPL.

Download

Status: Underconstruction

Installation

Demonstration program 1


Subversion

Located under components/trayicon/ on the latest subversion Lazarus.

Bug Reporting/Feature Request

Tests are necessary to verify if the component works on all Window Managers.

You can post Bug Reports / Feature Requests here:


Change Log

  1. 17/01/2006 - Available as a preview on the Lazarus subversion. Still under heavy construction, however.

Help

Help requests can be posted here: