-
Oct 9th, 2020, 07:15 AM
#1
Thread Starter
Junior Member
[RESOLVED] Blinking numbers on the clock-face....
Hi again.... !
I have now made my adjustments to the analog clock that I was able to download from 'RinoBull's collection.
I can be back about what the adaptations are if there is some interest.
They include anyway a calendar next to the watch (See attached image), but which works completely independently of the clock's own drivers and is based solely on "Date" in the program code !
Since the watch in its original version lacks numbers, I have placed such around the clock-face by labels directly on the surface, ie picturebox "picClock".
It looks good and seems to work fine, but there is one thing that bothers and irritates, namely that on one of my computers - with Windows 7 - several, sometimes all, numbers blinks as the second hand moves forward.
On another smaller laptop (With windows 10!) Single and alternating numbers blinks !
On the original computer , with Windows 10, where I produced the program, the numbers don't flash at all !
I don't know if the different versions of Windows have any real and virtuall significance, and the screens have identical size as well as resolution and frequencies !
Is there any other and better way to place the numbers in the right places around the clock-face without too much intervention ?
I've thought of putting a Frame over the watch and making it transparent so that the numbers with labels do not end up directly on the picturebox, but I haven't tested this yet
I attach the underlying program code for Form1 (where my own code naturally is in swedish !), which includes the watch itself and I'll for the time being excludes other program code on other forms, which can be sent in case of any demand and interest.
With kind regards
Kalle in Sweden
[QUOTE][
Option Explicit
Dim Dag As String, Ar As String
Dim MS As String 'ParSiffra månadsslut
Dim fso As New FileSystemObject
Private Const PI = 3.14159265
Private Sub DrawClock()
'========================
Static last_time As Date
Dim cx As Single
Dim cy As Single
Dim num As Single
Dim radius As Single
Dim theta As Single
If last_time = Now Then Exit Sub
last_time = Now
picClock.Cls
cx = picClock.ScaleWidth / 2
cy = picClock.ScaleHeight / 2
' Hours.
num = 5 * (DatePart("h", last_time) + DatePart("n", last_time) / 60 + DatePart("s", last_time) / 3600)
theta = MinutesToRadians(num)
radius = picClock.ScaleWidth * 0.2
picClock.DrawWidth = 3
picClock.Line (cx, cy)-Step(radius * Cos(theta), -radius * Sin(theta))
' Minutes.
num = DatePart("n", last_time)
theta = MinutesToRadians(num)
radius = picClock.ScaleWidth * 0.3
picClock.DrawWidth = 2
picClock.Line (cx, cy)-Step(radius * Cos(theta), -radius * Sin(theta))
' Seconds.
num = DatePart("s", last_time)
theta = MinutesToRadians(num)
radius = picClock.ScaleWidth * 0.4
picClock.DrawWidth = 1
picClock.Line (cx, cy)-Step(radius * Cos(theta), -radius * Sin(theta))
End Sub
Private Sub DrawFace()
Dim r1 As Single
Dim r2 As Single
Dim r3 As Single
Dim cx As Single
Dim cy As Single
Dim i As Integer
Dim theta As Single
picClock.AutoRedraw = True
cx = picClock.ScaleWidth / 2
cy = picClock.ScaleHeight / 2
r1 = picClock.ScaleWidth * 0.45
r2 = picClock.ScaleWidth * 0.4
r3 = picClock.ScaleWidth * 0.35
For i = 1 To 60
theta = MinutesToRadians(i)
If i Mod 5 = 0 Then
picClock.Line (cx + r1 * Cos(theta), cy + r1 * Sin(theta))-(cx + r3 * Cos(theta), cy + r3 * Sin(theta))
Else
picClock.Line (cx + r1 * Cos(theta), cy + r1 * Sin(theta))-(cx + r2 * Cos(theta), cy + r2 * Sin(theta))
End If
Next i
picClock.Picture = picClock.Image
End Sub
Private Function MinutesToRadians(ByVal num As Single) As Single
MinutesToRadians = (15 - num) * 2 * PI / 60
End Function
Private Sub Command1_Click()
Form1.Enabled = False
Form2.Visible = True
Command3.Enabled = False
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.ToolTipText = "Lägg in minnesnotering på datum !"
End Sub
Private Sub Command2_Click()
Form1.Left = Screen.Width - Form1.Width
Form1.Top = 0
Ar = Left(Date, 4)
Dag = Weekday(Date, 1)
Mon = Mid(Date, 6, 2) 'Som parsiffra
Update_Calender
End Sub
Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command2.ToolTipText = "Uppdatera Pos. & Tid"
End Sub
Private Sub Command3_Click()
Close
End
End Sub
Private Sub Command3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command3.ToolTipText = "Avsluta och stäng ClockCalender !"
End Sub
Private Sub Form_Load()
Form1.Left = Screen.Width - Form1.Width
Form1.Top = 0
tmrClock.Interval = 1
DrawFace
tmrClock.Interval = 1000
Ar = Left(Date, 4)
Dag = Weekday(Date, 1)
Mon = Mid(Date, 6, 2) 'Som parsiffra
Update_Calender
Form1.Show
Open "\\PC2014\Center\BirthDayfil" For Random As #1 Len = 40 'Startar upp Birthfilen från Center
'Open "Birthdayfil" For Random As #1 Len = 40 'Startar upp BirthDay-filen från programkatalogen
Open "\\PC2014\Center\Memofil" For Random As #2 Len = 50 'Startar upp Memofilen från Center
'Open "Memofil" For Random As #2 Len = 50 'Startar upp Memo-filen från programkatalogen
NuPost = 0 'Nollställer ev. funnet postnummer i filernan "MemoFil" och BirthDay-fil
If LOF(1) / 40 >= 1 Then
BirthDaySeek 'Söker daterade poster i "BirthDayFil"
End If
If LOF(2) / 50 >= 1 Then
MemoSeek 'Söker daterade poster i filen "MemoFil"
End If
End Sub
Private Sub picClock_Paint()
DrawClock
End Sub
Private Sub tmrClock_Timer()
DrawClock
End Sub
Public Sub Update_Calender()
Select Case Dag
Case "1"
Label5.Caption = "Söndag"
Case "2"
Label5.Caption = "Måndag"
Case "3"
Label5.Caption = "Tisdag"
Case "4"
Label5.Caption = "Onsdag"
Case "5"
Label5.Caption = "Torsdag"
Case "6"
Label5.Caption = "Fredag"
Case "7"
Label5.Caption = "Lördag"
End Select
Label6.Caption = CStr(CInt(Right(Date, 2))) 'Dag
Label8.Caption = Ar
Select Case Mon
Case "01"
Label7.Caption = "Jan"
MS = "31"
Case "02"
Label7.Caption = "Feb"
Select Case Ar
Case "2024" Or "2028" Or "2032" _
Or "2034" Or "2038" Or "2042"
MS = "29"
Case Else
MS = "28"
End Select
Case "03"
Label7.Caption = "Mar"
MS = "31"
Case "04"
Label7.Caption = "Apr"
MS = "30"
Case "05"
Label7.Caption = "Maj"
MS = "31"
Case "06"
Label7.Caption = "Jun"
MS = "30"
Case "07"
Label7.Caption = "Jul"
MS = "31"
Case "08"
Label7.Caption = "Aug"
MS = "31"
Case "09"
Label7.Caption = "Sep"
MS = "30"
Case "10"
Label7.Caption = "Okt"
MS = "31"
Case "11"
Label7.Caption = "Nov"
MS = "30"
Case "12"
Label7.Caption = "Dec"
MS = "31"
End Select
End Sub
/QUOTE]
-
Oct 9th, 2020, 07:25 AM
#2
Re: Blinking numbers on the clock-face....
I've not created a project for this, so no comments on the flickering.
But all the date stuff can be replaced by VB6 methods and functions, instead of using hard coded names.
Code:
Dim d As Date
d = Date
Debug.Print WeekdayName(Weekday(Date, vbUseSystemDayOfWeek), True)
Debug.Print WeekdayName(Weekday(Date, vbUseSystemDayOfWeek), False)
Debug.Print MonthName(Month(d), True)
Debug.Print MonthName(Month(d), False)
-
Oct 9th, 2020, 11:51 PM
#3
Re: Blinking numbers on the clock-face....
Did you get the 4 projects for analog clocks that I sent you ?
Do any of them suffer the same problem ?
Rob
PS Do you know how to attach a project to this thread (instead of pasting reams of code) ?
-
Oct 10th, 2020, 04:11 AM
#4
Re: Blinking numbers on the clock-face....
the flashing may be to do with the speed of the different computers
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 10th, 2020, 07:23 AM
#5
Thread Starter
Junior Member
Re: [RESOLVED] Blinking numbers on the clock-face....
Bobbles !
Yes, I have received your 4 projects and studied them!
However, my problem was not at that level.
I simply did not realize that the frame that "picClock" constitutes is exactly what the name suggests, ie an image page where to insert an image, ie a clock_face.
Instead, I put in 12 labels for the hourly numbers, which at each second pulse were turned on and off ....
But now I've downloaded a clock image from the internet and brought it in where it should be located. With a few adjustments, it all works perfectly now!
When I was going to post my program code on VB forums, I looked for "Code" which was previously used for this purpose, but I did not find one.
I used "Quote" incorrectly instead, which was not so successful!
I agree that it was unnecessary to send my message with all this program code !
Westconn1!
Blinking was due to incorrect use of labels instead of a clock image, which I now have posted!
Frequency and image resolution etc. were the same for all tested computers!
I think the problem is solved with this!
/Kalle
-
Oct 10th, 2020, 09:26 PM
#6
Re: [RESOLVED] Blinking numbers on the clock-face....
use the # button for code
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|