home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- AutoRedraw = -1 'True
- BorderStyle = 0 'None
- Caption = "Form1"
- ClientHeight = 1605
- ClientLeft = 5250
- ClientTop = 3750
- ClientWidth = 1605
- LinkTopic = "Form1"
- ScaleHeight = 1605
- ScaleMode = 0 'User
- ScaleWidth = 1605
- ShowInTaskbar = 0 'False
- Begin VB.Timer Timer1
- Interval = 1
- Left = 600
- Top = 480
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim second As Long, minute As Long, hour As Long
- Dim second_Prv As Long, minute_Prv As Long, hour_Prv As Long
- Dim Pos_x(1 To 60) As Double
- Dim Pos_y(1 To 60) As Double
- Dim Minute_to_x As Double, Minute_to_y As Double
- Dim Hour_to_x As Double, Hour_to_y As Double
- Dim swp As Long, shp As Long
- Dim fwp As Long, fhp As Long
- Dim i As Long, j As Long, pi As Double, c As Long
- Private Sub Form_DblClick()
- Me.Visible = False
- Unload Me
- End Sub
- Private Sub Form_Load()
- 'Storing Pi
- pi = 3.1415629
- 'Scr Width and height by pixels
- swp = Screen.Width / Screen.TwipsPerPixelX
- shp = Screen.Height / Screen.TwipsPerPixelY
- 'Form Width and height by pixels. Of course
- 'we are not setting them here, but storing
- fwp = 105
- fhp = 105
- 'Here, we are creating an elliptic region,
- c = CreateEllipticRgn(0, 0, 103, 102)
- 'As you see, the function returnes an id for the region,
- 'And we are seting the region as our form
- SetWindowRgn Form1.hWnd, c, True
- With Form1
- .BackColor = vbBlack
- .Picture = LoadPicture(VB.App.Path + "\clock.bmp")
- .Move Screen.Width - (fwp + 10) * Screen.TwipsPerPixelX, _
- 10 * Screen.TwipsPerPixelY, _
- fwp * Screen.TwipsPerPixelX, _
- fhp * Screen.TwipsPerPixelY
- End With
- 'Storing these calculatings into an array matrix,
- 'And calling them from there,
- 'is faster around 20 times than calculating.
- 'This, is a mathamatical process, But I think you can
- 'understand what's going on here.
- For i = 1 To 60
- Pos_x(i) = 35 * Cos(-(pi / 2) + (i * (pi / 30)))
- Pos_y(i) = 35 * Sin(-(pi / 2) + (i * (pi / 30)))
- Next i
- 'Set scalemode to pixels.
- Form1.ScaleMode = vbPixels
- End Sub
- Private Sub Timer1_Timer()
- 'Take the time of computer
- second = Val(Right(Time$, 2))
- second_Prv = second - 1
- minute = Val(Mid(Time$, 4, 2))
- minute_Prv = minute - 1
- 'The clock is analogue. So:
- hour = Val(Left(Time$, 2)) Mod 12
- hour_Prv = hour - 1
- 'Reset:
- If hour = 0 Then hour = 12: hour_Prv = 11
- If minute = 0 Then minute = 60: minute_Prv = 59
- If second = 0 Then second = 60: second_Prv = 59
- If hour = 1 Then hour_Prv = 0
- If minute = 1 Then minute_Prv = 60
- If second = 1 Then second_Prv = 60
- 'We need to do the clearing together, and first.
- 'Or something we drawed might be cleared
- 'Clear
- Form1.Line (51, 50)-(51 + Pos_x(second_Prv), 50 + Pos_y(second_Prv)), vbWhite
- Minute_to_x = 51 + 0.9 * Pos_x(minute_Prv)
- Minute_to_y = 50 + 0.9 * Pos_y(minute_Prv)
- draw_minute False
- If second = 60 Then
- 'This means a first moment of a minute
- 'Clearing
- If minute < 12 Or minute = 60 Then
- Hour_to_x = 51 + 0.7 * Pos_x(hour_Prv * 5 + Int(59 / 12))
- Hour_to_y = 50 + 0.7 * Pos_y(hour_Prv * 5 + Int(59 / 12))
- Else
- If minute = 12 Then
- Hour_to_x = 51 + 0.7 * Pos_x(hour * 5 + Int(minute_Prv / 12))
- Hour_to_y = 50 + 0.7 * Pos_y(hour * 5 + Int(minute_Prv / 12))
- Else
- If hour = 12 Then hour = 0
- Hour_to_x = 51 + 0.7 * Pos_x(hour * 5 + Int(minute_Prv / 12))
- Hour_to_y = 50 + 0.7 * Pos_y(hour * 5 + Int(minute_Prv / 12))
- If hour = 0 Then hour = 12
- End If
- End If
- draw_hour False
- End If
- 'Drawing:
- Draw_Second
- Minute_to_x = 51 + 0.9 * Pos_x(minute)
- Minute_to_y = 50 + 0.9 * Pos_y(minute)
- draw_minute True
- If hour = 12 Then hour = 0
- If minute = 60 Then minute = 0
- If hour = 0 And minute < 12 Then hour = 12
- If hour = 0 And minute = 0 Then hour = 12
- Hour_to_x = 51 + 0.7 * Pos_x(hour * 5 + Int(minute / 12))
- Hour_to_y = 50 + 0.7 * Pos_y(hour * 5 + Int(minute / 12))
- draw_hour True
- End Sub
- Sub Draw_Second()
- Form1.Line (51, 50)-(51 + Pos_x(second), 50 + Pos_y(second)), RGB(128, 128, 128)
- End Sub
- Sub draw_minute(Draw_Or_Clear As Boolean)
- 'I think, easy to understand
- Dim Draw_Color As ColorConstants
- If Draw_Or_Clear = True Then
- Draw_Color = RGB(128, 128, 128)
- Else
- Draw_Color = vbWhite
- End If
- For i = 50 To 52
- For j = 49 To 51
- Form1.Line (i, j)-(Minute_to_x, Minute_to_y), Draw_Color
- Next j
- Next i
- End Sub
- Sub draw_hour(Draw_Or_Clear As Boolean)
- 'I think, easy to understand
- Dim Draw_Color As ColorConstants
- If Draw_Or_Clear = True Then
- Draw_Color = RGB(128, 128, 128)
- Else
- Draw_Color = vbWhite
- End If
- For i = 49 To 53
- For j = 48 To 52
- Form1.Line (i, j)-(Hour_to_x, Hour_to_y), Draw_Color
- Next j
- Next i
- End Sub
-