From Xojo Documentation

Revision as of 16:50, 12 November 2019 by PLefebvre (talk | contribs) (Sample Code)

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.PressTypes.LeftClick
MessageBox("Left button clicked")
Case TrayItem.PressTypes.DoubleClick
Case TrayItem.PressTypes.RightClick
Var trayMenu As New MenuItem
trayMenu.Add(New MenuItem("About"))
trayMenu.Add(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.