I have the code that producing manual clock but i have no idea how to locate it actually how to dock it to the right/left side of my form no matter is form maximized or not ... i will apreciate any help .... thanks in advance
Below is code i use for clock:
Const kordinataX = 600
Const kordinataY = 100
Const SecondHandLenght = 60
Const MinuteHandLenght = 50
Const HourHandLenght = 40
Dim l As Label
Dim Pen As New Drawing.Pen(System.Drawing.Color.Red, 2)
Dim Second, Minute, Hour As Integer
Dim x1, y1, x2, y2 As Integer
'
'here is the timer Sub
'
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Refresh() ' Clears Hands
Second = Microsoft.VisualBasic.DateAndTime.Second(Now)
Minute = Microsoft.VisualBasic.DateAndTime.Minute(Now)
Hour = Microsoft.VisualBasic.DateAndTime.Hour(Now)
' Draws Hour-Hand:
Pen = New Drawing.Pen(System.Drawing.Color.MediumSeaGreen, 4)
x1 = Sin(((Hour Mod 12) * 30 + Minute / 2) * PI / 180 + PI) * HourHandLenght / 5 + kordinataX 'Tail x
y1 = Cos(((Hour Mod 12) * 30 + Minute / 2) * PI / 180) * HourHandLenght / 5 + kordinataY 'Tail y
x2 = Sin(((Hour Mod 12) * 30 + Minute / 2) * PI / 180) * HourHandLenght + kordinataX 'Head x
y2 = Cos(((Hour Mod 12) * 30 + Minute / 2) * PI / 180 + PI) * HourHandLenght + kordinataY 'Head y
Me.CreateGraphics.DrawLine(Pen, x1, y1, x2, y2)
' Draws Minute-Hand:
Pen = New Drawing.Pen(System.Drawing.Color.MediumSeaGreen, 3)
x1 = Sin(Minute * PI / 30 + Second * PI / 1800 + PI) * MinuteHandLenght / 5 + kordinataX
y1 = Cos(Minute * PI / 30 + Second * PI / 1800) * MinuteHandLenght / 5 + kordinataY
x2 = Sin(Minute * PI / 30 + Second * PI / 1800) * MinuteHandLenght + kordinataX
y2 = Cos(Minute * PI / 30 + Second * PI / 1800 + PI) * MinuteHandLenght + kordinataY
Me.CreateGraphics.DrawLine(Pen, x1, y1, x2, y2)
' Draws Second-Hand:
Pen = New Drawing.Pen(System.Drawing.Color.DimGray, 2)
x1 = Sin(Second * PI / 30 + PI) * SecondHandLenght / 5 + kordinataX
y1 = Cos(Second * PI / 30) * SecondHandLenght / 5 + kordinataY
x2 = Sin(Second * PI / 30) * SecondHandLenght + kordinataX
y2 = Cos(Second * PI / 30 + PI) * SecondHandLenght + kordinataY
Me.CreateGraphics.DrawLine(Pen, x1, y1, x2, y2)
End Sub
Note: Do i need maybe check user's screen resolution so regard to resolution make the code eg. (i just improvise) if resolution is 1024 x 768 Then kordinataX = 900 'or this is bad idea ... :cry:
Question
Southern Man
Hello,
I have the code that producing manual clock but i have no idea how to locate it actually how to dock it to the right/left side of my form no matter is form maximized or not ... i will apreciate any help .... thanks in advance
Below is code i use for clock:
Note: Do i need maybe check user's screen resolution so regard to resolution make the code eg. (i just improvise) if resolution is 1024 x 768 Then kordinataX = 900 'or this is bad idea ... :cry:
Link to comment
Share on other sites
2 answers to this question
Recommended Posts