Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function Polyline Lib "gdi32.dll" _
(ByVal hdc As Long, lpPoints As Any, ByVal cPoints As Long) As Long
Private Declare Function MoveToEx Lib "gdi32.dll" _
(ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long, ByVal lpPoint As Long) As Long
Private Declare Function LineTo Lib "gdi32.dll" _
(ByVal hdc As Long, ByVal nXEnd As Long, ByVal nYEnd As Long) As Long
Private Sub Form_Load()
Me.Picture1.ScaleMode = 3
Me.Picture1.BackColor = vbWhite
End Sub
Private Sub Picture1_Paint()
Dim lpPoints(11) As POINTAPI
Dim dx, dy, y, x
dx = Me.Picture1.ScaleWidth
dy = Me.Picture1.ScaleHeight
Me.Picture1.ForeColor = vbBlack
Call MoveToEx(Me.Picture1.hdc, 30, 10, 0)
Call LineTo(Me.Picture1.hdc, 30, dy - 30)
Call LineTo(Me.Picture1.hdc, dx - 20, dy - 30)
For a = 0 To 10
y = ((dy - 40) / 10) * a + 10
Call MoveToEx(Me.Picture1.hdc, 20, y, 0)
Call LineTo(Me.Picture1.hdc, 30, y)
If a = 0 Or a = 5 Or a = 10 Then
Me.Picture1.CurrentX = 0
Me.Picture1.CurrentY = y - 5
Me.Picture1.Print 10 - a
End If
Next
y = dy - 30
For a = 1 To 12
x = ((dx - 50) / 12) * (a - 1) + 30
Call MoveToEx(Me.Picture1.hdc, x, y, 0)
Call LineTo(Me.Picture1.hdc, x, y + 5)
Me.Picture1.CurrentX = x - 5
Me.Picture1.CurrentY = y + 5
Me.Picture1.Print a
Me.Picture1.CurrentX = x - 3
Me.Picture1.CurrentY = y + 17
Me.Picture1.Print "月"
Next
Me.Picture1.ForeColor = vbRed
y = dy - 40
Randomize
For a = 0 To 11
x = ((dx - 50) / 12) * (a - 1) + 50
lpPoints(a).x = x
lpPoints(a).y = y * Rnd + 10
Next
Call Polyline(Me.Picture1.hdc, lpPoints(0), 12)
End Sub |