Gdi::CreatePen_I

This method creates a logical pen that has the specified style, width, and color. You can subsequently select the pen into a device context and use the pen to draw lines and curves.

static WINGDIAPI HPEN WINAPI CreatePen_I(
  int fnPenStyle, 
  int nWidth, 
  COLORREF crColor
);

Parameters

  • fnPenStyle
    [in] Integer that specifies the pen style. The following table shows the possible values.

    Value Description
    PS_SOLID Pen is solid.
    PS_DASH Pen is dashed. This style is valid only when the pen width is one device unit or less.
    PS_NULL Pen is invisible.
  • nWidth
    [in] Integer that specifies the width of the pen, in logical units. If nWidth is zero, the pen is a single pixel wide, regardless of the current transformation.

    Gdi::CreatePen_I returns a pen with the specified width bit with the PS_SOLID style if you specify a width greater than one for the PS_DASH style.

  • crColor
    [in] COLORREF value that specifies a color reference for the pen color.

Return Values

Handle to a logical pen indicates success. NULL indicates failure. To get extended error information, call GetLastError.

Remarks

This method is an internal version of the CreatePen function.

After an application creates a logical pen, the application can select that pen into a device context by calling the Gdi::SelectObject_I method. After an application selects a pen into a device context, the application can use the pen to draw lines and curves.

If the value specified by the nWidth parameter is zero, a line drawn with the created pen is always a single pixel wide regardless of the current transformation.

If the value specified by nWidth is greater than 1, the fnPenStyle parameter must be PS_NULL or PS_SOLID.

Windows CE does not support user-specified endcap styles, such as PS_ENDCAP_ROUND.

When you no longer need the pen, call the Gdi::DeleteObject_I method to delete the pen.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Gdi.hpp.

See Also

CreatePen | Gdi::CreatePenIndirect_I | Gdi::DeleteObject_I | Gdi::SelectObject_I | COLORREF

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.