; English forum: ; Author: Kale ; Date: 13. April 2003 ; ************************************************************************************* ; Changes for this version compared to Taskbar_Icon_Example.pb ; ************************************************************ ; Its better to use a timer function instead of just a Delay() command ; (which will halt program execution For specified time) see this windowsAPI command: ; SetTimer_(WindowID(), TimerID, delay, address of procedure) ; TimerID = number identifing timer (many can be used) ; delay = milliseconds until procedure is called ; the address of the prodcedure must used for the last parameter you use a '@' sign ; at the beginning of the Procedure name To specify this (see PB manual about this) ; ************************************************************************************* ; Program to create an icon in the task bar that will bring ; up a popup menu on right click and allow you to set a counter that will ; sound an alarm when the counter gets down to 0.... ; set up the popup menu with several pre set times and an exit option.. CreatePopupMenu(0) MenuItem(1, "1 Minute") MenuItem(2, "2 Minutes") MenuItem(3, "3 Minutes") MenuItem(4, "4 Minutes") MenuItem(5, "5 Minutes") MenuItem(6, "10 Minutes") MenuItem(7, "20 Minutes") MenuItem(10, "Quit") ; now open a hiddeen windoe (I think I need this to set the taskbar icon) OpenWindow(0, 10, 10, 10, 10, #PB_Window_Invisible, "Alarm Clock") ;assign a taskbar icon to the above hidden window. AddSysTrayIcon(1, WindowID(), LoadImage(0, "..\..\Graphics\Gfx\tool16.ico")) ; and add a tool tip... SysTrayIconToolTip(1, "Alarm Clock - Right click to set alarm delay") Procedure quitIt() ; so I guess the easiest thing is to change the icon to show it is "locked" ChangeSysTrayIcon(1, LoadImage(0, "Data\locked.ico")) SysTrayIconToolTip(1, "Alarm Clock - LOCKED") ; now tell the user that their time is up ; using a message requester that prints up a message ; and waits for "OK" To be pressed MessageRequester("Alarm Time", "Your Time is up :)", #PB_MessageRequester_Ok) End EndProcedure Repeat ; wait for the user to do something.... Event=WaitWindowEvent() ; is the "event" over the system tray ? If Event = #PB_Event_SysTray Select EventType() Case #PB_EventType_RightClick ; was it a right mouse click ? DisplayPopupMenu(0, WindowID()) ; then display the popup menu EndSelect EndIf ; is the event choosing from a menu ? If Event = #PB_EventMenu Select EventMenuID() Case 1 ; Set Timer to 1 Minute Delay=1000 * 60 Case 2 ; Set Timer to 2 Minutes Delay=2000 * 60 Case 3 ; Set Timer to 3 minutes (etc...) Delay=3000 * 60 Case 4 Delay=4000 * 60 Case 5 Delay=5000 * 60 Case 6 Delay=10000 * 60 Case 7 Delay=20000 * 60 Case 10 ; Quit Quit = 1 EndSelect EndIf ; keep doing the above until user chooses a delay time or the quit option If Delay > 0 SetTimer_(WindowID(), 1, Delay, @quitIt()) EndIf Until Event = #PB_EventCloseWindow Or Quit = 1 End ; ExecutableFormat=Windows ; FirstLine=1 ; EnableXP ; EOF