Code: Select all
; Invisible window to just have the systray
OpenWindow(10, 0, 0, 10, 10, "", #PB_Window_Invisible)
UsePNGImageDecoder()
AddSysTrayIcon(0, WindowID(10), 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
CreatePopupMenu(0)
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
Debug "Menu item "+EventMenu()+" Window "+EventWindow()
Select EventMenu()
Case 1 ; Exit
RemoveSysTrayIcon(0)
End
EndSelect
EndSelect
ForEver
Code: Select all
Procedure Event_Menu()
Select Event()
Case #PB_Event_Menu
Debug "Menu item "+EventMenu()+" Window "+EventWindow()
Select EventMenu()
Case 1 ; Exit
RemoveSysTrayIcon(0)
End
EndSelect
EndSelect
EndProcedure
; Invisible window to just have the systray
OpenWindow(10, 0, 0, 10, 10, "", #PB_Window_Invisible)
UsePNGImageDecoder()
AddSysTrayIcon(0, WindowID(10), 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
CreatePopupMenu(0)
MenuItem(0, "About PureBasic...")
MenuBar()
MenuItem(1, "Exit")
; Associate the menu to the systray
SysTrayIconMenu(0, MenuID(0))
BindEvent(#PB_Event_Menu, @Event_Menu(), 10)
Repeat
Select WaitWindowEvent()
; Case #PB_Event_Menu
; Debug "Menu item "+EventMenu()+" Window "+EventWindow()
; Select EventMenu()
; Case 1 ; Exit
; RemoveSysTrayIcon(0)
; End
; EndSelect
EndSelect
ForEver
But if in BindEvent() replace the window number with 0 then events appear.
Code: Select all
Procedure Event_Menu()
Select Event()
Case #PB_Event_Menu
Debug "Menu item "+EventMenu()+" Window "+EventWindow()
Select EventMenu()
Case 1 ; Exit
RemoveSysTrayIcon(0)
End
EndSelect
EndSelect
EndProcedure
; Invisible window to just have the systray
OpenWindow(10, 0, 0, 10, 10, "", #PB_Window_Invisible)
UsePNGImageDecoder()
AddSysTrayIcon(0, WindowID(10), 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
CreatePopupMenu(0)
MenuItem(0, "About PureBasic...")
MenuBar()
MenuItem(1, "Exit")
; Associate the menu to the systray
SysTrayIconMenu(0, MenuID(0))
BindEvent(#PB_Event_Menu, @Event_Menu(), 0)
Repeat
Select WaitWindowEvent()
; Case #PB_Event_Menu
; Debug "Menu item "+EventMenu()+" Window "+EventWindow()
; Select EventMenu()
; Case 1 ; Exit
; RemoveSysTrayIcon(0)
; End
; EndSelect
EndSelect
ForEver