The gb.gui.trayicon component allows you to display a tray icon in the taskbar. The following system tray protocols are supported:
The DBus system protocol should be standard, but unfortunately KDE and Ubuntu implementations are not compatible with each other! The component therefore examines at runtime which type of system tray is available on the system. The appropriate protocol is then selected automatically. The component gb.dbus is only loaded if the DBus protocol is also used.
While the TrayIcon class implements a tray icon, the TrayIcons class provides a virtual collection of all TrayIcon objects managed by an application.
The class TrayIcon has these properties:
|Icon||Picture||Returns the icon or sets the icon for the tray icon.|
|Picture||Picture||A synonym for the icon property.|
|PopupMenu||String||The name of the menu is set or returned when a user clicks on the tray icon.|
|Tag||Variant||Returns the value of the Tag property or sets the value of this property. This property is intended for the programmer and is never used by the component. tag can have any value of type Variant.|
|ToolTip||String||Returns the text of the tool tip or sets the text of the tool tip displayed for the tray icon.|
|Text||String||A synonym for the tooltip property.|
|Visible||Boolean||Specifies whether the tray icon is visible or sets True to indicate that the tray icon is visible.|
Table 126.96.36.199.1.1: Properties of the TrayIcon class
The class TrayIcon has only three methods:
|Delete ()||Deletes a TrayIcon object.|
|Hide()||Hide the tray icon from the system tray.|
|Show ()||Displays the tray icon in the system tray.|
Table 188.8.131.52.1: Methods of the class TrayIcon
If you want to close the window of an application that uses a TrayIcon object, you must first use the TrayIcon.Hide () method!
Only three events are triggered by the class TrayIcon:
|Click||This event is triggered when the user clicks on the tray icon with the left mouse button.|
|MiddleClick||This event is triggered when the user clicks on the tray icon with the middle mouse button.|
|Scroll (Delta As Float, Orientation As Integer)||This event is triggered when the user scrolls with the mouse over the tray icon.|
Table 184.108.40.206.1: Events of the TrayIcon class
Notes on the Scroll (…) event
In chapter 13.6 Context menu - TrayIcon you will find a project that uses selected properties, methods and events of the class TrayIcon.
19.2.2 Class TrayIcons
This class implements a virtual collection of all TrayIcon objects managed by an application. This class behaves like a read-only class.
Dim hTrayIcon As TrayIcon hTrayIcon = TrayIcons [ Index As Integer ]
All TrayIcon objects can be iterated with the keyword pair “For Each”:
Dim hTrayIcon As TrayIcon For Each hTrayIcon In TrayIcons ... Next
While the TrayIcons.Count property returns the number of TrayIcon objects managed by an application, the only method TrayIcons.DeleteAll () of the TrayIcons class deletes all TrayIcon objects.