windows_programming_notes.nbk: Home | Index | Next Page: ExtTextOut | Previous Page: ExpandEnvironmentStrings


 ExtCreatePen

The ExtCreatePen function creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes.

    HPEN ExtCreatePen(
      DWORD dwPenStyle,      // pen style
      DWORD dwWidth,         // pen width
      CONST LOGBRUSH *lplb,  // brush attributes
      DWORD dwStyleCount,    // length of custom style array
      CONST DWORD *lpStyle   // custom style array
    );

Parameters

Return Values

If the function succeeds, the return value is a handle that identifies a logical pen.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks

A geometric pen can have any width and can have any of the attributes of a brush, such as dithers and patterns. A cosmetic pen can only be a single pixel wide and must be a solid color, but cosmetic pens are generally faster than geometric pens.

The width of a geometric pen is always specified in world units. The width of a cosmetic pen is always 1.

End caps and joins are only specified for geometric pens.

After an application creates a logical pen, it can select that pen into a device context by calling the SelectObject function. After a pen is selected into a device context, it can be used to draw lines and curves.

If dwPenStyle is PS_COSMETIC and PS_USERSTYLE, the entries in the lpStyle array specify lengths of dashes and spaces in style units. A style unit is defined by the device where the pen is used to draw a line.

If dwPenStyle is PS_GEOMETRIC and PS_USERSTYLE, the entries in the lpStyle array specify lengths of dashes and spaces in logical units.

If dwPenStyle is PS_ALTERNATE, the style unit is ignored and every other pixel is set.

If the lbStyle member of the LOGBRUSH structure pointed to by lplb is BS_PATTERN, the bitmap pointed to by the lbHatch member of that structure cannot be a DIB section. A DIB section is a bitmap created by CreateDIBSection. If that bitmap is a DIB section, the ExtCreatePen function fails.

When an application no longer requires a specified pen, it should call the DeleteObject function to delete the pen.

ICM: No color management is done at pen creation. However, color management is performed when the pen is selected into an ICM-enabled device context.

Requirements

  Windows NT/2000/XP/Vista: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Wingdi.h; include Windows.h.
  Library: Use Gdi32.lib.

windows_programming_notes.nbk: Home | Index | Next Page: ExtTextOut | Previous Page: ExpandEnvironmentStrings


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time