Pen::SetDashCap method (gdipluspen.h)

The Pen::SetDashCap method sets the dash cap style for this Pen object.

Syntax

Status SetDashCap(
  [in] DashCap dashCap
);

Parameters

[in] dashCap

Type: DashCap

Element of the DashCap enumeration that specifies the dash cap for this Pen object.

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 you set the alignment of a Pen object to PenAlignmentInset, you cannot use that pen to draw triangular dash caps.

Examples

The following example creates a Pen object, sets the dash style and the dash cap, and draws a dashed line.

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

   // Create a pen.
   Pen pen(Color(255, 0, 0, 255), 20);

   // Set the dash style for the pen.
   pen.SetDashStyle(DashStyleDash);

   // Set a triangular dash cap for the pen.
   pen.SetDashCap(DashCapTriangle);

   // Draw a line using the pen.
   graphics.DrawLine(&pen, 20, 20, 200, 100);
}

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 gdipluspen.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Drawing a Custom Dashed Line

Drawing a Line with Line Caps

Pen

Pen::GetCustomEndCap

Pen::GetCustomStartCap

Pen::GetDashCap

Pens, Lines, and Rectangles