Polygon Function

Declare Function Polygon Lib "gdi32.dll" (ByVal hdc As Long, lpPoint As POINT_TYPE, ByVal nCount As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

Polygon draws and fills a polygon on a device. The polygon is drawn using the current pen and is filled using the current brush. The vertices of the polygon are stored in an array passed as lpPoint, in sequential order. Only specify each point once. The function returns 1 if successful, or 0 if an error occured.

hdc
A device context to the device to draw the polygon on.
lpPoint
An array holding the vertices of the polygon in the order which they will be drawn in. Specify each point only once.
nCount
The number of elements in the array passed as lpPoint.

Example:

' Draw a diamond on window Form1 using the default pen and
' brush.  Note how the points must be loaded into the array before calling the function.
Dim points(0 To 3) As POINT_TYPE  ' vertices of the polygon
Dim retval As Long  ' return value

' Load the coordinates of the diamond's vertices into the array.
points(0).x = 200: points(0).y = 100  ' 1st point (200,100)
points(1).x = 250: points(1).y = 150  ' 2nd point (250,150)
points(2).x = 200: points(2).y = 200  ' 3rd point (200,200)
points(3).x = 150: points(3).y = 150  ' 4th point (150,150)

' Draw the diamond using Form1's default pen and brush
retval = Polygon(Form1.hDC, points(0), 4)  ' four points in the array

See Also: PolyPolygon
Category: Filled Shapes

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/p/polygon.html