Pen::Pen(constColor&,REAL) method (gdipluspen.h)

Creates a Pen object that uses a specified color and width.

Syntax

void Pen(
  [in, ref] const Color & color,
  [in]      REAL          width
);

Parameters

[in, ref] color

Type: const Color

Reference to a Color object that specifies the color for this Pen object.

[in] width

Type: REAL

Optional. Real number that specifies the width of this pen's stroke. The default value is 1.0. If this value is 0, the width in device units is always 1 pixel, except that the width will not be affected by scale-transform operations that are in effect for the Graphics object that the Pen is used for; the width will always be 1 pixel.

Return value

None

Remarks

If you pass the address of a pen to one of the draw methods of a Graphics object, the width of the pen's stroke is dependent on the unit of measure specified in the Graphics object. The default unit of measure is UnitPixel, which is an element of the Unit enumeration.

Examples

The following example creates a Pen object with the color red and a width of 4.0.

Pen pen(Color(255,255,0,0), 4.0f); 

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

Color

Pen

Pen::SetWidth

Pens, Lines, and Rectangles

Setting Pen Width and Alignment