Draw Straight And Rounded PolyGon

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Set the form AutoRedraw property to True.
'Insert the following code to your module:

Public Type POINTAPI
x As Long
y As Long
End Type
'To make rounded polygon, replace the 2 'Polyline' in this document with 'PolyBezier'
Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, _
ByVal nCount As Long) As Long

'Insert the following code to your form:

Private Sub Form_Load()
Dim Points() As POINTAPI
Dim NumPoints As Integer
Dim I As Integer
'Replace the '4' below with the number of your polygon's points.
NumPoints = 4
'Replace the '4' below with the number of your polygon's points.
ReDim Points(1 To 4)
Points(1).x = 110
Points(1).y = 20
Points(2).x = 130
Points(2).y = 170
Points(3).x = 30
Points(3).y = 70
Points(4).x = 110
Points(4).y = 20
'You can add points to the list above.
If Polyline(Me.hdc, Points(1), NumPoints) = 0 Then Exit Sub
Me.Refresh
End Sub

Go Back