Page 1 of 1

Enhanced Systray Library

Posted: Tue Jan 26, 2010 11:41 am
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

Re: Enhanced Systray Library

Posted: Tue Jan 26, 2010 11:48 am
by atomo
You can already do this with the Menu Library.

Re: Enhanced Systray Library

Posted: Tue Jan 26, 2010 11:50 am
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

Re: Enhanced Systray Library

Posted: Tue Jan 26, 2010 11:52 am
by UserOfPure
And you don't need DesktopMouseX() or DesktopMouseY() either; just leave them out (they're optional).

Re: Enhanced Systray Library

Posted: Sat Jan 30, 2010 2:30 am
by Arcturus
Thanks, I always wondered how to do this.