Class
TrayItem
Description
Used to add items to the System Tray. Windows and Linux only.
Property descriptions
TrayItem.Handle
Handle As Ptr
Returns the window handle that the TrayItem belongs to on Windows and the GtkStatusIcon widget on Linux. On Windows, the first TrayItem has a ID of 1000 and subsequent adds will increment this ID.
This property is read-only.
TrayItem.Icon
Icon As Picture
The icon displayed as the TrayItem.
TrayItem.ToolTip
ToolTip As String
Help associated with the TrayItem.
Event descriptions
TrayItem.Action
Action(Cause As Integer)
The user has clicked on the TrayItem.
The parameter Cause indicates the type of click. To determine the kind of click, use the following TrayItem class constants:
TrayItem Class Constant |
---|
DoubleClick |
LeftMouseButton |
RightMouseButton |
Notes
See also the Application.AddTrayItem method for information on adding a TrayItem.
Sample code
Add a class to your project (call it AppTrayItem) and change its super to TrayItem. Also add a property to the App class:
Tray As AppTrayItem
This code instantiates it in the App.Opening event handler:
Tray = New AppTrayItem
If Not Self.AddTrayItem(Tray) Then
' There was an error adding the TrayItem
End If
The following code in the Action event of the AppTrayItem handles mouse clicks and double-clicks:
Select Case cause
Case TrayItem.LeftMouseButton
MessageBox("Left button clicked")
Case TrayItem.DoubleClick
MessageBox("Double-clicked")
Case TrayItem.RightMouseButton
Var trayMenu As New DesktopMenuItem
trayMenu.AddMenu(New DesktopMenuItem("About"))
trayMenu.AddMenu(New DesktopMenuItem("Exit"))
Var result As DesktopMenuItem
result = trayMenu.PopUp
Select Case result.Text
Case "About"
MessageBox("The TrayItem example")
Case "Exit"
Quit
End Select
End Select
When the application quits, you call the RemoveTrayItem method of the DesktopApplication class. This goes in the Close event handler of the App object.
If Tray <> Nil Then
Self.RemoveTrayItem(Tray)
End If
Compatibility
All project types on all supported operating systems.
See also
Object parent class; DesktopApplication class.