The following example creates a
Pen object, sets the end cap, and draws a line. The code then resets the end cap, draws a second line, resets the end cap again, and draws a third line.
C++
VOID Example_SetEndCap(HDC hdc)
{
Graphics graphics(hdc);
// Create a Pen object.
Pen pen(Color(255, 0, 0, 255), 15);
// Set the end cap of the pen, and draw a line.
pen.SetEndCap(LineCapArrowAnchor);
graphics.DrawLine(&pen, 0, 50, 400, 150);
// Reset the end cap, and draw a second line.
pen.SetEndCap(LineCapTriangle);
graphics.DrawLine(&pen, 0, 80, 400, 180);
// Reset the end cap, and draw a third line.
pen.SetEndCap(LineCapRound);
graphics.DrawLine(&pen, 0, 110, 400, 210);
}
PowerBASIC
SUB GDIP_SetPenEndCap (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPen AS DWORD
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create a Pen object.
hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 15, %UnitWorld, pPen)
' // Set the end cap of the pen, and draw a line.
hStatus = GdipSetPenEndCap(pPen, %LineCapArrowAnchor)
hStatus = GdipDrawLineI(pGraphics, pPen, 0, 50, 400, 150)
' // Reset the end cap, and draw a second line.
hStatus = GdipSetPenEndCap(pPen, %LineCapTriangle)
hStatus = GdipDrawLineI(pGraphics, pPen, 0, 80, 400, 180)
' // Reset the end cap, and draw a third line.
hStatus = GdipSetPenEndCap(pPen, %LineCapRound)
hStatus = GdipDrawLineI(pGraphics, pPen, 0, 110, 400, 210)
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipSetPenEndCap.png)