1hr Stopwatch / Timer with 'retro' GUI
G'Day Guys
With the new war we have had a hugh jump in Aerospace/Defence business in Aus. being hassled by hackers and have not had any time to spend time with my autistic son.
He is trying to build a stopwatch / timer as we only allow him to be online for 1hr at a time, his mech. analogue timer has broken, apparently fell off the back of a bus :)
I'm looking for a really 'retro' GUI with a nice big chunky hour hand. Funny how the teenager of today are pining for the Ye Olde Dazs !!!
Anyone got an old VB6 project I could hack ?
TIA
Re: 1hr Stopwatch / Timer with 'retro' GUI
Re: 1hr Stopwatch / Timer with 'retro' GUI
G'Day PS
Thanks for the really prompt reply :)
Quote:
Originally Posted by
Peter Swinkels
Something like this?
No
Did you notice I said
Quote:
Originally Posted by
jg.sa
I'm looking for a really 'retro' GUI with a nice big chunky hour hand
So not digital, I know I have seen 1 on here but cannot find it with the search
Re: 1hr Stopwatch / Timer with 'retro' GUI
Re: 1hr Stopwatch / Timer with 'retro' GUI
G'Day JPbro
Good to hear from you :)
Quote:
Originally Posted by
jpbro
No to be honest I have never seen this before, but great start.
T H A N K S
2 Attachment(s)
Re: 1hr Stopwatch / Timer with 'retro' GUI
I put together a small example from scratch. May be simpler to build on, I don't know.
Not much code in the example. It just uses a scrollbar to change the timer value and the image updates to match.
I originally tried using transparentblt, but I guess because the files were jpg, I couldn't get a solid color background. I tried Magenta and I tried Red, but in both cases, saving the jpg file mangled a bunch of the colors around the dial, quite a ways from the edge of the dial for some reason.
So, I changed to putting the dial on a white background and a black background and then using two bitblts with Raster Ops to implement the transparency.
Here's what the code looks like, and I'll try to attach a shot of the form.
Code:
Option Explicit
Const PI2 As Double = 6.28318530717959
Private Type XFORM
eM11 As Single
eM12 As Single
eM21 As Single
eM22 As Single
eDx As Single
eDy As Single
End Type
Private Const GM_ADVANCED = 2
Private Declare Function SetGraphicsMode Lib "gdi32" (ByVal hdc As Long, ByVal iMode As Long) As Long
Private Declare Function SetWorldTransform Lib "gdi32" (ByVal hdc As Long, lpXform As XFORM) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Dim Ang As Single
Private Sub HScroll1_Change()
processScroll
End Sub
Private Sub HScroll1_Scroll()
processScroll
End Sub
Private Sub processScroll()
Ang = PI2 - (PI2 * HScroll1.Value / HScroll1.Max)
Label1.Caption = HScroll1.Value / 100: Label1.Refresh
UpdateImage
End Sub
Private Sub UpdateImage()
Dim CosAng As Single, SinAng As Single
Dim mtx As XFORM, nGraphicsMode As Long
With Picture1
.Cls
nGraphicsMode = SetGraphicsMode(.hdc, GM_ADVANCED)
CosAng = Cos(Ang) 'Need the cosine and sine of the angle
SinAng = Sin(Ang) 'to set up rotation matrix
mtx.eM11 = CosAng
mtx.eM12 = -SinAng
mtx.eM21 = SinAng
mtx.eM22 = CosAng
mtx.eDx = 310 'translate the rotation point
mtx.eDy = 287 'to the middle of our destination
SetWorldTransform .hdc, mtx
'Offset the bitblts negatively by center of dial middle of bitblt is at the rotation point
BitBlt .hdc, -215, -207, 431, 415, Picture2(0).hdc, 0, 0, vbSrcPaint
BitBlt .hdc, -215, -207, 431, 415, Picture2(1).hdc, 0, 0, vbSrcAnd
'Restore transform back to identity
'and restore graphics mode to previous value
mtx.eM11 = 1
mtx.eM12 = 0
mtx.eM21 = 0
mtx.eM22 = 1
mtx.eDx = 0
mtx.eDy = 0
SetWorldTransform .hdc, mtx
SetGraphicsMode .hdc, nGraphicsMode
.Refresh
End With
End Sub
p.s. The image was a straight on photo, I guess, but it was slightly rotated so the 0 line and the 30 line are not quite vertically aligned, likewise the 15 and 45 are not exactly horizontally aligned. Also the dial is not a perfect circle, but slightly oval. I probably trimmed the dial too closely and you can see the background image tic marks peeking out when you're rotated around 15 and 45 minutes.
But this is just an example of an approach, and you can use your own and better proportioned images for your application.
1 Attachment(s)
Re: 1hr Stopwatch / Timer with 'retro' GUI
I liked your project passel, and I made a modification to be able to move the value from the grip in the image.
Re: 1hr Stopwatch / Timer with 'retro' GUI
Glad you liked it.
I was tempted to do that instead of the slider, and perhaps add the timer logic and maybe sound, but decided to keep it simple and leave those fun things for others.
Then there was the fact that I've been shoveling snow all day, and only started on this after midnight and with the daylight savings time change lost another hour of sleep due to that, so keeping it simple was the order of the day.
Re: 1hr Stopwatch / Timer with 'retro' GUI
G'Day Passel and Eduardo
Thank you so much for all of your efforts, this is so much more than I ever anticipated.
Passel - This image is exactly what has been broken !!!
You are a mind reader, don't worry about the coding, I can work with all of that with my Son :)
What kind of noises were you thinking of having, like a smashing plate once the hour is up ?
Eduardo - Really like you idea thanks, I was orig. thinking of making it Neuromorphic, got the idea from u with On/Off etc. but my Son wants more analogue :)
I'm going to add
- Sending of an email once the hour is up and once it is set to zero "Reset"
- Allow for 'Always on Top'
- Remove the form and just have the image, but allow for drag and drop
Quote:
Originally Posted by
passel
Glad you liked it.
He is not the only 1
Quote:
Originally Posted by
passel
Then there was the fact that I've been shoveling snow all day
Its a holiday here today, so need to get some work done in the garden.
Here is a photo of the growing 'pods', the fig tree and Feijoa ( Pineapple Guava ) so no snow to shovel Passel !!!
http://ozedge.net/Pods-Fig-Feijoa.png
Re: 1hr Stopwatch / Timer with 'retro' GUI
Forgot to mention
- going to put it in the tray with a revolving pwd to change the settings based on Hostname
- Track changes to the Taskbar jump list to give a summary rpt of which files we accessed during the 1hr session in the 'finished session' email
Re: 1hr Stopwatch / Timer with 'retro' GUI
The people in this forum are awesome.
Re: 1hr Stopwatch / Timer with 'retro' GUI
@jg.sa:
Sorry, I overlooked the retro part in your question. I once wrote an analogue clock program in vb6. I could link to it if you're interested.