Uhr mit Systemzeit II

Uhr mit Systemzeit: Static ... As Date, MinutesToRadians, PictureBox
Private Const PI = 3.14159265
Private Sub DrawClock() Zeiger zeichnen
Static last_time As Date
Dim cx As Single, cy As Single, num As Single
Dim radius As Single, theta As Single
If last_time = Now Then Exit Sub
last_time = Now
picClock.Cls
cx = picClock.ScaleWidth / 2 Zeiger Horizontalachse.
cy = picClock.ScaleHeight / 2 Zeiger Vertikalachse.
num = 5 * (DatePart("h", last_time) + DatePart("n", last_time) / 60 + DatePart("s", last_time) / 3600) Stunden.
theta = MinutesToRadians(num)
radius = picClock.ScaleWidth * 0.25 Länge Stundenzeiger.
picClock.DrawWidth = 3
picClock.Line (cx, cy)-Step(radius * Cos(theta), -radius * Sin(theta))
num = DatePart("n", last_time) Minuten.
theta = MinutesToRadians(num)
radius = picClock.ScaleWidth * 0.35 Länge Minutenzeiger.
picClock.DrawWidth = 2
picClock.Line (cx, cy)-Step(radius * Cos(theta), -radius * Sin(theta))
num = DatePart("s", last_time) Sekunden.
theta = MinutesToRadians(num)
radius = picClock.ScaleWidth * 0.4 Länge Sekundenzeiger.
picClock.DrawWidth = 1
picClock.Line (cx, cy)-Step(radius * Cos(theta), -radius * Sin(theta))
End Sub
Private Sub DrawFace() Minutenkreis zeichnen.
Dim r1 As Single, r2 As Single, r3 As Single
Dim cx As Single, cy As Single, i As Integer
Dim theta As Single
picClock.AutoRedraw = True
cx = picClock.ScaleWidth / 2 Minutenkreis Horizantalachse.
cy = picClock.ScaleHeight / 2 Minutenkreis Vertikalachse.
r1 = picClock.ScaleWidth * 0.45 Minutenkreis (alle Steps).
r2 = picClock.ScaleWidth * 0.4 Minutenkreis (Steps 1 bis 4).
r3 = picClock.ScaleWidth * 0.35 Minutenkreis (5-er Step).
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 Uhrzeit berechnen
End Function
Private Sub Form_Load()
DrawFace
End Sub
Private Sub picClock_Paint()
DrawClock
End Sub
Private Sub tmrClock_Timer()
DrawClock
End Sub

Mehr Tipps: Grafikausgabe auf Formular

Sponsoren und Investoren

Sponsoren und Investoren sind jederzeit herzlich willkommen!
Wenn Sie die Information(en) auf dieser Seite interessant fanden, freuen wir uns über eine kleine Spende. Empfehlen Sie uns bitte auch in Ihren Netzwerken (z. B. Twitter, Facebook oder Google+). Herzlichen Dank!

Nach oben Sitemap
Impressum & Kontakt