Code updated for 5.20+
Code: Select all
; Place a tray icon
; left click opens a popup menu
; right click closes the program
; (c) 2001 - Franco's template - absolutely freeware
Procedure.l Screen_Width ()
ProcedureReturn GetSystemMetrics_(#SM_CXSCREEN)
EndProcedure
Procedure.l Screen_Height ()
ProcedureReturn GetSystemMetrics_ (#SM_CYSCREEN)
EndProcedure
Structure pt
x.l
y.l
EndStructure
Cursor.pt
If CreatePopupMenu(0)
MenuItem(1, "Cut")
MenuItem(2, "Copy")
MenuItem(3, "Paste")
MenuBar()
OpenSubMenu("Options")
MenuItem(4, "Window...")
MenuItem(5, "Gadget...")
CloseSubMenu()
MenuBar()
MenuItem( 6, "About")
EndIf
;open a window (needed...) but put it outside the desktop
If OpenWindow(0, Screen_Width (), Screen_Height (), 0, 0, "(c) 2001 - Franco's template - absolutely freeware", #PB_Window_SystemMenu)
AddSysTrayIcon(1, WindowID(0), LoadIcon_(0, #IDI_WINLOGO))
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_SysTray
If EventType() = #PB_EventType_LeftClick
ResizeWindow(0, Screen_Width (), Screen_Height (), #PB_Ignore, #PB_Ignore) ;if somebody resizes the desktop
GetCursorPos_(Cursor)
xPos=Cursor\x
yPos=Cursor\y
DisplayPopupMenu(0, WindowID(0), xPos, yPos)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
Select EventMenu()
Case 1 ; Cut
MessageRequester("(c) 2001 - Franco's template", "Cut", 0)
ExitMenu = 1
Case 2 ; Copy
MessageRequester("(c) 2001 - Franco's template", "Copy", 0)
ExitMenu = 1
Case 3 ; Paste
MessageRequester("(c) 2001 - Franco's template", "Paste", 0)
ExitMenu = 1
Case 4 ; Options
MessageRequester("(c) 2001 - Franco's template", "Options", 0)
ExitMenu = 1
Case 5 ; Gadget
MessageRequester("(c) 2001 - Franco's template", "Gadget", 0)
ExitMenu = 1
Case 6 ; About
MessageRequester("(c) 2001 - Franco's template", "Absolutely Freeware!", 0)
ExitMenu = 1
EndSelect
Case #PB_Event_CloseWindow
ExitMenu = 1
EndSelect
Until ExitMenu = 1
Quit = 0
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
;---------------------------------------------------------
Franco