From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)

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

Handle fa-lock-32.png Icon ToolTip


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.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
MessageBox("Left button clicked")
Case TrayItem.DoubleClick
Case TrayItem.RightMouseButton
Var trayMenu As New MenuItem
trayMenu.AddMenu(New MenuItem("About"))
trayMenu.AddMenu(New MenuItem("Exit"))

Var result As MenuItem
result = trayMenu.PopUp

Select Case result.Text
Case "About"
MessageBox("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.