Option Explicit
'定义时钟显示方式
Public Enum style
enumNumberic = 1
enumPicturic = 2
End Enum
Private bstyle As style
Private lwidth As Long, lheight As Long
Private lCenterX As Long, lcentery As Long
Private bRedrawClockFrame As Boolean
Private Const cwidth = 1000
Private Const cheight = 1000
Public Event TimeChanged(ByVal lhour As Long, ByVal lminute As Long, ByVal lsec As Long)
Public Event StyleChanged(ByVal Newstyle As style)Private Sub Timer1_Timer()
Dim i As Integer
RaiseEvent TimeChanged(Hour(Time), Minute(Time), Second(Time))
If bstyle = enumNumberic Then
Cls
CurrentX = lCenterX - lwidth / 2
CurrentY = lcentery - lheight / 2
Print Trim(Format(Time, "hh:mm:ss"))
Else
If bRedrawClockFrame Then
bRedrawClockFrame = False
AutoRedraw = True
Cls
Circle (lCenterX, lcentery), 30 * 15, RGB(0, 0, 155)
'绘出钟盘分时点
For i = 1 To 11
If i Mod 3 <> 0 Then
DrawWidth = 1
Line (lCenterX - 375 * Sin(-i * 30 / 180 * 3.14), lcentery - 375 * Cos(-i * 30 / 180 * 3.14))-(lCenterX - 450 * Sin(-i * 30 / 180 * 3.14), lcentery - 450 * Cos(-i * 30 / 180 * 3.14)), RGB(0, 0, 255)
Else
DrawWidth = 2
Line (lCenterX - 325 * Sin(-i * 30 / 180 * 3.14), lcentery - 325 * Cos(-i * 30 / 180 * 3.14))-(lCenterX - 450 * Sin(-i * 30 / 180 * 3.14), lcentery - 450 * Cos(-i * 30 / 180 * 3.14)), RGB(0, 0, 255)
End If
Next i
Cls
DrawWidth = 3
Line (lCenterX, lcentery)-(lCenterX - 250 * Sin(-Hour(Time) * 30 / 180 * 3.14), lcentery - 200 * Cos(-Hour(Time) * 30 / 180 * 3.14)), RGB(0, 0, 255)
DrawWidth = 2
Line (lCenterX, lcentery)-(lCenterX - 250 * Sin(-Minute(Time) * 6 / 180 * 3.14), lcentery - 250 * Cos(-Minute(Time) * 6 / 180 * 3.14)), RGB(0, 255, 0)
DrawWidth = 1
Line (lCenterX, lcentery)-(lCenterX - 300 * Sin(-Second(Time) * 6 / 180 * 3.14), lcentery - 300 * Cos(-Second(Time) * 6 / 180 * 3.14)), RGB(255, 0, 0)
End If
End If
End SubPrivate Sub UserDocument_Initialize()
lwidth = TextWidth("00:00:00")
lheight = TextHeight("00:00:00")
style = enumPicturic
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Property Get style() As style
style = bstyle
End Property
Property Let style(x As style)
Dim i As Integer
If bstyle <> x Then
RaiseEvent StyleChanged(x)
bstyle = x
If x = enumPicturic Then
bRedrawClockFrame = True
Else
AutoRedraw = True
Cls
AutoRedraw = False
End If
Call Timer1.Timer
End If
End Property
生成控件的时候总是说
Call Timer1.Timer
未找到方法或数据成员
'定义时钟显示方式
Public Enum style
enumNumberic = 1
enumPicturic = 2
End Enum
Private bstyle As style
Private lwidth As Long, lheight As Long
Private lCenterX As Long, lcentery As Long
Private bRedrawClockFrame As Boolean
Private Const cwidth = 1000
Private Const cheight = 1000
Public Event TimeChanged(ByVal lhour As Long, ByVal lminute As Long, ByVal lsec As Long)
Public Event StyleChanged(ByVal Newstyle As style)Private Sub Timer1_Timer()
Dim i As Integer
RaiseEvent TimeChanged(Hour(Time), Minute(Time), Second(Time))
If bstyle = enumNumberic Then
Cls
CurrentX = lCenterX - lwidth / 2
CurrentY = lcentery - lheight / 2
Print Trim(Format(Time, "hh:mm:ss"))
Else
If bRedrawClockFrame Then
bRedrawClockFrame = False
AutoRedraw = True
Cls
Circle (lCenterX, lcentery), 30 * 15, RGB(0, 0, 155)
'绘出钟盘分时点
For i = 1 To 11
If i Mod 3 <> 0 Then
DrawWidth = 1
Line (lCenterX - 375 * Sin(-i * 30 / 180 * 3.14), lcentery - 375 * Cos(-i * 30 / 180 * 3.14))-(lCenterX - 450 * Sin(-i * 30 / 180 * 3.14), lcentery - 450 * Cos(-i * 30 / 180 * 3.14)), RGB(0, 0, 255)
Else
DrawWidth = 2
Line (lCenterX - 325 * Sin(-i * 30 / 180 * 3.14), lcentery - 325 * Cos(-i * 30 / 180 * 3.14))-(lCenterX - 450 * Sin(-i * 30 / 180 * 3.14), lcentery - 450 * Cos(-i * 30 / 180 * 3.14)), RGB(0, 0, 255)
End If
Next i
Cls
DrawWidth = 3
Line (lCenterX, lcentery)-(lCenterX - 250 * Sin(-Hour(Time) * 30 / 180 * 3.14), lcentery - 200 * Cos(-Hour(Time) * 30 / 180 * 3.14)), RGB(0, 0, 255)
DrawWidth = 2
Line (lCenterX, lcentery)-(lCenterX - 250 * Sin(-Minute(Time) * 6 / 180 * 3.14), lcentery - 250 * Cos(-Minute(Time) * 6 / 180 * 3.14)), RGB(0, 255, 0)
DrawWidth = 1
Line (lCenterX, lcentery)-(lCenterX - 300 * Sin(-Second(Time) * 6 / 180 * 3.14), lcentery - 300 * Cos(-Second(Time) * 6 / 180 * 3.14)), RGB(255, 0, 0)
End If
End If
End SubPrivate Sub UserDocument_Initialize()
lwidth = TextWidth("00:00:00")
lheight = TextHeight("00:00:00")
style = enumPicturic
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Property Get style() As style
style = bstyle
End Property
Property Let style(x As style)
Dim i As Integer
If bstyle <> x Then
RaiseEvent StyleChanged(x)
bstyle = x
If x = enumPicturic Then
bRedrawClockFrame = True
Else
AutoRedraw = True
Cls
AutoRedraw = False
End If
Call Timer1.Timer
End If
End Property
生成控件的时候总是说
Call Timer1.Timer
未找到方法或数据成员
改成
Timer1_Timer