Enhanced Systray Library

Just starting out? Need help? Post your questions and find answers here.
Arcturus
User
User
Posts: 14
Joined: Tue Jan 26, 2010 11:23 am
Location: Australia
Contact:

Enhanced Systray Library

Post by Arcturus »

I was wondering if you could expand the Systray library? One feature I would particularly like to see is to have a context menu appear when a user clicks/right clicks on the Systray, or maybe it would be better to have a command that opens a context menu on the Systray icon, like this:

Code: Select all

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_SysTray
    If EventType() = #PB_EventType_LeftDoubleClick
      OpenContextMenu(SysTrayID(0))
        ContextMenuItem(0, "Item 1")
        ContextMenuItem(1, "Item 2")
        ContextMenuBar()
        ContextMenuItem(3, "Item 3")
    EndIf

  EndIf
Until Event = #PB_Event_CloseWindow
Give a man fire and he's warm for a day; set a man on fire and he's warm for the rest of his life
atomo
User
User
Posts: 65
Joined: Thu May 22, 2008 10:32 pm

Re: Enhanced Systray Library

Post by atomo »

You can already do this with the Menu Library.
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Enhanced Systray Library

Post by eesau »

As atomo said, you can already do this. Here's a quick example:

Code: Select all

LoadImage(0, #PB_Compiler_Home + "\Examples\Sources\Data\CdPlayer.ico")

OpenWindow(0, 0, 0, 100, 100, "Systray Menu", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

AddSysTrayIcon(0, WindowID(0), ImageID(0))

CreatePopupMenu(0)
	MenuItem(0, "A")
	MenuItem(1, "B")
	MenuItem(2, "C")

Repeat

	Event = WaitWindowEvent()
	
	Select Event
	
		Case #PB_Event_CloseWindow
			Break
	
		Case #PB_Event_SysTray
			DisplayPopupMenu(0, WindowID(0), DesktopMouseX(), DesktopMouseY())					
	
	EndSelect

ForEver
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Re: Enhanced Systray Library

Post by UserOfPure »

And you don't need DesktopMouseX() or DesktopMouseY() either; just leave them out (they're optional).
Arcturus
User
User
Posts: 14
Joined: Tue Jan 26, 2010 11:23 am
Location: Australia
Contact:

Re: Enhanced Systray Library

Post by Arcturus »

Thanks, I always wondered how to do this.
Give a man fire and he's warm for a day; set a man on fire and he's warm for the rest of his life
Post Reply