|
' Draw a red triangle and a red parallelogram on window Form1. The
' triangle has corners (100,100), (200,150), and (0,150). The parallelogram has corners
' (300,300), (400,300), (350,400), and (250,400). Note that since the first and last points
' are not connected, the beginning point is also specified as the last point in order
' to close the figures.
Private Type POINT_TYPE
x As Long
y As Long
End Type
Dim points(0 To 8) As POINT_TYPE ' the points in both sets
Dim numpoints(0 To 1) As Long ' the number of points in each set
Dim retval As Long ' return value
Private Declare Function PolyPolyline Lib "gdi32.dll" (ByVal hdc As Long, lppt As POINT_TYPE, lpdwPolyPoints As Long, ByVal cCount As Long) As Long
Private Sub Form_Click()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
' -> Code written by Raist Lin (Raist_Lin@hotmail.com)
Me.ScaleMode = vbPixels
' Load the points for the triangle into the array. The point (100,100) is both the first
' and last points in order to close the figure.
points(0).x = 100: points(0).y = 100 ' point #0: (100,100)
points(1).x = 200: points(1).y = 150 ' point #1: (200,150)
points(2).x = 0: points(2).y = 150 ' point #2: (0,150)
points(3).x = 100: points(3).y = 100 ' point #3: (100,100)
numpoints(0) = 4 ' number of points in first set
' Load the points for the parallelogram in a similar fashion.
points(4).x = 300: points(4).y = 300 ' point #4: (300,300)
points(5).x = 400: points(5).y = 300 ' point #5: (400,300)
points(6).x = 350: points(6).y = 400 ' point #6: (350,400)
points(7).x = 250: points(7).y = 400 ' point #7: (250,400)
points(8).x = 300: points(8).y = 300 ' point #8: (300,300)
numpoints(1) = 5 ' number of points in second set
' Now, finally draw both sets of points. The two are not mutually connected.
Form1.ForeColor = RGB(255, 0, 0) ' set Form1's drawing color to red
retval = PolyPolyline(Form1.hdc, points(0), numpoints(0), 2) ' draw the lines
End Sub
|
|