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 the SysTray events will be handled. 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.
With the QT subsystem, the left-click returns a double-left-click event and the middle-click returns a left-click event.
For normal operation, a systray event must always be associated with a menu.
Example
; Invisible window to just have the systray OpenWindow(0, 0, 0, 10, 10, "", #PB_Window_Invisible) UsePNGImageDecoder() AddSysTrayIcon(0, WindowID(0), LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/world.png")) ; Create a pop-up menu to be displayed by the systray with a systray look CreatePopupImageMenu(0, #PB_Menu_SysTrayLook) MenuItem(0, "About PureBasic...") MenuBar() MenuItem(1, "Exit") ; Associate the menu to the systray SysTrayIconMenu(0, MenuID(0)) Repeat Select WaitWindowEvent() Case #PB_Event_Menu Select EventMenu() Case 1 ; Exit RemoveSysTrayIcon(0) End EndSelect EndSelect ForEver
See Also
RemoveSysTrayIcon(), ChangeSysTrayIcon()
Supported OS
All