VB 如何图片时钟
不是用黑白线条表现出来的。
三张图片,一张背景,一张时针图片,一张分针图片。用绘图的方式也行,把时针和分针绘到背景图。做出来再加500分。谢谢,要速度。
最佳答案:
这就给你(VistaClock.rar)。
其 他 回 答: (共3条)
1楼
http://www.codeproject.com/KB/datetime/Desktop_Alarm_Clock.aspx
http://www.codeproject.com/KB/datetime/Analog_Clock.aspx
2楼
'添加一个timer控件和一个shape控件,名字都用默认的名字,粘贴如下代码即可
Option Explicit
Private cx As Long
Private cy As Long
Private R As Long
Private Const Color1 As Long = &H404040
Private Const Color2 As Long = &H808080
Private Const PI As Double = 3.14159265358979
Private Sub DrawBackGround()
Me.ScaleMode = 3
Me.FillStyle = 0
Me.Height = 5800
Me.Width = 5800
cx = 150
cy = 150
R = 100
Me.FillColor = Color1
Me.Circle (cx, cy), R, Color1
Me.FillColor = Color2
Me.Circle (cx, cy), R - 7, Color2
Me.FillColor = Color1
Me.Circle (cx, cy), R - 15, Color1
Dim Cor(1 To 12, 1 To 2) As Long
Me.FontName = "Arial" '如果这个字体无效 换换黑体试试,字体需要自己到网上下载
Me.FontBold = True
Me.FillColor = Color2
Me.ForeColor = Color2
Me.FontSize = 14
Cor(1, 1) = cx + ((R - 15) * Cos(GetDegree(60)) - 10)
Cor(1, 2) = cy - ((R - 15) * Sin(GetDegree(60)) + 5)
Me.CurrentX = Cor(1, 1)
Me.CurrentY = Cor(1, 2)
Me.Print "1"
Me.FontSize = 18
Cor(2, 1) = cx + ((R - 15) * Cos(GetDegree(30)) - 15)
Cor(2, 2) = cy - ((R - 15) * Sin(GetDegree(30)) + 10)
Me.CurrentX = Cor(2, 1)
Me.CurrentY = Cor(2, 2)
Me.Print "2"
Me.FontSize = 22
Cor(3, 1) = cx + (R - 15) - Me.TextWidth("3")
Cor(3, 2) = cy - Me.TextHeight("3") / 2
Me.CurrentX = Cor(3, 1)
Me.CurrentY = Cor(3, 2)
Me.Print "3"
Me.FontSize = 24
Cor(4, 1) = cx + ((R - 15) * Cos(GetDegree(-30)) - 20)
Cor(4, 2) = cy - ((R - 15) * Sin(GetDegree(-30)) + 20)
Me.CurrentX = Cor(4, 1)
Me.CurrentY = Cor(4, 2)
Me.Print "4"
Me.FontSize = 26
Cor(5, 1) = cx + ((R - 15) * Cos(GetDegree(-60)) - 15)
Cor(5, 2) = cy - ((R - 15) * Sin(GetDegree(-60)) + 32)
Me.CurrentX = Cor(5, 1)
Me.CurrentY = Cor(5, 2)
Me.Print "5"
Me.FontSize = 28
Cor(6, 1) = cx - Me.TextWidth("6") / 2
Cor(6, 2) = cy + (R - 50)
Me.CurrentX = Cor(6, 1)
Me.CurrentY = Cor(6, 2)
Me.Print "6"
Me.FontSize = 26
Cor(7, 1) = cx + ((R - 15) * Cos(GetDegree(-120)))
Cor(7, 2) = cy - ((R - 15) * Sin(GetDegree(-120)) + 32)
Me.CurrentX = Cor(7, 1)
Me.CurrentY = Cor(7, 2)
Me.Print "7"
Me.FontSize = 24
Cor(8, 1) = cx + ((R - 15) * Cos(GetDegree(-150)))
Cor(8, 2) = cy - ((R - 15) * Sin(GetDegree(-150)) + 25)
Me.CurrentX = Cor(8, 1)
Me.CurrentY = Cor(8, 2)
Me.Print "8"
Me.FontSize = 22
Cor(9, 1) = cx - (R - 15)
Cor(9, 2) = cy - Me.TextHeight("9") / 2
Me.CurrentX = Cor(9, 1)
Me.CurrentY = Cor(9, 2)
Me.Print "9"
Me.FontSize = 18
Cor(10, 1) = cx + ((R - 15) * Cos(GetDegree(150)))
Cor(10, 2) = cy - ((R - 15) * Sin(GetDegree(150)) + 10)
Me.CurrentX = Cor(10, 1)
Me.CurrentY = Cor(10, 2)
Me.Print "10"
Me.FontSize = 14
Cor(11, 1) = cx + ((R - 15) * Cos(GetDegree(120)))
Cor(11, 2) = cy - ((R - 15) * Sin(GetDegree(120)) + 5)
Me.CurrentX = Cor(11, 1)
Me.CurrentY = Cor(11, 2)
Me.Print "11"
Me.FontSize = 10
Cor(12, 1) = cx - 5
Cor(12, 2) = cy - (R - 15)
Me.CurrentX = Cor(12, 1)
Me.CurrentY = Cor(12, 2)
Me.Print "12"
Me.FillColor = Color2
Dim i As Long
For i = 0 To 360 Step 30
Me.Circle ((R - 3) * Cos(GetDegree(i)) + cx, cy - (R - 3) * Sin(GetDegree(i))), 2
Next i
End Sub
Private Sub DrawTime(NowTime As Date)
Dim h As Long, m As Long, s As Long
h = Hour(NowTime)
m = Minute(NowTime)
s = Second(NowTime)
'Line (cx, cy)-((R - 30) * Sin(GetDegree(s / 60 * 360)) + cx, cy - (R - 30) * Cos(GetDegree(s / 60 * 360))), vbYellow
Shape1.Shape = 4
Shape1.BorderColor = vbYellow
Shape1.Width = 25
Shape1.Height = 15
Shape1.BorderWidth = 1
Shape1.Left = cx + 35
Shape1.Top = cy - 8
Me.CurrentX = Shape1.Left + 2
Me.CurrentY = Shape1.Top
Me.ForeColor = vbWhite
FillColor = vbYellow
FillStyle = vbSolid
If h >= 12 Then
Me.Print "PM"
Else
Me.Print "AM"
End If
Circle ((R - 20) * Sin(GetDegree(s / 60 * 360)) + cx, cy - (R - 20) * Cos(GetDegree(s / 60 * 360))), 80, vbYellow, -GetDegree((((60 - s) / 60 * 360) + 267) Mod 360), -GetDegree((((60 - s) / 60 * 360) + 273) Mod 360)
Circle ((R - 40) * Sin(GetDegree(m / 60 * 360)) + cx, cy - (R - 40) * Cos(GetDegree(m / 60 * 360))), 60, vbYellow, -GetDegree((((60 - m) / 60 * 360) + 267) Mod 360), -GetDegree((((60 - m) / 60 * 360) + 273) Mod 360)
Circle ((R - 60) * Sin(GetDegree(h / 60 * 360)) + cx, cy - (R - 60) * Cos(GetDegree(h / 60 * 360))), 40, vbYellow, -GetDegree((((60 - h) / 60 * 360) + 267) Mod 360), -GetDegree((((60 - h) / 60 * 360) + 273) Mod 360)
Circle (cx, cy), 5, vbYellow
End Sub
Private Function GetDegree(ByVal V As Long) As Double
GetDegree = V / 360 * 2 * PI
End Function
Private Sub Form_Load()
Timer1.Interval = 1000
Call Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Me.Cls
DrawBackGround
DrawTime Now
End Sub
查看更多相关问题 >>