OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing TPen

You can construct a TPen either directly, by specifying the color, width, and style of the pen, or indirectly, by specifying a TPen & or pointer to a LOGPEN structure.

Directly constructing a pen creates a new object with the specified attributes. Here is the constructor for directly constructing a pen:

TPen(TColor color, int width=1, int style=PS_SOLID);

The style parameter can be one of the following values: PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT, PS_NULL, or PS_INSIDEFRAME.

Indirectly creating a pen creates a new object, but copies the attributes of the object passed to it into the new pen object. Here are the constructors for indirectly creating a pen:

TPen(const LOGPEN far* logPen);
TPen(const TPen&);

You can also create a new TPen object from an existing HPEN handle:

TPen(HPEN handle, TAutoDelete autoDelete = NoAutoDelete);

This constructor is used to obtain an ObjectWindows object as an alias to a regular Windows handle received in a message.

Two other constructors are available only for 32-bit applications. You can use these constructors to create cosmetic or geometric pens:

TPen(uint32 penStyle,
uint32 width,
const TBrush& brush,
uint32 styleCount,
LPDWORD style);
TPen(uint32 penStyle,
uint32 width,
uint32 styleCount,
LPDWORD style);

where:

  • penStyle is a combination of type, style, end cap, and join of the pen, where:
    • Type is either PS_GEOMETRIC or PS_COSMETIC.
    • Style can be any one of the following values:
      • PS_ALTERNATE
      • PS_DASH
      • PS_DASHDOT
      • PS_DASHDOTDOT
      • PS_DOT
      • PS_INSIDEFRAME
      • PS_NULL
      • PS_SOLID
      • PS_USERSTYLE
    • End cap is specified only for geometric pens, and can be one of the following values:
      • PS_ENDCAP_FLAT
      • PS_ENDCAP_ROUND
      • PS_ENDCAP_SQUARE
    • Join is specified only for geometric pens, and can be one of the following values:
      • PS_JOIN_BEVEL
      • PS_JOIN_MITER
      • PS_JOIN_ROUND
  • width is the pen width.
  • brush or logBrush is a reference to an existing TBrush or LOGBRUSH object.
  • styleCount is the size (in uint32s) of the style array and should be 0 unless the pen style is PS_USERSTYLE.
  • style is a pointer to an array of uint32s that specifies the pattern of the pen and should be NULL unless the pen style is PS_USERSTYLE.

See Also