The following example draws a polygon.
C++
VOID Example_DrawPolygon2(HDC hdc)
{
Graphics graphics(hdc);
// Create a Pen object.
Pen blackPen(Color(255, 0, 0, 0), 3);
// Create an array of PointF objects that define the polygon.
PointF point1(100.0f, 100.0f);
PointF point2(200.0f, 130.0f);
PointF point3(150.0f, 200.0f);
PointF point4(50.0f, 200.0f);
PointF point5(0.0f, 130.0f);
PointF points[5] = {point1, point2, point3, point4, point5};
PointF* pPoints = points;
// Draw the polygon.
graphics.DrawPolygon(&blackPen, pPoints, 5);
}
PowerBASIC
SUB GDIP_DrawPolygon (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPen AS DWORD
DIM pt(4) AS POINTF
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create a Pen
hStatus = GdipCreatePen1(GDIP_ARGB(255,0, 0, 0), 3, %UnitPixel, pPen)
' // Create an array of PointF objects that define the polygon.
pt(0).x = 100.0! : pt(0).y = 100.0!
pt(1).x = 200.0! : pt(1).y = 130.0!
pt(2).x = 150.0! : pt(3).y = 200.0!
pt(3).x = 50.0! : pt(3).y = 200.0!
pt(4).x = 0.0! : pt(4).y = 130.0!
' // Draw the pie
hStatus = GdipDrawPolygon(pGraphics, pPen, pt(0), 5)
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipDrawPolygon.png)