Follow the following steps to accomplish task:
Friend WithEvents Timer1 As System.Timers.Timer
Name = Clock
Width = 376
Height = 376
BackgroundImage = “image that you want to display in the background of your clock”
Enabled = True
Interval = 1000
SynchronizingObject = Me ‘here me represents the Form
Name = Form1
Text = Analog Clock
Public MinuteP As Bitmap = New Bitmap(Application.StartupPath + "\minute.bmp")
Public SecondP As Bitmap = New Bitmap(Application.StartupPath + "\second.bmp")
Public HourP As Bitmap = New Bitmap(Application.StartupPath + "\hour.bmp")
Public CenterP As Bitmap = New Bitmap(Application.StartupPath + "\center.bmp")
Public TMPIMG As Bitmap = New Bitmap(376, 376)
Public Graph As Graphics = Graphics.FromImage(TMPIMG)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1_Elapsed(Nothing, Nothing)
End Sub
Private Sub Timer1_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Graph.DrawImage(ClockI.BackgroundImage, 0, 0, 376, 376)
Graph.TranslateTransform(188, 188)
Graph.RotateTransform(-90 + ((Now.Hour * 30) + (Now.Minute * 0.5)))
Graph.DrawImage(HourP, -13, -13)
Graph.ResetTransform()
Graph.RotateTransform(-90 + (((Now.Minute * 60) + Now.Second) * 0.1))
Graph.DrawImage(MinuteP, -13, -13)
Graph.RotateTransform(-90 + (Now.Second * 6))
Graph.DrawImage(SecondP, -13, -13)
Graph.DrawImage(CenterP, -18, -18)
ClockI.Image = TMPIMG
Before going to execute the project be sure that you have the images in bin folder of your application. These images are used to display hour, minute and second needles. These images are just colorful lines in the bitmap format.
You can change then name of files but be sure that you have given the correct names in the declaration of bitmap images above in the code.
Here in this application the names are.
Center is used to combine all these at a single point in the clock center. Thats why they seem to be met each other.
Posted on 3/24/2008 8:55:56 PM by Joe Sweeney
Posted on 3/10/2009 5:58:00 AM by priya
Posted on 11/12/2009 3:54:39 PM by pirate
Posted on 1/29/2010 9:16:10 PM by Kabir Ali
Posted on 2/21/2010 8:29:52 PM by Syed Gilani
Posted on 4/29/2010 7:14:42 AM by Mayur Patil
Posted on 8/30/2010 8:45:19 PM by Ken Arce
Posted on 11/2/2010 2:31:15 PM by Arun