AddSysTrayIcon()

Syntax

Result = AddSysTrayIcon(#SysTrayIcon, WindowID, ImageID)
Description
Adds an icon in the SysTray area.

When an event occurs on any of the SysTray icons the #PB_Event_SysTray event is sent. EventGadget() can be used to know which SysTrayIcon has been used. EventType() functions is also updated by this function.

Parameters

#SysTrayIcon A number to identify the new systray icon. #PB_Any can be used to auto-generate this number.
WindowID The window on which will handle the systray events. WindowID() can be used to get this value.
ImageID The image to use for the systray icon. It is advised to use a PNG image in order to have a transparency layer. ImageID() may be used to get this ID easily.

Return value

Nonzero if the systray icon has been successfully added, zero otherwise.

Remarks

All SysTray icons are automatically removed when the program ends.

Example

  If OpenWindow(0, 0, 0, 300, 100, "", #PB_Window_Invisible)
    ; Create a pop-up menu and a Systray icon (CD symbol) with this menu associated:
    If CreatePopupImageMenu(0)
      MenuItem(0, "Exit")
    EndIf
    AddSysTrayIcon(0, WindowID(0), LoadImage(0, #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico"))
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_SysTray
          Select EventType()
            Case #PB_EventType_RightClick, #PB_EventType_LeftClick
              DisplayPopupMenu(0, WindowID(0)) ; Show pop-up menu after a mouse-click on the Systray icon
          EndSelect
        Case #PB_Event_Menu
          Select EventMenu()
            Case 0 ; Exit 
              RemoveSysTrayIcon(0)
              FreeMenu(0)
              CloseWindow(0)
              End
          EndSelect
      EndSelect
    ForEver
  EndIf

See Also

RemoveSysTrayIcon(), ChangeSysTrayIcon()

Supported OS

All

SysTray Index - ChangeSysTrayIcon() ->