Help Center

GdipGetPenDashArrayfunction

Gets an array of custom dashes and spaces currently set for a **Pen** object.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipGetPenDashArray (BYVAL pen AS GpPen PTR, BYVAL dash AS REAL PTR, BYVAL count AS INT_) AS GpStatus

Parameters

NameDescription
pen[in] Pointer to the Pen object.
dash[out] Pointer to an array that receives the length of the dashes and spaces in a custom dashed line.
count[in] Long integer value that specifies the number of elements in the dash array.

Description

Gets an array of custom dashes and spaces currently set for a Pen object.

Remarks

The elements in the dash array set the length of each dash and space in the dash pattern. The first element sets the length of a dash, the second element sets the length of a space, the third element sets the length of a dash, and so forth.

The length of each dash and space in the dash pattern is the product of each element in the array and the width of the Pen object.

Example

' ======================================================================================== ' The following example creates an array of real numbers and a Pen object, sets the dash ' pattern, and draws a custom dashed line. The code then gets the dash pattern currently ' set for the pen. ' ======================================================================================== SUB Example_GetPenDashArray (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Create and set an array of real numbers. DIM dashVals(3) AS SINGLE = {5.0, 2.0, 15.0, 4.0}

' // Create a Pen object. DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_BLACK, 5, UnitWorld, @pen)

' // Set the dash pattern for the custom dashed line. hStatus = GdipSetPenDashArray(pen, @dashVals(0), 4)

' // Draw the custom dashed line. hStatus = GdipDrawLine(graphics, pen, 10, 20, 390, 200)

' // Obtain information about the pen. DIM count AS LONG DIM dashValues(ANY) AS SINGLE

hStatus = GdipGetPenDashCount(pen, @count) REDIM dashValues(count - 1) hStatus = GdipGetPenDashArray(pen, @dashValues(0), count)

FOR j AS LONG = 0 TO count - 1

' // Inspect or use the value in dashValues[j].
  OutputDebugStringW WSTR(dashValues(j))

NEXT

' // Cleanup IF pen THEN GdipDeletePen(pen) IF graphics THEN GdipDeleteGraphics(graphics)

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

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2343
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusPen.md
  • Topic: GdiPlusPen