http://www.networkmaestro.com/vistaclock128.zip
and here's two example programs. The first one shows how to drop the gadget on a form, the second is a full working desktop clock:
Code: Select all
; Add a clock gadget to your gui
OpenWindow(0,0,0,320,240,"VistaClock",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ImageGadget(0,80,40,144,144,0)
OpenLibrary(0,"VistaClock128.dll")
CallFunction(0,"InitClock", RGB(224,223,227), 0) ; pass it your window color and 0 = no floating.
Repeat
EventID=WaitWindowEvent(1)
ret = CallFunction(0,"UpdateClock")
If ret
SetGadgetState(0,ret)
EndIf
Until EventID=#PB_Event_CloseWindow
Code: Select all
; Make a floating desktop clock
OpenWindow(0,0,0,144,144,"VistaClock",#PB_Window_BorderLess|#PB_Window_ScreenCentered|#PB_Window_Invisible)
SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(0),0,0,1)
CreatePopupMenu(0)
MenuItem(0, "Close the VistaClock")
MenuItem(1, "Sticky")
SetMenuItemState(0,1,1)
Import "vistaclock128.lib"
InitClock(color.l,floating.l)
UpdateClock()
EndImport
InitClock(0,1) ;floating = true will look best for this job
HideWindow(0,0)
StickyWindow(0,1)
Repeat
EventID=WaitWindowEvent(1)
Select EventID
Case #WM_LBUTTONDOWN
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Case #WM_RBUTTONDOWN
DisplayPopupMenu(0,WindowID(0))
Case #PB_Event_Menu
Select EventMenu()
Case 0
End
Case 1
If GetMenuItemState(0,1)
SetMenuItemState(0,1,0)
StickyWindow(0,0)
Else
SetMenuItemState(0,1,1)
StickyWindow(0,1)
EndIf
EndSelect
EndSelect
ret = UpdateClock()
If ret
StartDrawing(WindowOutput(0))
DrawImage(ret,0,0)
StopDrawing()
EndIf
Until EventID=#PB_Event_CloseWindow
Note: Resizing is done and works well, I just haven't included it in this release. If any bugs show up here, they'll be fixed and released with the resizable version.
Oh yes, I forgot, the InitClock() function will return 1 if all is ok, otherwise 0. So you can test it and go to plan B if the clock dll is gone for a sh**