Help Center

GdipGetPenDashCountfunction

Gets the number of elements in a dash pattern array.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipGetPenDashCount (BYVAL pen AS GpPen PTR, BYVAL count AS INT_ PTR) AS GpStatus

Parameters

NameDescription
pen[in] Pointer to the Pen object.
count[out] Pointer to a variable that receives the number of elements in the dash pattern array.

Description

Gets the number of elements in a dash pattern array.

Example

' ======================================================================================== ' This example sets a custom dash pattern for a Pen object, draws a dashed line, and then ' retrieves the number of elements in the dash array using GdipGetPenDashCount. ' ======================================================================================== SUB Example_GetPenDashCount (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 a Pen object and set a custom dash pattern DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_BLACK, 5, UnitWorld, @pen) DIM dashVals(3) AS SINGLE = {5.0, 2.0, 15.0, 4.0} hStatus = GdipSetPenDashArray(pen, @dashVals(0), 4)

' // Draw a dashed line hStatus = GdipDrawLine(graphics, pen, 20, 50, 380, 50)

' // Retrieve the dash count DIM dashCount AS LONG hStatus = GdipGetPenDashCount(pen, @dashCount) AfxMsg "Dash count: " & WSTR(dashCount)

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

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

Reference

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