home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{52DE3A21-0A3F-11D4-B9D2-008048FD54E6}#2.0#0"; "POLARDraw20.ocx"
- Begin VB.Form FormClock
- BorderStyle = 3 'Fixed Dialog
- Caption = "Clock"
- ClientHeight = 3240
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4845
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3240
- ScaleWidth = 4845
- ShowInTaskbar = 0 'False
- StartUpPosition = 3 'Windows Default
- Begin POLARDRAW20Lib.POLARDraw POLARDraw1
- Height = 3015
- Left = 120
- TabIndex = 3
- Top = 120
- Width = 3375
- _Version = 131072
- _ExtentX = 5953
- _ExtentY = 5318
- _StockProps = 224
- Appearance = 1
- PaperShadowColor= 0
- PaperOutlinecolor= 22899756
- EditMode = 6
- DrawPaper = 0 'False
- DrawPaperOutline= -1 'True
- DrawPaperShadow = -1 'True
- PaperShadowOffset= 0
- ViewportOriginX = 22899756
- ViewportOriginY = 22873116
- PageOriginX = 1
- PageOriginY = 97719525
- HorizontalGrid = 567
- VerticalGrid = 567
- ShowVerticalScrollBar= 0 'False
- ShowHorizontalScrollBar= 0 'False
- ShowVerticalRuler= 0 'False
- ShowHorizontalRuler= 0 'False
- SelectionCount = 22740992
- ShapeCount = 22742704
- MeasurementUnits= 8
- CanvasWidth = 536873485
- CanvasHeight = 0
- AllowSelect = 0 'False
- AllowRotate = 0 'False
- AllowDelete = 0 'False
- AllowResize = 0 'False
- AllowMove = 0 'False
- AllowEditPoints = 0 'False
- AllowDragSelect = 0 'False
- End
- Begin VB.Timer Timer
- Interval = 1000
- Left = 3720
- Top = 1320
- End
- Begin VB.CheckBox CheckTicking
- Caption = "Ticking"
- Height = 375
- Left = 3600
- TabIndex = 2
- Top = 2760
- Width = 1095
- End
- Begin VB.CheckBox CheckBorder
- Caption = "Border"
- Height = 255
- Left = 3600
- TabIndex = 1
- Top = 2520
- Value = 1 'Checked
- Width = 1095
- End
- Begin VB.CommandButton Close
- Caption = "Close"
- Height = 375
- Left = 3600
- TabIndex = 0
- Top = 120
- Width = 1095
- End
- Attribute VB_Name = "FormClock"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Type POINT
- x As Long
- y As Long
- End Type
- Dim m_pdHour As POLARDRAW20Lib.Shape
- Dim m_pdMinute As POLARDRAW20Lib.Shape
- Dim m_pdSecond As POLARDRAW20Lib.Shape
- Dim m_fTicking As Boolean
- Dim m_fBorder As Boolean
- Dim ptCenter As POINT
- Dim m_pdPage As POLARDRAW20Lib.Page
- Private Sub Form_Load()
- Dim lX As Long
- Dim lY As Long
- Dim l As Long
- Dim lRad As Long
- Dim Shape As POLARDRAW20Lib.Shape
- Set m_pdPage = POLARDraw1.ActivePage
- m_fTicking = False
- m_fBorder = True
- l = 0
- lRad = 90
- ptCenter.x = 0
- ptCenter.y = 0
- POLARDraw1.ActiveWindow.Environment.EditMode = polRotate
- While (l < 12)
- Dim lAngle As Double
-
- lAngle = l * 30 / (360 / (2 * 3.1416))
- lX = ptCenter.x - Sin(lAngle) * lRad
- lY = ptCenter.y - Cos(lAngle) * lRad
- If (l * 30) Mod 90 = 0 Then
- Set Shape = m_pdPage.Shapes.Add(5, lX - 10, lY - 10, lX + 10, lY + 10)
- Else
- Set Shape = m_pdPage.Shapes.Add(5, lX - 8, lY - 8, lX + 8, lY + 8)
- End If
- Shape.Rotate (l * 30)
- Shape.Fill.Color = RGB(0, 0, 255)
- l = l + 1
- Wend
- Set Shape = Nothing
- lX = ptCenter.x
- lY = ptCenter.y
- 'hour handle
- Set m_pdHour = m_pdPage.Shapes.Add(66, lX - 40, lY - 30, lX + 40, lY + 30)
- With m_pdHour
- .Rotation = -90
- .Move 0, -30
- End With
- 'minute handle
- Set m_pdMinute = m_pdPage.Shapes.Add(5, lX - 10, lY - 100, lX + 10, lY + 10)
- m_pdMinute.Fill.Color = RGB(255, 0, 0)
-
- 'seconds handle
- Set m_pdSecond = m_pdPage.Shapes.Add(1, lX - 2, lY - 95, lX + 2, lY + 10)
- m_pdSecond.Fill.Color = RGB(0, 0, 255)
- m_pdPage.Shapes.SelectAll
- POLARDraw1.ActiveWindow.FitTo polFitToSelection
- m_pdPage.Selection.Clear
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Set m_pdPage = Nothing
- Set m_pdHour = Nothing
- Set m_pdMinute = Nothing
- Set m_pdSecond = Nothing
-
- End Sub
- Private Sub Timer_Timer()
- Dim lHH As Long
- Dim lMM As Long
- Dim lSS As Long
- Dim lX As Long
- Dim lY As Long
- Dim crVal As Long
- ' get current time
- lHH = Hour(Time)
- lMM = Minute(Time)
- lSS = Second(Time)
- ' disable redrawing while we moving objects
- POLARDraw1.EnableRendering = False
- lX = ptCenter.x
- lY = ptCenter.y
- ' set shapes to initial position
- With m_pdHour
- .Left = lX - 40
- .Top = lY - 30
- .Right = lX + 40
- .Bottom = lY + 30
- .Rotation = -90
- .Move 0, -30
- End With
- With m_pdMinute
- .Left = lX - 10
- .Top = lY - 100
- .Right = lX + 10
- .Bottom = lY + 10
- .Fill.Color = RGB(255, 0, 0)
- .Rotation = 0
- End With
- With m_pdSecond
- .Left = lX - 2
- .Top = lY - 95
- .Right = lX + 2
- .Bottom = lY + 10
- .Rotation = 0
- End With
-
- ' rotate them around center according to the current time
- m_pdHour.RotateAroundPoint -(lHH + lMM / 60) * 30, ptCenter.x, ptCenter.y
- m_pdMinute.RotateAroundPoint -lMM * 6, ptCenter.x, ptCenter.y
- m_pdSecond.RotateAroundPoint -lSS * 6, ptCenter.x, ptCenter.y
- crVal = 255 * ((lSS Mod 60) / 60#)
- POLARDraw1.EnableRendering = True
- m_pdHour.Fill.Color = RGB(crVal, 255, 0)
- If m_fTicking Then
- Beep
- End If
- End Sub
- Private Sub CheckBorder_Click()
- If CheckBorder.Value = Checked Then
- m_fBorder = True
- Else
- m_fBorder = False
- End If
- If m_fBorder Then
- POLARDraw1.Appearance = cc3D
- POLARDraw1.BorderStyle = 1
- Else
- POLARDraw1.Appearance = ccFlat
- POLARDraw1.BorderStyle = 0
- End If
- ' stretch the canvas to fit the window
- POLARDraw1.EnableRendering = False
- m_pdPage.Shapes.SelectAll
- POLARDraw1.ActiveWindow.FitTo polFitToSelection
-
- ' this call will re-render canvas
- m_pdPage.Selection.Clear
- End Sub
- Private Sub CheckTicking_Click()
- If CheckTicking.Value = Checked Then
- m_fTicking = True
- Else
- m_fTicking = False
- End If
- End Sub
- Private Sub Close_Click()
- End
- End Sub
-