Polygon

2.x

  BOOL Polygon(hdc, lppt, cPoints)    
  HDC hdc; /* handle of device context */
  const POINT FAR* lppt; /* address of array with points for vertices */
  int cPoints; /* number of points in array */

The Polygon function draws a polygon consisting of two or more points (vertices) connected by lines. The system closes the polygon automatically, if necessary, by drawing a line from the last vertex to the first. Polygons are surrounded by a frame drawn by using the current pen and filled by using the current brush.

Parameters

hdc

Identifies the device context.

lppt

Points to an array of POINT structures that specify the vertices of the polygon. Each structure in the array specifies a vertex. The POINT structure has the following form:

typedef struct tagPOINT {   /* pt */
   int x;
   int y;
} POINT;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

cPoints

Specifies the number of vertices in the array.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

The current polygon-filling mode can be retrieved or set by using the GetPolyFillMode and SetPolyFillMode functions.

Example

The following example assigns values to an array of points and then calls the Polygon function:

HDC hdc;

POINT aPoints[3];

aPoints[0].x = 50;
aPoints[0].y = 10;
aPoints[1].x = 250;
aPoints[1].y = 50;
aPoints[2].x = 125;
aPoints[2].y = 130;

Polygon(hdc, aPoints, sizeof(aPoints) / sizeof(POINT));

See Also

GetPolyFillMode, Polyline, PolyPolygon, SetPolyFillMode