The following example creates a
GraphicsPath object
path, adds a sequence of four connected lines to
path, and then draws
path.
C++
VOID Example_AddLines(HDC hdc)
{
Graphics graphics(hdc);
PointF pts[] = {PointF(20.0f, 20.0f),
PointF(30.0f, 30.0f),
PointF(40.0f, 25.0f),
PointF(50.0f, 30.0f),
PointF(60.0f, 20.0f)};
GraphicsPath path;
path.AddLines(pts, 5);
// Draw the path.
Pen pen(Color(255, 255, 0, 0));
graphics.DrawPath(&pen, &path);
}
PowerBASIC
SUB GDIP_AddPathLines (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPath AS DWORD
LOCAL pPen AS DWORD
DIM pts(4) AS POINTF
hStatus = GdipCreateFromHDC(hdc, pGraphics)
hStatus = GdipCreatePath(%FillModeAlternate, pPath)
pts(0).x = 20 : pts(0).y = 20
pts(1).x = 30 : pts(1).y = 30
pts(2).x = 40 : pts(2).y = 25
pts(3).x = 50 : pts(3).y = 30
pts(4).x = 60 : pts(4).y = 20
hStatus = GdipAddPathLine2(pPath, pts(0), 5)
' // Draw the path.
hStatus = GdipCreatePen1(GDIP_ARGB(255, 255, 0, 0), 1, %UnitWorld, pPen)
hStatus = GdipDrawPath(pGraphics, pPen, pPath)
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pPath THEN GdipDeletePath(pPath)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipAddPathLine2.png)