Transparent Clock
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
it might be a GDI issue
do you have a small GDI snippet you want me to 'speed-test' on my machine ?
PS:
when i say maximum zoom - i say the zoom of the max value of the trackbar (not the radio buttons).

do you have a small GDI snippet you want me to 'speed-test' on my machine ?
PS:
when i say maximum zoom - i say the zoom of the max value of the trackbar (not the radio buttons).
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
i feel (almost) guilty as i think i was the one who triggered all your work by requesting a clock way back 
not that guilty though
anyway, got one request: could you give it an option to hide the seconds? the moving arm is somewhat distracting, especially with multiple clocks open
but darn, it's a beautifull thing you made!

not that guilty though

anyway, got one request: could you give it an option to hide the seconds? the moving arm is somewhat distracting, especially with multiple clocks open
but darn, it's a beautifull thing you made!
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
OK, option to remove secondhand is done (not yet for 2000 version). You will have to redo any saved settings using the new version, as it will not accept saved settings that don't include the secondhand status. So just Forget Settings on all your clocks before shutting them down and then Remember Settings on all the new ones.
Here's how it works:

One picture is worth many words.
Here's how it works:

One picture is worth many words.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
There is an update to this program. It covers three main bases:
1. The timing method for the 2000 version is better, it's now employed by TransparentClock.exe and so there is no more need for a 2000 version
2. There was a bug in the resize function where there could potentially be a crash under certain conditions, this is corrected.
3. The timing logic for the Jump and No Secondhand options is rewritten to only update the clock graphic once on the variable Date() getting a new second, which should effectively remove all CPU usage for people who are getting some. The Sweep option updates the graphic 17 times a second.
This clock is pretty much done, so please download the current version, which is going to be final unless a bug shows up. Thanks to all testers and enjoy the clock!
1. The timing method for the 2000 version is better, it's now employed by TransparentClock.exe and so there is no more need for a 2000 version
2. There was a bug in the resize function where there could potentially be a crash under certain conditions, this is corrected.
3. The timing logic for the Jump and No Secondhand options is rewritten to only update the clock graphic once on the variable Date() getting a new second, which should effectively remove all CPU usage for people who are getting some. The Sweep option updates the graphic 17 times a second.
This clock is pretty much done, so please download the current version, which is going to be final unless a bug shows up. Thanks to all testers and enjoy the clock!
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
hello,
1/
can you just add some menu-separators in the pop-menu to make it more readable ?
2/
Not possible to re-use them ?
1/
can you just add some menu-separators in the pop-menu to make it more readable ?
2/
Yes, like the your previous VistaClock, which included 2 backgrounds.What if we would like a background for the clock? Razz (not transparent)
Not possible to re-use them ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
- Michael Vogel
- Addict
- Posts: 2802
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Hi,
observing your project with interest - the actually version can not be seen on my (old) Win2000 notebook, earlier versions did...
Concerning the CPU usage, I can tell you only about the last working version (with the sweeping second hand):
I had about 25% CPU usage, but when using smaller factors of the picture (128x128) the CPU usage went down to about 5%. For me it seems to be that my old (built in) graphic "card" needs a lot of performance to do the transparent things...
I'm looking forward and wish you the best for your project - and wait for all peaces of code (or libs) you will publish.
Michael
PS I also searched for some old code when I started to write also a clock (but failed to make a good code for the hands) - relaunched it and... voilà, it also took around 20% of the CPU performance (and this without all your really nice hands).
observing your project with interest - the actually version can not be seen on my (old) Win2000 notebook, earlier versions did...
Concerning the CPU usage, I can tell you only about the last working version (with the sweeping second hand):
I had about 25% CPU usage, but when using smaller factors of the picture (128x128) the CPU usage went down to about 5%. For me it seems to be that my old (built in) graphic "card" needs a lot of performance to do the transparent things...
I'm looking forward and wish you the best for your project - and wait for all peaces of code (or libs) you will publish.
Michael
PS I also searched for some old code when I started to write also a clock (but failed to make a good code for the hands) - relaunched it and... voilà, it also took around 20% of the CPU performance (and this without all your really nice hands).
Code: Select all
; Define
UsePNGImageDecoder()
UseTIFFImageDecoder()
Global Alpha = 255
Global UhrX=260
Global UhrY=260
Global MidX=UhrX>>1
Global MidY=UhrY>>1
Global Stunde,Minute,Sekunde
Global Zeit,LetzteZeit
Global WinID,ImageDC
Enumeration
#Hintergrund
#Zeichenflaeche
#Stundenzeiger
#ImgBack
#ImgBorder
#ImgGloss
#ImgLongPointer
#ImgMediumPointer
#ImgSmallPointer
EndEnumeration
DataSection
Uhr:
IncludeBinary "fiat.png"
StundenZeiger:
IncludeBinary "z1.bmp"
EndDataSection
Global Dim SinQ(59)
Global Dim CosQ(59)
For i=0 To 59
SinQ(i)=Sin(i/30*#PI)*MidX
CosQ(i)=Cos(i/30*#PI)*MidY
Next i
; EndDefine
Procedure MyLineXY(x,y,x1,y1,Color,Width=3)
hDC=ImageDC;GetDC_(WindowID(0))
pen=CreatePen_(#PS_SOLID,Width,#Black)
hPenOld=SelectObject_(hDC,pen)
MoveToEx_(hDC,x-1,y,0):LineTo_(hDC,x1-1,y1)
MoveToEx_(hDC,x,y-1,0):LineTo_(hDC,x1,y1-1)
MoveToEx_(hDC,x+1,y,0):LineTo_(hDC,x1+1,y1)
MoveToEx_(hDC,x,y+1,0):LineTo_(hDC,x1,y1+1)
DeleteObject_(pen)
DeleteObject_(hPenOld)
pen=CreatePen_(#PS_SOLID,Width,Color)
hPenOld=SelectObject_(hDC,pen)
MoveToEx_(hDC,x,y,0):LineTo_(hDC,x1,y1)
DeleteObject_(pen)
DeleteObject_(hPenOld)
EndProcedure
Procedure UpdateClock()
Zeit=Date()
If Zeit<>LetzteZeit
LetzteZeit=Zeit
Stunde=Hour(Zeit)
Minute=Minute(Zeit)
Sekunde=Second(Zeit)
; Fresh copy of background to draw on
CreateImage(#Zeichenflaeche,UhrX,UhrY)
ImageDC=StartDrawing(ImageOutput(#Zeichenflaeche))
DrawAlphaImage(ImageID(#Hintergrund),0,0)
MyLineXY(MidX-SinQ(Stunde)>>5,MidY+CosQ(Stunde)>>5,MidX+(SinQ(Stunde)*1)>>1,MidY-(CosQ(Stunde)*1)>>1,#White,3)
MyLineXY(MidX-SinQ(Minute)>>5,MidY+CosQ(Minute)>>5,MidX+(SinQ(Minute)*6)>>3,MidY-(CosQ(Minute)*6)>>3,#White,5)
MyLineXY(MidX-SinQ(Sekunde)>>3,MidY+CosQ(Sekunde)>>3,MidX+(SinQ(Sekunde)*7)>>3,MidY-(CosQ(Sekunde)*7)>>3,#Black,1)
; Update the window
Static ContextOffset.POINT
Static BlendMode.BLENDFUNCTION
Static BitmapInfo.BITMAP
GetObject_(ImageID(#Zeichenflaeche),SizeOf(BITMAP),@BitmapInfo)
BlendMode\SourceConstantAlpha=Alpha
BlendMode\AlphaFormat=1
UpdateLayeredWindow_(WindowID(0),0,0,@BitmapInfo+4,ImageDC,@ContextOffset,0,@BlendMode,2)
FreeImage(#Zeichenflaeche)
StopDrawing()
EndIf
EndProcedure
#APPNAME = "Clock"
OpenWindow(1, 0, 0, 0, 0, #APPNAME + " Parent", #PB_Window_Invisible)
OpenWindow(0, 0, 0, 512, 384, #APPNAME, #PB_Window_Invisible, WindowID(1))
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED)
CatchImage(#Hintergrund,?Uhr)
CatchImage(#Stundenzeiger,?Stundenzeiger)
UpdateClock()
HideWindow(0,0)
SetParent_(WindowID(0),0)
StickyWindow(0,1)
quit=0
Repeat
UpdateClock()
Select WaitWindowEvent(250)
Case #WM_LBUTTONDOWN
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Case #WM_CHAR
quit=#True
EndSelect
Until quit
Just a little GDI clock from the french forum (Erix14)
Catch it here : http://www.rx14.info/public/index.php?a=HorlogeRX
This one is very nice, smooth, cpu reasonable.
I think it is a good idea to add the date on the clock. maybe you can add it to TransparentClock (?)
Catch it here : http://www.rx14.info/public/index.php?a=HorlogeRX
This one is very nice, smooth, cpu reasonable.
I think it is a good idea to add the date on the clock. maybe you can add it to TransparentClock (?)
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
- Michael Vogel
- Addict
- Posts: 2802
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Be patient, its on my notebook far, far away...jack wrote:@Michael Vogel, could you give a link to your images "fiat.png" and "z1.bmp" ?
Last edited by Michael Vogel on Wed Nov 08, 2006 1:04 pm, edited 2 times in total.