Help Center

CGpPen.SetDashStylemethod

Sets the dash style for this **Pen** object.

GraphicsmethodCGpPen.incdocumented

Syntax

FUNCTION SetDashStyle (BYVAL nDashStyle AS DashStyle) AS GpStatus

Parameters

NameDescription
nDashStyleElement of the DashStyle enumeration that specifies the dash style for this Pen object.

Return value

If the function succeeds, it returns Ok, which is an element of the GpStatus enumeration.

If the function fails, it returns one of the other elements of the GpStatus enumeration.

Description

Sets the dash style for this Pen object.

Example

' ======================================================================================== ' The following example creates a Pen object, sets the dash style, and draws a dashed line. ' The code then gets the dash style, creates a second pen with the dash style of the first ' pen, and draws a second dashed line. ' ======================================================================================== SUB Example_SetDashStyle (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

' // Create a Pen object DIM pen AS CGpPen = CGpPen(ARGB_BLUE, 20)

' // Set the dash style for the pen pen.SetDashStyle(DashStyleDashDot)

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

' // Draw a line using the pen graphics.DrawLine(@pen, 20, 20, 200, 100)

' // Obtain the dash style for the pen. DIM nDashStyle AS DashStyle

' // Create another pen, and use the same dash style. DIM pen2 AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 255, 0), 9)

' // Draw a second dashed line. graphics.DrawLine(@pen2, 20, 60, 200, 140)

END SUB ' ========================================================================================

Reference

  • Include file CGpPen.inc
  • Defined in AfxNova/CGpPen.inc:351
  • Documented in Graphics/GdiPlus Classes/CGpPen Class.md
  • Topic: CGpPen Class