Class

DesktopTrayItem


Description

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

Properties

Name

Type

Read-Only

Shared

Handle

Ptr

Icon

Picture

Tooltip

String

Events

Name

Parameters

Returns

Pressed

cause As PressedTypes

Enumerations


DesktopTrayItem.PressedTypes

PressedTypes

The mouse clicks that can occur on a DesktopTrayItem.

Name

Description

DoubleClick

A double-click occurred.

LeftClick

The left mouse button was clicked.

RightClick

The right mouse button was clicked.

Property descriptions


DesktopTrayItem.Handle

Handle As Ptr

Returns the window handle that the DesktopTrayItem belongs to on Windows and the GtkStatusIcon widget on Linux. On Windows, the first DesktopTrayItem has a ID of 1000 and subsequent adds will increment this ID.

This property is read-only.


DesktopTrayItem.Icon

Icon As Picture

The icon displayed as the DesktopTrayItem.


DesktopTrayItem.Tooltip

Tooltip As String

Help associated with the DesktopTrayItem.

Event descriptions


DesktopTrayItem.Pressed

Pressed(Cause As PressedTypes)

The user has clicked on the DesktopTrayItem.

The parameter Cause indicates the type of click.

Notes

See also the DesktopApplication.AddTrayItem method for information on adding a DesktopTrayItem.

Sample code

Add a class to your project (call it AppTrayItem) and change its super to DesktopTrayItem. 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 Pressed event of the AppTrayItem handles mouse clicks and double-clicks:

Select Case cause
Case DesktopTrayItem.PressedTypes.LeftClick
  MessageBox("Left button clicked")
Case DesktopTrayItem.PressedTypes.DoubleClick
  MessageBox("Double-clicked")
Case DesktopTrayItem.PressedTypes.RightClick
  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 Closing event handler of the App object.

If Tray <> Nil Then
  Self.RemoveTrayItem(Tray)
End If

Compatibility

Desktop project types on the Linux and Windows operating systems.

See also

Object parent class; DesktopApplication class.