Difference between revisions of "TrayIcon/de"

From Free Pascal wiki
Jump to navigationJump to search
 
m (OSX -> macOS/named OS; fixed syntax highlighting)
 
(33 intermediate revisions by 7 users not shown)
Line 1: Line 1:
=== About ===
+
{{TrayIcon}}
  
'''TrayIcon''' is a multiplatform System Tray component. It currently works on the following widgetsets: win32, Gtk1, Gnome, Gtk2. In the future it will also work for Carbon ( Mac OS X ) and Qt 4.
+
=== Über ===
  
Two interfaces are supplied, a visual component and a non-visual object. The non-visual object is called SystrayIcon and it is compatible with Delphi. The visual component is called TTrayIcon and works only on Lazarus.
+
'''TrayIcon''' ist eine crossplattformtaugliche Systemtray-Komponente, die momentan unter folgenden Widgetsets funktioniert: win32, Gtk1, Gnome, Gtk2.
 +
Für die Zukunft ist außerdem Carbon ( Mac OS X ) und Qt 4 vorgesehen.
  
To start quickly, please read [[TrayIcon#Demonstration_program_1|the demonstration program]].
+
Zwei Schnittstellen werden momentan angeboten: eine visuelle Komponente und ein non-visuelles Objekt. Zweiteres heißt SystrayIcon und ist delphikompatibel. Die visuelle Komponente ist das TTrayIcon, das nur mit Lazarus funktioniert.
  
=== Documentation ===
+
Als Schnelleinstieg siehe: [[TrayIcon/de#Demonstrationsprogramm|das Demonstrationsprogramm]].
  
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.
+
=== Dokumentation ===
  
A function works on all target platforms unless written otherwise.
+
Nachfolgend eine Liste mit allen Methoden, Eigenschaften und Ereignissen, die die Komponente zur Verfügung stellt. Namen und Funktion sind für die visuelle und die nicht-visuelle Version identisch. Außerdem arbeiten die Funktionen, außer wenn anders angegeben unter allen Plattformen.
  
==== Methods ====
+
==== Methoden ====
  
 
<span style="color: teal">'''Show'''</span>
 
<span style="color: teal">'''Show'''</span>
Line 19: Line 20:
 
'''procedure''' Show;
 
'''procedure''' Show;
  
Shows the icon on the system tray.
+
Zeigt das Icon im Systemtray
  
  
Line 26: Line 27:
 
'''procedure''' Hide;
 
'''procedure''' Hide;
  
Removes the icon from the system tray.
+
Entfernt das Icon aus dem Systemtray
  
  
Line 33: Line 34:
 
'''function''' GetPosition: TPoint;
 
'''function''' GetPosition: TPoint;
  
Returns the position of the tray icon on the display. This function is utilized to show message boxes near the icon. Currently it´s only a stub, no implementations are available and TPoint(0, 0) is returned.
+
Gibt die Position des Trayicons auf dem Bildschirm aus. Diese Funktion dient dazu, Nachrichten nahe des Icons anzuzeigen.  
 +
Dies ist allerdings momentan nur ein Platzhalter und nicht implementiert. Stattdessen wird immer der Punkt (0, 0) zurückgegeben.
  
==== Properties ====
+
==== Eigenschaften ====
  
 
<span style="color: teal">'''Hint'''</span>
 
<span style="color: teal">'''Hint'''</span>
  
 
'''property''' Hint: string;
 
'''property''' Hint: string;
 
  
  
Line 46: Line 47:
  
 
'''property''' ShowHint: Boolean;
 
'''property''' ShowHint: Boolean;
 
  
  
Line 53: Line 53:
 
'''property''' PopUpMenu: TPopUpMenu;
 
'''property''' PopUpMenu: TPopUpMenu;
  
A PopUp menu that appears when the user right-clicks the tray icon.
+
Gibt ein Popupmenu an, das beim Rechtsklick auf das Icon erscheint.
  
==== Events ====
+
==== Ereignisse ====
  
 
<span style="color: teal">'''OnPaint'''</span>
 
<span style="color: teal">'''OnPaint'''</span>
Line 61: Line 61:
 
'''property''' OnPaint: TNotifyEvent;
 
'''property''' OnPaint: TNotifyEvent;
  
Use this to implement custom drawing to the icon. Draw using the canvas property of the icon.
+
Erlaubt eine eigene Zeichenroutine für das Canvas des Icons.
  
Note: Does not work on win32.
+
Bemerkung: Arbeitet nicht unter Win32!
  
  
Line 90: Line 90:
 
'''property''' OnMouseMove: TMouseMoveEvent;
 
'''property''' OnMouseMove: TMouseMoveEvent;
  
=== Screenshot ===
+
=== Autoren ===
 
 
 
 
=== Authors ===
 
  
 
[[User:Sekelsenmat|Felipe Monteiro de Carvalho]]
 
[[User:Sekelsenmat|Felipe Monteiro de Carvalho]]
Line 99: Line 96:
 
[[User:AndrewH|Andrew Haines]]
 
[[User:AndrewH|Andrew Haines]]
  
=== License ===
+
=== Lizenz ===
  
Modifyed LGPL.
+
Modifizierte LGPL
  
 
=== Download ===
 
=== Download ===
  
Status: Stable
+
Status: Stabil
  
Can be located at any recent Lazarus install at the directory: lazarus/components/trayicon
+
Ist bei jeder aktuellen Lazarusinstallation im Ordner lazarus/components/trayicon zu finden.
  
 
=== Installation ===
 
=== Installation ===
  
 +
'''GTK2 WORKAROUND'''
 +
Es gibt ein Problem mit Trayicon unter Linux mit GTK2 und FPC 2.1.x oder neuer. Das Problem ist, dass TrayIcon die Unit gdk2x.pp enthält (actually the unit is located inside the opengl component but TrayIcon compiles it into itself). This unit has been added to FPC as of version 2.1.x but it still in the lazarus sources as well, because it doesn't exist on the latest stable FPC (2.0.4). This means that when you install TrayIcon Lazarus will refuse to build the GTK2 LCL complaining that it cannot find unit GTKint. If you look at the messages however you will see the true error: the checksum for gdk2x has changed (this is the result of the duplication).
 +
To overcome this, you need to remove either the gdk2x.pp file from the lazarus tree, or the gdk2x.o and gdk2x.ppu file from your FPC units directory. This will be fixed once fpc 2.2.0 is released, at which time gdk2x.pp will be removed from lazarus, so consider this a temporary work-around.
 +
 +
=== Demonstrationsprogramm ===
 +
 +
Es gibt 2 Arten ein Trayicon zu erstellen. Ich empfehle die erste leichtere Methode, lasse aber die alte Methode drinne..
 +
Quelle(Diese Seite Englische version).
 +
 +
 +
==== Die Leichte Variante: ====
 +
 +
 +
Seit Lazarus 0.9.26 wurde TIcon vollständig implementiert, und es ist nicht länger notwendig das Bild aus einer Ressource zu laden. Das icon kann in der IDE geladen werden, oder auch mit "usual code".
 +
 +
Fügen sie ein TTrayIcon aus Additional in ihrer Form ein.
 +
 +
Füge ein TButton zu deiner Form. Und gebe in sein OnClickEvent folgendes ein.
 +
 +
<pre>
 +
procedure MyForm.Button1Click(Sender: TObject);
 +
begin
 +
  TrayIcon1.Icon.LoadFromFile('/phad_zum_icon/icon.ico');
 +
  TrayIcon1.ShowHint := True;
 +
  TrayIcon1.Hint := 'Mein tooltip';
 +
 +
  TrayIcon1.PopUpMenu := MyPopUpMenu;
 +
 +
  TrayIcon1.Show;
 +
end;
 +
</pre>
 +
 +
==== Die Alte Variante: ====
  
=== Demonstration program 1 ===
 
  
This program will load a icon from a internal resource on Windows or from an external file on other platforms.
+
Dieses Programm läd ein Icon aus einer internen Ressource (unter Windows) bzw. aus einer externen Datei (unter anderen Plattformen als Windows).
  
To create and link the icon resource to your Windows software you must:
+
Um die Ressource mit dem Icon unter Windows zu erstellen und einzubinden ist folgendes nötig:
  
1. Create a traytest.rc resource script, like this:
+
1. Erstellen sie ein Ressourcenskript traytest.rc wie dieses:
  
 
<pre>
 
<pre>
Line 124: Line 153:
 
</pre>
 
</pre>
  
2. Compile the resource script into a .res file with windres. Windres is supplied with Lazarus.
+
2. Compilieren sie das Ressourcenskript mittels windres.exe in eine *.res Datei. (Windres ist im Lazarusverzeichnis zu finden)
 
+
Der Befehl lautet:
 
windres -i traytest.rc -o traytest.res
 
windres -i traytest.rc -o traytest.res
  
Now you can write the test program. Create a new program with 1 form. Go to your source file and add this on the interface section:
+
Nun können sie ihr Testprogramm schreiben. Erstellen sie eine neue Anwendung mit einem Formular und fügen sie in die entsprechende Unit folgendes in den Interface-Abschnitt ein:
  
 
<pre>
 
<pre>
Line 136: Line 165:
 
</pre>
 
</pre>
  
Next add a button to the form. Double click the button and add this code to it:
+
Als nächstes benötigen sie noch einen Button. Schreiben sie folgendes in das OnClick-Ereignis des Buttons:
  
<pre>
+
<syntaxhighlight lang="pascal">
 
procedure MyForm.Button1Click(Sender: TObject);
 
procedure MyForm.Button1Click(Sender: TObject);
 
const
 
const
Line 145: Line 174:
 
{$ifdef win32}
 
{$ifdef win32}
 
   SystrayIcon.Icon.Handle := LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
 
   SystrayIcon.Icon.Handle := LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
   //7 march 2006 - Loading from icon file (see next line) seems buggy on win32 at this time
+
   //7. März 2006 - Das laden einer .ico-Datei unter Windows funktioniert nicht
 
{$else}
 
{$else}
 
   SystrayIcon.Icon.LoadFromFile('/path_to_icon/icon.ico');
 
   SystrayIcon.Icon.LoadFromFile('/path_to_icon/icon.ico');
   //7 march 2006 - You may experience problems with rendering using .ico files (buggy display),
+
   //7. März 2006 - Es kann zu Problemen mit der Darstellung von .ico-Dateien kommen.
   //               if then try using xpm (resolved the problem on fedora core 4 / Gnome)
+
   //Ist dies der Fall, probieren sie xpm (dies löst das Problem unter FedoraCore 4 / Gnome)
 
{$endif}
 
{$endif}
  
 
   SystrayIcon.ShowHint := True;
 
   SystrayIcon.ShowHint := True;
   SystrayIcon.Hint := 'my tool tip';
+
   SystrayIcon.Hint := 'Mein Tooltip';
  
 
   SystrayIcon.PopUpMenu := MyPopUpMenu;
 
   SystrayIcon.PopUpMenu := MyPopUpMenu;
Line 159: Line 188:
 
   SystrayIcon.Show;
 
   SystrayIcon.Show;
 
end;
 
end;
</pre>
+
</syntaxhighlight>
  
 
=== Subversion ===
 
=== Subversion ===
  
Located under components/trayicon/ on the latest subversion Lazarus.
+
Zu finden unter components/trayicon/ im aktuellen Subversion-Verzeichnis
  
=== Help, Bug Reporting and Feature Request ===
+
=== Hilfe, Bugreports und Funktionswünsche ===
  
Please, post Bug Reports and Feature Requests on the [http://www.lazarus.freepascal.org/mantis/main_page.php Lazarus Bugtracker].
+
Bitte stellen sie Bugreports und Funktionswünsche im [http://bugs.freepascal.org/main_page.php Lazarus Bugtracker].
  
Help requests can be posted on the Lazarus mailling list or on the Lazarus [http://www.lazarus.freepascal.org/modules.php?op=modload&name=PNphpBB2&file=index Forum].
+
Hilfsanfragen können in der Lazarus-Maillinglist oder im [http://www.lazarus.freepascal.org/modules.php?op=modload&name=PNphpBB2&file=index Forum] gestellt werden.
  
 
=== Change Log ===
 
=== Change Log ===
  
# 17/01/2006 - Available as a preview on the Lazarus subversion. Still under heavy construction, however.
+
# 17/01/2006 - Als Vorschau in der Lazarus-Subversion verfügbar
# 24/01/2006 - Stable under win32, gnome and gtk1, but still waiting for gtk2 support. Lazarus 0.9.12 was release with this version.
+
# 24/01/2006 - stable unter win32, Gnome and Gtk1, aber noch ohne Gtk2-Unterstützung. Lazarus 0.9.12 wurde mit dieser Version veröffentlicht.
# 17/02/2006 - Added support for gtk2 on subversion.
+
# 17/02/2006 - gtk2-Unterstützung in Subversion eingefügt
  
=== Technical Details ===
+
=== Technische Details ===
  
A difficulty on the development of this component was 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:
+
Eine Schwierigkeit in der Entwicklung waren die vielen Unterschiede in der Umsetzung der Implementierungen für den Systemtray unter den unterschiedlichen Betriebssystemen und Windowmanagern unter Linux. Um dies zu lösen, implementiert die Komponente den Satz an minimalen Funktionen, der unter allen Plattformen vorhanden ist.
 +
Nachflgend dazu eine Liste der unter den jeweiligen Plattformen implementierten Funktionen:
  
'''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 which owns the Icon. No paint events are sent to the Window.
+
'''Windows''' - Mehrere Systemtrayicons pro Anwendung werden unterstützt. Außerdem ist es möglich, das Icon mittels des HICON-Handle zu modifizieren. Events des Icons werden über eine spezielle Message im für den Nutzer reservierten Messageraum (>= WM_USER) zum Fenster, dem das Icon zugeordnet ist, gesendet. Es werden keine Paint-Events an das Fenster gesendet.
  
'''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)''' - Mehrere Systemtrayicons pro Anwendung werden unterstützt. Das Bild es Icons ist momentan ein sehr kleines Fenster, und kann gezeichnet werden und Nachrichten empfangen, wie jedes andere Formular.
  
'''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]
+
'''Linux (WindowMaker, Openbox, etc)''' - Unterstützt von Haus aus keine Systemtrayicons. Allerdings gibt es zwei Anwendungen, die dafür Unterstützung anbieten: [http://icculus.org/openbox/2/docker/ Docker] und [http://freshmeat.net/projects/wmsystray/ WMSystray]
  
'''Mac OS X''' - This system doesn´t really have System Tray icons in the way Linux and Windows have them. This component attempts to use tray-like features of Mac OS X to implement a tray icon. Every application on Mac OS X has a Dock icon. The software can assign a popup menu for this Dock, and this is probably how TrayIcon for Mac OS will work in the future. One compatibility problem is that only one Dock per application can exist.
+
'''Mac OS X''' - Dieses System besitzt keine herkömlichen Systemtrayicons, wie sie Windows und Linux haben. Die Komponete nutzt Tray-ähnliche Funktionen von macOS um ein Trayicon bereitzustellen. Jede Anwendung in MacOS besitzt ein Dockicon und die Software kann diesem Dock ein Kontextmenü zuordnen. Dies ist der Weg, wie TrayIcon in der Zukunft arbeiten wird. Ein Kompatibilitätsproblem ist allerdings die Tatsache, das nur ein Dockicon pro Anwendung möglich ist.
  
You can see here is how it will look like: http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGMenus/chapter_16_section_6.html
+
Hier ist ein Eindruck über das Aussehen zu finden: http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGMenus/chapter_16_section_6.html
  
With this in mind a approach which supports all Platforms was created:
+
Mit diesen Gedanken wurde eine Komponete erstellt, die alle Platformen unterstützt:
  
* 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)
+
* Es ist nur ein Systrayicon pro Anwednung möglich und alle Anwednungen, die ein Systrayicon benutzen, initialisieren dies beim Start. Dazu muss das SystrayIcon-Objekt und nicht seine Klasse verwendet werden. (nötig für macOS)
  
* Painting is done via a TIcon object. (Required by Windows)
+
* Zeichnen wird über das TIcon-Objekt ausgeführt. (nötig für Windows)
  
The following extra features are already available or will be, but they won´t work on all platforms.
+
Die folgenden Funktionen sind außerdem verfügbar, funktionieren jedoch nicht auf allen Plattformen:
  
* Multiple Systray Icons. Won´t work on Mac OS X.
+
* Mehrere Systemtrayicons (Funktioniert nicht mit macOS)
  
* OnPaint event and Canvas property to draw the icon freely. Won´t work on Windows.
+
* OnPaint-Event und Canvas-Property um das Icon frei zu zeichnen. Funktioniert nicht unter Windows)
  
=== External Links ===
+
=== Externe Links ===
  
* http://www.codeproject.com/shell/ctrayiconposition.asp - Code and theory to find the tray icon position under Windows
+
* http://www.codeproject.com/shell/ctrayiconposition.asp - Code und Theorie um die Position des Trayicons unter Windows zu ermitteln.
  
* http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkstatusicon.c?rev=1.23&view=markup - Gtk2 code that implements gtkstatusicon
+
* http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkstatusicon.c?rev=1.23&view=markup - Gtk2-Code, der ein gtkstatusicon implementiert

Latest revision as of 03:59, 23 December 2019

Deutsch (de) English (en)

Über

TrayIcon ist eine crossplattformtaugliche Systemtray-Komponente, die momentan unter folgenden Widgetsets funktioniert: win32, Gtk1, Gnome, Gtk2. Für die Zukunft ist außerdem Carbon ( Mac OS X ) und Qt 4 vorgesehen.

Zwei Schnittstellen werden momentan angeboten: eine visuelle Komponente und ein non-visuelles Objekt. Zweiteres heißt SystrayIcon und ist delphikompatibel. Die visuelle Komponente ist das TTrayIcon, das nur mit Lazarus funktioniert.

Als Schnelleinstieg siehe: das Demonstrationsprogramm.

Dokumentation

Nachfolgend eine Liste mit allen Methoden, Eigenschaften und Ereignissen, die die Komponente zur Verfügung stellt. Namen und Funktion sind für die visuelle und die nicht-visuelle Version identisch. Außerdem arbeiten die Funktionen, außer wenn anders angegeben unter allen Plattformen.

Methoden

Show

procedure Show;

Zeigt das Icon im Systemtray


Hide

procedure Hide;

Entfernt das Icon aus dem Systemtray


GetPosition

function GetPosition: TPoint;

Gibt die Position des Trayicons auf dem Bildschirm aus. Diese Funktion dient dazu, Nachrichten nahe des Icons anzuzeigen. Dies ist allerdings momentan nur ein Platzhalter und nicht implementiert. Stattdessen wird immer der Punkt (0, 0) zurückgegeben.

Eigenschaften

Hint

property Hint: string;


ShowHint

property ShowHint: Boolean;


PopUpMenu

property PopUpMenu: TPopUpMenu;

Gibt ein Popupmenu an, das beim Rechtsklick auf das Icon erscheint.

Ereignisse

OnPaint

property OnPaint: TNotifyEvent;

Erlaubt eine eigene Zeichenroutine für das Canvas des Icons.

Bemerkung: Arbeitet nicht unter Win32!


OnClick

property OnClick: TNotifyEvent;


OnDblClick

property OnDblClick: TNotifyEvent;


OnMouseDown

property OnMouseDown: TMouseEvent;


OnMouseUp

property OnMouseUp: TMouseEvent;


OnMouseMove

property OnMouseMove: TMouseMoveEvent;

Autoren

Felipe Monteiro de Carvalho

Andrew Haines

Lizenz

Modifizierte LGPL

Download

Status: Stabil

Ist bei jeder aktuellen Lazarusinstallation im Ordner lazarus/components/trayicon zu finden.

Installation

GTK2 WORKAROUND Es gibt ein Problem mit Trayicon unter Linux mit GTK2 und FPC 2.1.x oder neuer. Das Problem ist, dass TrayIcon die Unit gdk2x.pp enthält (actually the unit is located inside the opengl component but TrayIcon compiles it into itself). This unit has been added to FPC as of version 2.1.x but it still in the lazarus sources as well, because it doesn't exist on the latest stable FPC (2.0.4). This means that when you install TrayIcon Lazarus will refuse to build the GTK2 LCL complaining that it cannot find unit GTKint. If you look at the messages however you will see the true error: the checksum for gdk2x has changed (this is the result of the duplication). To overcome this, you need to remove either the gdk2x.pp file from the lazarus tree, or the gdk2x.o and gdk2x.ppu file from your FPC units directory. This will be fixed once fpc 2.2.0 is released, at which time gdk2x.pp will be removed from lazarus, so consider this a temporary work-around.

Demonstrationsprogramm

Es gibt 2 Arten ein Trayicon zu erstellen. Ich empfehle die erste leichtere Methode, lasse aber die alte Methode drinne.. Quelle(Diese Seite Englische version).


Die Leichte Variante:

Seit Lazarus 0.9.26 wurde TIcon vollständig implementiert, und es ist nicht länger notwendig das Bild aus einer Ressource zu laden. Das icon kann in der IDE geladen werden, oder auch mit "usual code".

Fügen sie ein TTrayIcon aus Additional in ihrer Form ein.

Füge ein TButton zu deiner Form. Und gebe in sein OnClickEvent folgendes ein.

procedure MyForm.Button1Click(Sender: TObject);
begin
  TrayIcon1.Icon.LoadFromFile('/phad_zum_icon/icon.ico');
  TrayIcon1.ShowHint := True;
  TrayIcon1.Hint := 'Mein tooltip';

  TrayIcon1.PopUpMenu := MyPopUpMenu;

  TrayIcon1.Show;
end;

Die Alte Variante:

Dieses Programm läd ein Icon aus einer internen Ressource (unter Windows) bzw. aus einer externen Datei (unter anderen Plattformen als Windows).

Um die Ressource mit dem Icon unter Windows zu erstellen und einzubinden ist folgendes nötig:

1. Erstellen sie ein Ressourcenskript traytest.rc wie dieses:

101               ICON                    "icon1.ico"

2. Compilieren sie das Ressourcenskript mittels windres.exe in eine *.res Datei. (Windres ist im Lazarusverzeichnis zu finden) Der Befehl lautet: windres -i traytest.rc -o traytest.res

Nun können sie ihr Testprogramm schreiben. Erstellen sie eine neue Anwendung mit einem Formular und fügen sie in die entsprechende Unit folgendes in den Interface-Abschnitt ein:

{$ifdef win32}
  {$R traytest.res}
{$endif}

Als nächstes benötigen sie noch einen Button. Schreiben sie folgendes in das OnClick-Ereignis des Buttons:

procedure MyForm.Button1Click(Sender: TObject);
const
  IDI_ICON1         = 101;
begin
{$ifdef win32}
  SystrayIcon.Icon.Handle := LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
  //7. März 2006 - Das laden einer .ico-Datei unter Windows funktioniert nicht
{$else}
  SystrayIcon.Icon.LoadFromFile('/path_to_icon/icon.ico');
  //7. März 2006 - Es kann zu Problemen mit der Darstellung von .ico-Dateien kommen.
  //Ist dies der Fall, probieren sie xpm (dies löst das Problem unter FedoraCore 4 / Gnome)
{$endif}

  SystrayIcon.ShowHint := True;
  SystrayIcon.Hint := 'Mein Tooltip';

  SystrayIcon.PopUpMenu := MyPopUpMenu;

  SystrayIcon.Show;
end;

Subversion

Zu finden unter components/trayicon/ im aktuellen Subversion-Verzeichnis

Hilfe, Bugreports und Funktionswünsche

Bitte stellen sie Bugreports und Funktionswünsche im Lazarus Bugtracker.

Hilfsanfragen können in der Lazarus-Maillinglist oder im Forum gestellt werden.

Change Log

  1. 17/01/2006 - Als Vorschau in der Lazarus-Subversion verfügbar
  2. 24/01/2006 - stable unter win32, Gnome and Gtk1, aber noch ohne Gtk2-Unterstützung. Lazarus 0.9.12 wurde mit dieser Version veröffentlicht.
  3. 17/02/2006 - gtk2-Unterstützung in Subversion eingefügt

Technische Details

Eine Schwierigkeit in der Entwicklung waren die vielen Unterschiede in der Umsetzung der Implementierungen für den Systemtray unter den unterschiedlichen Betriebssystemen und Windowmanagern unter Linux. Um dies zu lösen, implementiert die Komponente den Satz an minimalen Funktionen, der unter allen Plattformen vorhanden ist. Nachflgend dazu eine Liste der unter den jeweiligen Plattformen implementierten Funktionen:

Windows - Mehrere Systemtrayicons pro Anwendung werden unterstützt. Außerdem ist es möglich, das Icon mittels des HICON-Handle zu modifizieren. Events des Icons werden über eine spezielle Message im für den Nutzer reservierten Messageraum (>= WM_USER) zum Fenster, dem das Icon zugeordnet ist, gesendet. Es werden keine Paint-Events an das Fenster gesendet.

Linux (Gnome, KDE, IceWM, etc) - Mehrere Systemtrayicons pro Anwendung werden unterstützt. Das Bild es Icons ist momentan ein sehr kleines Fenster, und kann gezeichnet werden und Nachrichten empfangen, wie jedes andere Formular.

Linux (WindowMaker, Openbox, etc) - Unterstützt von Haus aus keine Systemtrayicons. Allerdings gibt es zwei Anwendungen, die dafür Unterstützung anbieten: Docker und WMSystray

Mac OS X - Dieses System besitzt keine herkömlichen Systemtrayicons, wie sie Windows und Linux haben. Die Komponete nutzt Tray-ähnliche Funktionen von macOS um ein Trayicon bereitzustellen. Jede Anwendung in MacOS besitzt ein Dockicon und die Software kann diesem Dock ein Kontextmenü zuordnen. Dies ist der Weg, wie TrayIcon in der Zukunft arbeiten wird. Ein Kompatibilitätsproblem ist allerdings die Tatsache, das nur ein Dockicon pro Anwendung möglich ist.

Hier ist ein Eindruck über das Aussehen zu finden: http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGMenus/chapter_16_section_6.html

Mit diesen Gedanken wurde eine Komponete erstellt, die alle Platformen unterstützt:

  • Es ist nur ein Systrayicon pro Anwednung möglich und alle Anwednungen, die ein Systrayicon benutzen, initialisieren dies beim Start. Dazu muss das SystrayIcon-Objekt und nicht seine Klasse verwendet werden. (nötig für macOS)
  • Zeichnen wird über das TIcon-Objekt ausgeführt. (nötig für Windows)

Die folgenden Funktionen sind außerdem verfügbar, funktionieren jedoch nicht auf allen Plattformen:

  • Mehrere Systemtrayicons (Funktioniert nicht mit macOS)
  • OnPaint-Event und Canvas-Property um das Icon frei zu zeichnen. Funktioniert nicht unter Windows)

Externe Links