From Xojo Documentation

Class (inherits from Object)

Used to add items to the System Tray. Windows and Linux only.

Handle fa-lock-32.png HelpTag Icon


See also the Application.AddTrayItem method for information on adding a TrayItem.

Class Constants

The following class constants can be used in the Action event to determine the way the user clicked on the TrayItem.

Class Constants Description
DoubleClick The user double-clicked.
LeftMouseButton The user held down the Left mouse button and clicked.
RightMouseButton The user held down the Right mouse button and clicked.

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.Open 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
MsgBox("Left button clicked")
Case TrayItem.DoubleClick
Case TrayItem.RightMouseButton
Dim trayMenu As New MenuItem
trayMenu.Append(New MenuItem("About"))
trayMenu.Append(New MenuItem("Exit"))

Dim result As MenuItem
result = trayMenu.PopUp

Select Case result.Text
Case "About"
MsgBox("The TrayItem example")
Case "Exit"
End Select
End Select

When the application quits, you call the RemoveTrayItem method of the Application class. This goes in the Close event handler of the App object.

If Tray <> Nil Then
End If

See Also

Application class.