Thanks to Danilo over in the German forum for providing the ground work. I threw in some color and added some boarder work to dress up the appearance. Also added an alarm feature sure to grab your attention, asleep or awake. Flashing the whole desktop was a trick I learned back in my GFA Basic days. And here it is:
Code: Select all
; Original Reference, written as "Clock_Timer.pb":
; German forum: http://www.purebasic.fr/german/archive/viewtopic.php?t=3528&highlight=
; THAT IS A BAD LINK AND I THINK MOVED TO HERE:
; http://www.purearea.net/pb/CodeArchiv/Time+Date/Clock/Clock_Timer.pb
; Author: Danilo (updated for PB 4.00 by Andre)
; Date: 23. January 2004
; OS: Windows
; Demo: No
; Adaptation by Randy Walker as "3amAlarm.pb" (Jan 5, 2011 for PB ver 4.20)
; New features include "window dressing", "borderless draggable window" and "STUNNING" alarm.
; (not to mention lots and lots of program line comments)
; Resized to make it readable in high rez screens and compatibilized for PB ver 6.xx (Jan 24, 2025)
If InitMouse() = 0
End
EndIf
Global lippi.LASTINPUTINFO ; Wow! Who understands this stuff??!
lippi\cbSize = SizeOf(LASTINPUTINFO) ; Compensating for "dumb" API I guess??
Global mPntr.Point ; DO NOT REUSE ; Used to restore mouse position
Global CursorPosition.Point ; ok to reuse
Global wSpec.Rect, t.q ; ok to reuse
Global alarm.l, alarm$, al_h.l, al_m.l, al_s.l, secs.l, HOUR.l, minute.l, SECOND.l, reminder.l, SkypeLimit.l, activated
Global dsktp.l ,quit.l, Disabled.l, dumbSoundCard.l, wasMinimized.l, stump.l, keepout.l,alarmTime$
Global patch, active.w, targetWindow$, hWin.l, HWNDlogo.w ; ALSO SEE: Globals() procedure
Global hTooltip.l
#TTS_BUBBLE = $40
Global Dim Tool.TOOLINFO(0)
Define x, success
Define ini_Signal$ = "C:\accessories\alarm.wav"
Global IsSound = 0
#RingTone = 0
If Asc(ini_Signal$) And FileSize(ini_Signal$) > 0 And InitSound()
If LoadSound(#RingTone, ini_Signal$)
IsSound = #True ;SoundLength(#RingTone, #PB_Sound_Millisecond)
EndIf
EndIf
Procedure Sound(*Value)
If PeekI(*Value) = 1 And IsSound
PlaySound(#RingTone)
Delay(200);IsSound)
EndIf
EndProcedure
Procedure AddTip(Handle,Text.s)
Tool(0)\cbSize = SizeOf(TOOLINFO)
Tool(0)\uFlags = #TTF_SUBCLASS|#TTF_IDISHWND
Tool(0)\hwnd = Handle
Tool(0)\uId = Handle
Tool(0)\hInst = GetModuleHandle_(0)
Tool(0)\lpszText = @Text
SendMessage_(hTooltip,#TTM_ADDTOOL,0,@Tool(0));
EndProcedure
Procedure ListWindows(Window, Parameter) ; used inside Gt_Prog()
; WindowClass.s = Space(255)
WindowTitle.s = Space(255)
; e.l = GetWindowLong_(Window,#GWL_ID) ; PB Window_# (0,1,2,3, etc)
; GetClassName_(Window, WindowClass, 255)
GetWindowText_(Window, WindowTitle, 255)
If FindString(WindowTitle,targetWindow$,1)
active.w = 1
hWin.l = Window
EndIf
ProcedureReturn #True
EndProcedure
Procedure Gt_Prog(dmy$) ; input : 11 char PROCESS name , active.w = true if running : hWin.l holds Window handle
targetWindow$ = dmy$
active.w = 0
hWin.l = 0
EnumWindows_(@ListWindows(), 0) ; Windows CallBack operation.
ProcedureReturn active.w
EndProcedure
If FileSize("alarm.wav") > 0
If InitSound() <> 0
If LoadSound(0,"alarm.wav")
; dumbSoundCard.l = #True
EndIf
EndIf
EndIf
;
dsktp.l = GetDesktopWindow_()
Disabled = GetSysColor_(#COLOR_INACTIVECAPTIONTEXT)
Procedure.f DSin(angle_in_degree.f)
; returns Sinus of 'angle in degree (and bannishes any flu symptoms you may have)
ProcedureReturn Sin(angle_in_degree*0.01745329)
EndProcedure
Procedure.f DCos(angle_in_degree.f)
; returns CoSinus of 'angle in degree (and bannishes any flu symptoms your partner may have)
ProcedureReturn Cos(angle_in_degree*0.01745329)
EndProcedure
Procedure Lin(HDC,X,Y,x1,y1,width,Color)
; by einander, english forum
pen=CreatePen_(#PS_SOLID,width,Color) ; You can also change the style with #Ps_dash, #Ps_dot, #Ps_dashdotdot, but only when the pen width equals 1.
hPenOld=SelectObject_(hDC,pen)
MoveToEx_(hDC,x,y,0):LineTo_(hDC,x1,y1)
DeleteObject_(SelectObject_(hDC,hPenOld))
EndProcedure
Procedure UpdateDisplay()
date = reminder & $F
reminder >> 4
reminder + (date << 20)
date$ = FormatDate("%mm/%dd",Date())
date = Date()
SECOND = Second(date)
minute = Minute(date)
HOUR = Hour(date)
sec.f = (180-SECOND*6)
min.f = (180-minute*6)-second/10
;std.f = (180-Hour(date)*30)-minute/2
std.f = (180-Hour*30)-minute/2
;Debug std
HDC = StartDrawing(ImageOutput(1))
If HDC
If reminder
Circle(181,159,111,reminder)
Else
Circle(181,159,111,$DEEFEF)
EndIf
If secs
time$ = FormatDate("%hh:%ii:%ss",Date())
Else
time$ = FormatDate(" %hh:%ii",Date())
EndIf
FrontColor(RGB(Red(ForeGround),Green(ForeGround),Blue(ForeGround)))
DrawingMode(1)
DrawingFont(FontID(1))
DrawImage(ImageID(42),80,315)
DrawText(120,200,date$)
DrawText(80,315,time$)
Lin(HDC,180,159,180+DSin(std)*100,159+DCos(std)*90,10,0)
Lin(HDC,180,159,180+DSin(std)*48,159+DCos(std)*48,9,0)
Lin(HDC,180,159,180+DSin(std)*48,159+DCos(std)*48,6,0)
Circle(180+DSin(std)*70,159+DCos(std)*70,9,$0)
Lin(HDC,180,159,180+DSin(min)*99,159+DCos(min)*99, 6,$FF2222)
Circle(180+DSin(min)*81,159+DCos(min)*81,9,$FF2222)
If secs
Circle(180,159,6,$4444FF)
LineXY( 180,159,180+DSin(sec)*109,159+DCos(sec)*109, $4444FF)
EndIf
If alarm
If alarm_flash
Circle(299,57,12,$00BB00)
alarm_flash = #False
Else
Circle(299,57,12,$FF0000)
alarm_flash = #True
EndIf
ForeGround = GetSysColor_(#COLOR_BTNTEXT)
FrontColor(RGB(Red(ForeGround),Green(ForeGround),Blue(ForeGround)))
DrawingMode(1)
DrawingFont(FontID(1))
DrawText(285,32,Chr(164))
;Box(293,51,12,12,$00FF00)
Circle(299,56,5,$00FF00)
Else
Box(282,44,33,33,$A0E4F0) ;LED ERASER
EndIf
StopDrawing()
EndIf
SetGadgetState(1,ImageID(1))
s$ = Right("0"+Str(HOUR),2) + ":" + Right("0"+Str(minute),2)
If secs
s$ = s$ + ":" + Right("0"+Str(SECOND),2)
EndIf
If alarm
s$ = s$ + " *" + alarm$
EndIf
SetWindowTitle(1,s$)
Delay(800)
EndProcedure
Procedure ReallySetForegroundWindow(MSwnd)
hWnd = MSwnd
; If the window is in a minimized state, maximize now
If GetWindowLong_(hWnd, #GWL_STYLE) & #WS_MINIMIZE
ShowWindow_(hWnd, #SW_MAXIMIZE)
UpdateWindow_(hWnd)
EndIf
; Check To see If we are the foreground thread
foregroundThreadID = GetWindowThreadProcessId_(GetForegroundWindow_(), 0)
ourThreadID = GetCurrentThreadId_()
; If not, attach our thread's 'input' to the foreground thread's
If (foregroundThreadID <> ourThreadID)
AttachThreadInput_(foregroundThreadID, ourThreadID, #True);
EndIf
; Bring our window To the foreground
SetForegroundWindow_(hWnd)
; If we attached our thread, detach it now
If (foregroundThreadID <> ourThreadID)
AttachThreadInput_(foregroundThreadID, ourThreadID, #False)
EndIf
; Force our window To redraw
InvalidateRect_(hWnd, #Null, #True)
EndProcedure
Procedure flash(wndw.l) ;/ REQUIRES EVEN NUMBER PASSES to return to normal screen ! ! ! ! !
; irritate video sensory organs
GetClientRect_(wndw, wSpec)
InvertRect_(GetWindowDC_(wndw), wSpec)
; irritate audio sensory organs
Debug "need sound"
If 1=0;IsSound = #True
PlaySound(#RingTone)
Else
Beep_(800,100)
Beep_(900,100)
Beep_(1070,100)
EndIf
EndProcedure
Procedure testAlarm()
If keepout = #False
If alarm.l ; Then beep and flash 8 times
Debug Str(HOUR)+" "+Str(al_h)
Debug Str(minute)+" "+Str(al_m)
Debug Str(SECOND)+" "+Str(al_s)
If (al_s.l = SECOND) And (al_h.l=HOUR) And (al_m.l=minute)
Debug " Hit Alarm set time"
keepout = #True ; prevent multiple instances of #timer activations
ShowWindow_(WindowID(1),#SW_MINIMIZE)
;BringWindowToTop_(WindowID(1))
Fcount = 1
Repeat
Select WaitWindowEvent()
Case #PB_Event_Timer
flash(dsktp) ;/ <<< REQUIRES EVEN NUMBER PASSES to return to normal screen ! ! ! ! !
UpdateDisplay()
Fcount + 1
EndSelect
Until (Fcount & 1) And (Fcount > 8) ;- << ADJUST NUMBER OF FALSHES AND BEEPS YOU WANT HERE <<
ShowWindow_(WindowID(1),#SW_RESTORE)
alarm.l = #False
reminder = $4B6D8F
keepout = #False
EndIf
Debug ""
EndIf
EndIf
EndProcedure
Procedure InitImage() ; DRAW MAIN WINDOW DRESSINGS
img = CreateImage(1,372,390)
If img = 0
MessageRequester("ERROR","Cant create image!",#MB_ICONERROR):End
EndIf
LoadFont(1,"Verdana",27,#PB_Font_Italic | #PB_Font_Bold)
If StartDrawing(ImageOutput(1))
Box(3,3,357,366,$80BBDF)
Box(6,8,348,348,$A0E4F0)
Box(9,13,339,330,$80BBDF)
Box(12,18,330,312,$A0E4F0)
Box(15,23,321,294,$80BBDF)
Box(18,28,312,276,$A0E4F0)
Box(21,33,303,258,$80BBDF)
Box(24,38,294,240,$A0E4F0)
LineXY( 3,373,357,373, $666666)
Circle(181,159,111,$999999)
ForeGround = GetSysColor_(#COLOR_BTNTEXT)
FrontColor(RGB(Red(ForeGround),Green(ForeGround),Blue(ForeGround)))
DrawingMode(1)
DrawingFont(FontID(1))
DrawText(181-TextWidth("12")/2,-3,"12")
DrawText(30,135,"9")
DrawText(305,135,"3")
DrawText(181-TextWidth("6")/2,275,"6")
For a = 0 To 360 Step 6
sin.f = DSin(a)
cos.f = DCos(a)
If a % 5
Circle(180+sin*118,159+cos*118,1,0)
Else
Circle(180+sin*118,159+cos*118,2,0)
EndIf
If a % 10 = 0
For b = 2 To 0 Step -1
Plot(180+sin*(111-b),159+cos*(111-b),0)
Next b
EndIf
Next a
StopDrawing()
patch = GrabImage(1,42,80,315,210,45)
EndIf
ProcedureReturn img
EndProcedure
Procedure configure()
Static secflag.l, alarmh$, alarmm$, alarms$, trump$, t.q
SM_CXscreen = GetSystemMetrics_(#SM_CXSCREEN)
SM_CYscreen = GetSystemMetrics_(#SM_CYSCREEN)
GetCursorPos_(@CursorPosition.Point)
wx.l = CursorPosition\X-40 ; offset here because used to determine window placement.
wy.l = CursorPosition\Y-124 ; offset here because used to determine window placement.
If wx < 2
wx = 2
EndIf
If wx > SM_CXscreen - 115
wx = SM_CXscreen - 115
EndIf
If wy < 30
wy = 30
EndIf
If wy > SM_CYscreen - 130
wy = SM_CYscreen - 130
EndIf
reminder = #False
trump$ = Right("00"+Str(SkypeLimit),2)
If OpenWindow(0,wx,wy,100,160,"3amAlarm*",#WS_DLGFRAME)
ButtonGadget (100, 20, 109, 30, 24, "OK")
TextGadget (101, 26, 5, 55, 17, " : :", #PB_Text_Border) ; **MILITARY** TIME ! ! !
;
If Hour(Date()) < 12
day = Day(Date())
Else
day = Day(Date())+1
EndIf
year = Year(Date())
month = Month(Date())
If t = 0
t = Date(year,month,day,3,0,0)
EndIf
;t = 1737784800
DateGadget(102, 30, 7, 90, 25, "", 0, #PB_Date_UpDown)
SetGadgetState(102, t)
SetWindowLong_(GadgetID(102), #GWL_STYLE, GetWindowLong_(GadgetID(102), #GWL_STYLE) | #DTS_TIMEFORMAT)
alarmTime$ = GetGadgetText(102)
CheckBoxGadget (105, 30, 27, 60, 18, "Alarm")
CheckBoxGadget (106, 12, 47, 70, 18,"Show secs")
; StringGadget (107, 85, 67, 14, 13,trump$, #PB_String_Numeric|#PB_String_BorderLess|#ES_MULTILINE|#ES_AUTOVSCROLL|$10000000)
ButtonGadget (108, 54, 109, 36, 24, "Kill")
SetGadgetColor(102, #PB_Gadget_BackColor, $DDF3FF)
SendMessage_(GadgetID(102),#EM_SETLIMITTEXT,2,0)
; SendMessage_(GadgetID(107),#EM_SETLIMITTEXT,2,0)
EndIf
If Len(alarm$) = 0 ; **MILITARY** TIME ! ! !
secflag = 1
alarm = 1
; alarmh$="03:00:00" ; Default is enabled at 3:00 AM -- hence the name "3amAlarm"
alarmm$="00" ; Default is enabled at 3:00 AM -- hence the name "3amAlarm"
alarms$="00" ; Default is enabled at 3:00 AM -- hence the name "3amAlarm"
EndIf
If alarm
SetGadgetColor(101, #PB_Gadget_BackColor, $DDF3FF)
Else
SetGadgetColor(101, #PB_Gadget_BackColor, Disabled)
EndIf
SetGadgetState(106, secflag)
SetGadgetState(105, alarm)
DisableGadget(102,alarm-1)
HideWindow(0,0)
SetActiveGadget(100)
q.l=#False
Repeat
oldgadget = GetActiveGadget()
Select WaitWindowEvent()
Case #PB_Event_Gadget
Gadget = EventGadget()
Select Gadget
Case 105 ; AlarmCheck
alarm.l=GetGadgetState(105)
DisableGadget(102,alarm-1)
If alarm
SetGadgetColor(101, #PB_Gadget_BackColor, $DDF3FF)
SetWindowTitle(0," 3amAlarm*")
Else
SetGadgetColor(101, #PB_Gadget_BackColor, Disabled)
SetWindowTitle(0," 3amAlarm")
EndIf
SetActiveGadget(100)
Case 106
SetActiveGadget(100)
Case 102, 103, 104, 107 ; Hr|Mn|Sc
If oldgadget <> Gadget ; Catch Caret relocation
PostMessage_(GadgetID(Gadget),#EM_SETSEL,2,0)
EndIf
; Case 110 ; Stump Skype - closewindow on it
Case 100 ; OK
q =100
Case 108 ; Kill
quit = #True
q =108
EndSelect
Case #PB_Event_Timer
UpdateDisplay()
testAlarm()
Case #WM_KEYDOWN
Select EventwParam()
Case #VK_RETURN ; watch for Tab refocus
s$=GetGadgetText(oldgadget)
k.l=FindString(s$,Chr(13)+Chr(10),1) ; Stop CR/LF Ding
If k.l<>0 ; Was Enter pressed on the StringGadget?
s$ = ReplaceString(s$,Chr(13)+Chr(10),"")
SetGadgetText(oldgadget,s$) ; Yes, so remove CR+LF.
;PostMessage_(GadgetID(oldgadget), #EM_SETSEL, k.l-1, k.l-1) ; Set cursor position back.
WaitWindowEvent()
Repeat : _mess = WindowEvent() : Until _mess = 0
EndIf
k.l=FindString(s$,Chr(13),1) ; Stop CR/LF Ding
If k.l<>0 ; Was Enter pressed on the StringGadget?
s$ = ReplaceString(s$,Chr(13),"")
SetGadgetText(oldgadget,s$) ; Yes, so remove CR+LF.
;PostMessage_(GadgetID(oldgadget), #EM_SETSEL, k.l-1, k.l-1) ; Set cursor position back.
WaitWindowEvent()
Repeat : _mess = WindowEvent() : Until _mess = 0
EndIf
SetGadgetText(oldgadget,s$) ; Yes, so remove CR+LF.
Select oldgadget
Case 102, 103
PostMessage_(GadgetID(oldgadget),#EM_SETSEL,2,0)
Case 104, 107
oldgadget = 99
Case 100
q =100
EndSelect
SetActiveGadget(oldgadget)
Debug s$
Debug Len(s$)
EndSelect
EndSelect
Until q.l
q = Val(StringField(GetGadgetText(102),1,":"))
Minute = Val(StringField(GetGadgetText(102),2,":"))
Second = Val(StringField(GetGadgetText(102),3,":"))
If Hour(Date()) > q
day = Day(Date())+1
Else
day = Day(Date())
EndIf
year = Year(Date())
month = Month(Date())
t = Date(year,month,day,q,Minute,Second)
secflag.l=GetGadgetState(106)
alarm.l=GetGadgetState(105) ; **MILITARY** TIME ! ! !
alarmh$=StringField(GetGadgetText(102),1,":")
alarmm$=StringField(GetGadgetText(102),2,":")
alarms$=StringField(GetGadgetText(102),3,":")
alarm$=alarmh$ + ":" + alarmm$ + ":" + alarms$
al_h.l=Val(Left(alarm$,2)) ; This could use error proofing
If FindString(GetGadgetText(102),"PM")
al_h.l + 12
EndIf
al_m.l=Val(Mid(alarm$,4,2)) ; if user is too lazy or dumb to
al_s.l=Val(Mid(alarm$,7,2)) ; edit using proper military time.
secs.l=GetGadgetState(106)
If stump.l
SkypeLimit = 0
EndIf
CloseWindow(0)
EndProcedure
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
; Windows fills the parameter automatically, which we will use in the callback...
If hWnd = WindowID(1)
If keepout = #False
Select uMsg
Case #WM_SIZE ; Only effective if window 1 style excludes BorderLess|DLGFRAME.
Select wParam
Case #SIZE_MINIMIZED ;/ Track Landing Pad window status in case user minimizes manually.
wasMinimized = #True ;/ CRITICAL PART OF HONORING WINDOW QUEUE MANAGEMENT!!!!
Case #SIZE_RESTORED
wasMinimized = #False ;/ CRITICAL PART OF HONORING WINDOW QUEUE MANAGEMENT!!!!
EndSelect
EndSelect
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
SkypeLimit = 0
configure()
;/ PLEASE READ -- PLEASE READ -- PLEASE READ -- PLEASE READ -- PLEASE READ
; **Consider, this is an "ALARM CLOCK" so you do not want to kill it accidentally.
; That is why it is not as "convenient" as possible to exit the program.
;/ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
;/ TRY BOTH OPENWINDOW STYLES FOR YOUR PREFERENCE
;/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
;If OpenWindow(1,3,3,123,129,"3amAlarm") ; << enables title bar menu options <<
If OpenWindow(1,3,3,368,380,"3amAlarm",#PB_Window_BorderLess|#WS_DLGFRAME)
ImageGadget(1,1,1,372,390,InitImage())
;
;
hTooltip = CreateWindowEx_(#WS_EX_TOPMOST, "tooltips_class32", 0,#TTS_ALWAYSTIP|#TTS_NOPREFIX|#WS_POPUP|#TTS_BUBBLE,#CW_USEDEFAULT,#CW_USEDEFAULT, #CW_USEDEFAULT,#CW_USEDEFAULT,WindowID(1), 0, GetModuleHandle_(0), 0);
SetWindowTheme_(hTooltip, @null.w, @null.w)
SendMessage_(hTooltip,#TTM_SETDELAYTIME,#TTDT_INITIAL,0)
SendMessage_(hTooltip,#TTM_SETTIPTEXTCOLOR,$0002FF,0) ;TextColor Tooltip
SendMessage_(hTooltip,#TTM_SETTIPBKCOLOR,$D1FFFF,0) ;BackColor Tooltip
SendMessage_(hTooltip,#TTM_SETMAXTIPWIDTH,0,160) ;Max tip width
r.RECT
SetRect_(r,10,10,10,10) ;Tip Margins
SendMessage_(hTooltip,#TTM_SETMARGIN,0,r)
SendMessage_(hTooltip,#TTM_ACTIVATE,#False,0) ;DeActivate
SendMessage_(hTooltip,#TTM_ACTIVATE,#True,0) ;Activate
LoadFont(0, "Tahoma",11,#PB_Font_HighQuality)
SendMessage_(hTooltip,#WM_SETFONT,FontID(0),0)
AddTip(WindowID(1),"Right Click for Options. Double Click to Minimize. Click hold and drag. One click stop alarm")
;
; Next 3 lines are only useful if window style excludes #PB_Window_BorderLess|#WS_DLGFRAME.
menubar.l=GetSystemMenu_(WindowID(1),0)
ModifyMenu_(menubar.l,#SC_CLOSE,#MF_BYCOMMAND,#SC_CLOSE,"Hide 3amAlarm") ; ,"Close 3amAlarm")
AppendMenu_(menubar.l,#MF_STRING,100,"Settings...") ; used in main loop under WM_SYSCOMMAND
SetWindowCallback(@WinCallback()) ; activate the callback to monitor system tray icon
; no idea how or why the following 3 lines allow window mouse dragging (but I like it :-)
SetWindowLong_(GadgetID(1), #GWL_STYLE, GetWindowLong_(GadgetID(1), #GWL_STYLE) &~#SS_NOTIFY)
#BS_FLAT=$8000
SetWindowLong_(GadgetID(1),#GWL_STYLE,GetWindowLong_(GadgetID(1),#GWL_STYLE) |#BS_FLAT)
UpdateDisplay() ; Get first update before entering main loop.
;SetTimer_(WindowID(1),0,1000,0) ; Timer message triggers at 1000 milliseconds (1 second interval)
AddWindowTimer(1,0,1000) ; Timer message triggers at 1000 milliseconds (1 second interval)
Repeat
evnt = WaitWindowEvent(3000)
Select evnt
Case #WM_RBUTTONDOWN ; Opens the options window for settings or exit.
configure()
If quit
Break
EndIf
Case #WM_LBUTTONDBLCLK ; Gets the "stupid thing" out of the way!! ! ! ! !
wasMinimized = #True ;/ CRITICAL PART OF HONORING WINDOW QUEUE MANAGEMENT!!!!
ShowWindow_(WindowID(1),#SW_MINIMIZE)
Case #WM_LBUTTONDOWN ; Hold and drag to move the clock on desktop.
reminder = #False
SendMessage_(WindowID(1),#WM_NCLBUTTONDOWN, #HTCAPTION,0)
Case #PB_Event_Timer ; "tick" second hand and test trigger-setting for alarm.
UpdateDisplay()
testAlarm()
If stump.l
If Gt_Prog("Skype") ; Prevent Skype windows from dominating taskbar.
SendMessage_(hWin.l, #WM_CLOSE,0,0)
While WindowEvent() <> 0 : Wend
If Gt_Prog("Skype") ; Prevent Skype windows from dominating taskbar.
SendMessage_(hWin.l, #WM_CLOSE,0,0)
While WindowEvent() <> 0 : Wend
EndIf
EndIf
EndIf
Case #WM_SYSCOMMAND ; Only effective if window style excludes BorderLess|DLGFRAME.
_wParam=EventwParam()
If _wParam=100 ; 100 is reference to value inside the AppendMenu_ line seen above.
configure()
EndIf
Default
If activated
GetLastInputInfo_(@lippi)
timeNow.l = ElapsedMilliseconds() ; get current timestamp value for comparison calculations
If timeNow.l - lippi\dwTime < 4
SetForegroundWindow_(activated)
activated = 0
SetCursorPos_(mPntr\x,mPntr\y)
ShowCursor_(1)
If wasMinimized
SetWindowState(1,#PB_Window_Minimize)
EndIf
EndIf
EndIf
EndSelect
Until evnt = #PB_Event_CloseWindow
If quit
RemoveWindowTimer(1,0)
CloseWindow(1)
EndIf
EndIf
End
[EDIT] Applied a few minor tweaks to code above to improve:
* left and bottom shadow borders were way too big
* Alarm LED
* Minute hand too long was leaving remnants around inner region of the seconds marks
* Extended the second hand to more practical length for readability