Graphics::DrawPolygon(constPen*,constPoint*,INT) method (gdiplusgraphics.h)

The Graphics::DrawPolygon method draws a polygon.

Syntax

Status DrawPolygon(
  [in] const Pen   *pen,
  [in] const Point *points,
  [in] INT         count
);

Parameters

[in] pen

Type: const Pen*

Pointer to a pen that is used to draw the polygon.

[in] points

Type: const Point*

Pointer to an array of Point objects that specify the vertices of the polygon.

[in] count

Type: INT*

Integer that specifies the number of elements in the points array.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

If the first and last coordinates in the points array are not identical, a line is drawn between them to close the polygon.

Examples

The following example draws a polygon, defined by an array of points.

VOID Example_DrawPolygon(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Pen object.
   Pen blackPen(Color(255, 0, 0, 0), 3);

   // Create an array of Point objects that define the polygon.
   Point point1(100, 100);
   Point point2(200, 130);
   Point point3(150, 200);
   Point point4(50, 200);
   Point point5(0, 130);
   Point points[5] = {point1, point2, point3, point4, point5};
   Point* pPoints = points;

   // Draw the polygon.
   graphics.DrawPolygon(&blackPen, pPoints, 5);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusgraphics.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

FillPolygon Methods

Graphics

Point

Polygons