The following example creates two
GraphicsPath objects:
path1 and
path2. The code adds an open figure consisting of an arc and a Bézier spline to each path. The code calls the
GdiAddPathPath function to add
path2 to
path1. The second argument is TRUE, which specifies that all four items (two arcs and two Bézier splines) belong to the same figure.
C++
VOID AddPathExample(HDC hdc)
{
Graphics graphics(hdc);
GraphicsPath path1;
path1.AddArc(10, 10, 50, 20, 0.0f, 150.0f);
path1.AddBezier(10, 50, 60, 50, 10, 80, 60, 80);
GraphicsPath path2;
path2.AddArc(10, 110, 50, 20, 0.0f, 150.0f);
path2.AddBezier(10, 150, 60, 150, 10, 180, 60, 180);
path1.AddPath(&path2, TRUE);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawPath(&pen, &path1);
}
PowerBASIC
SUB GDIP_AddPathPath (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPath1 AS DWORD
LOCAL pPath2 AS DWORD
LOCAL pPen AS DWORD
hStatus = GdipCreateFromHDC(hdc, pGraphics)
hStatus = GdipCreatePath(%FillModeAlternate, pPath1)
hStatus = GdipAddPathArc(pPath1, 10, 10, 50, 20, 0, 150)
hStatus = GdipAddPathBezier(pPath1, 10, 50, 60, 50, 10, 80, 60, 80)
hStatus = GdipCreatePath(%FillModeAlternate, pPath2)
hStatus = GdipAddPathArc(pPath2, 10, 110, 50, 20, 0, 150)
hStatus = GdipAddPathBezier(pPath2, 10, 150, 60, 150, 10, 180, 60, 180)
hStatus = GdipAddPathPath(pPath1, pPath2, %TRUE)
' // Draw the path.
hStatus = GdipCreatePen1(GDIP_ARGB(255, 255, 0, 0), 1, %UnitWorld, pPen)
hStatus = GdipDrawPath(pGraphics, pPen, pPath1)
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pPath2 THEN GdipDeletePath(pPath2)
IF pPath1 THEN GdipDeletePath(pPath1)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipAddPathPath.png)