Posted: Sun May 07, 2006 4:41 am
A new version of the VistaClock dll is available. It is a total rewrite, approaching the task from an entirely different angle. Gone is the need for directx, gone are the drawing problems for 16-bit desktops, and gone jumpiness in "floating desktop clock" implementations. Performance is, if I may say, close to perfect. And, touch wood, it should run everywhere, even on old junkers, with just the tiniest sip from the CPU. It doesn't even register above 0 on my machine. However, all this comes at a price. The dll is 390 kb in size, upx'd to the max. Ouch. But that's what it costs. I can't put out this kind of look and performance together for less. Here it is:
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:
I should say a word here about the floating parameter for InitClock(). You pass windowcolor and either 1 for floating version or 0 for normal. The difference is that if you are displaying the clock on a window, 0=no floating will look best. If you're building a desktop clock that will float on its own, 1 will look best. It just controls whether a dark fringe gets drawn around the clock, which looks good against a window and crappy against light backgrounds like web surfing, etc.
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**
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**