GdipSetPenDashArrayfunction
Sets an array of custom dashes and spaces for a **Pen** object.
Syntax
FUNCTION GdipSetPenDashArray (BYVAL pen AS GpPen PTR, BYVAL dash AS CONST REAL PTR, BYVAL count AS INT_) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
pen | [in] Pointer to the Pen object. | |
dash | [in] Pointer to an array of real numbers that specifies the length of the custom dashes and spaces. All elements in the array must be positive real numbers. | |
count | [in] Long integer that specifies the number of elements in the dash array. The integer must be greater than 0 and not greater than the total number of elements in the array. |
Description
Sets an array of custom dashes and spaces for a Pen object.
Remarks
This method will set the DashStyle enumeration for the Pen object to DashStyleCustom.
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 the element value in the array and the width of the Pen object.
Example
' ======================================================================================== ' The following example creates an array of real numbers. The code then creates a Pen object, ' sets the dash pattern based on the array, and then draws the custom dashed line. ' ======================================================================================== SUB Example_SetPenDashArray (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)
' // Cleanup IF pen THEN GdipDeletePen(pen) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2342
- Documented in Graphics/GdiPlus Flat Api/GdiPlusPen.md
- Topic: GdiPlusPen