|
Restored from previous forum. Originally posted by Franco.
; Place a tray icon ; left click opens a popup menu ; right click closes the program ; (c) 2001 - Franco's template - absolutely freeware
Procedure.l ScreenWidth () ProcedureReturn GetSystemMetrics_(#SM_CXSCREEN) EndProcedure
Procedure.l ScreenHeight () 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, ScreenWidth (), ScreenHeight (), 0, 0, #PB_Window_SystemMenu,"(c) 2001 - Franco's template - absolutely freeware") AddSysTrayIcon(1, WindowID(), LoadIcon_(0, #IDI_WINLOGO))
Repeat Event = WaitWindowEvent() If Event = #PB_EventSysTray If EventMouseButton() = 1 MoveWindow(ScreenWidth (), ScreenHeight ()) ;if somebody resizes the desktop GetCursorPos_(Cursor) xPos=Cursor\x yPos=Cursor\y
DisplayPopupMenu(0, WindowID(), xPos, yPos) Repeat Select WaitWindowEvent() Case #PB_EventMenu Select EventMenuID() 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_EventCloseWindow ExitMenu = 1 EndSelect
Until ExitMenu = 1 Quit = 0 EndIf If EventMouseButton() = 2 SetForegroundWindow_(WindowID()) MessageID = MessageRequester("(c) 2001 - Franco's template", "Do you want to exit the program?", 4) Select MessageID Case 6 ; Yes Button End EndSelect EndIf EndIf Until Event = #PB_EventCloseWindow EndIf End ;---------------------------------------------------------
Have a nice day... Franco
|