Pen::SetCompoundArray method (gdipluspen.h)

The Pen::SetCompoundArray method sets the compound array for this Pen object.

Syntax

Status SetCompoundArray(
  [in] const REAL *compoundArray,
  [in] INT        count
);

Parameters

[in] compoundArray

Type: const REAL*

Pointer to an array of real numbers that specifies the compound array. The elements in the array must be in increasing order, not less than 0, and not greater than 1.

[in] count

Type: INT

Positive even integer that specifies the number of elements in the compoundArray array. The integer must not be greater than the number of elements in the compound 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

Suppose you want a pen to draw two parallel lines where the width of the first line is 20 percent of the pen's width, the width of the space that separates the two lines is 50 percent of the pen' s width, and the width of the second line is 30 percent of the pen's width. Start by creating a Pen object and an array of real numbers. You can then set the compound array by passing the array with the values 0.0, 0.2, 0.7, and 1.0 to the Pen::SetCompoundArray method of the Pen object.

If you set the alignment of a Pen object to PenAlignmentInset, you cannot use that pen to draw compound lines.

Examples

The following example creates a Pen object and sets the compound array for the pen. The code then draws a line using the Pen object.

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

   // Create an array of real numbers and a Pen object.
   REAL compVals[6] = {0.0f, 0.2f, 0.5f, 0.7f, 0.9f, 1.0f};
   Pen pen(Color(255, 0, 0, 255), 30);

   // Set the compound array of the pen.
   pen.SetCompoundArray(compVals, 6);

   // Draw a line with the pen.
   graphics.DrawLine(&pen, 5, 20, 405, 200);
}

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::GetCompoundArray

Pen::GetCompoundArrayCount

Pens, Lines, and Rectangles