Pen::GetDashPattern method (gdipluspen.h)

The Pen::GetDashPattern method gets an array of custom dashes and spaces currently set for this Pen object.

Syntax

Status GetDashPattern(
  [out] REAL *dashArray,
  [in]  INT  count
);

Parameters

[out] dashArray

Type: REAL*

Pointer to an array that receives the length of the dashes and spaces in a custom dashed line.

[in] count

Type: INT

Integer that specifies the number of elements in the dashArray array.

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

The elements in the dashArray 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.

Examples

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.

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

   // Create a custom dashed pen, and use it to draw a line.
   REAL dashVals[4] = {5, 2, 15, 4};
   Pen pen(Color(255, 0, 0, 0), 5);
   pen.SetDashPattern(dashVals, 4);
   graphics.DrawLine(&pen, 5, 20, 405, 200);

   // Obtain information about the pen.
   INT count = 0;
   REAL* dashValues = NULL;

   count = pen.GetDashPatternCount();
   dashValues = new REAL[count];
   pen.GetDashPattern(dashValues, count);

   for(INT j = 0; j < count; ++j)
   {
      // Inspect or use the value in dashValues[j].
   }
   delete [] dashValues;
}

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

Pen

Pen::GetDashPatternCount

Pen::SetDashPattern

Pens, Lines, and Rectangles