Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function creates a logical pen that has the specified style, width, and color. The pen can subsequently be selected into a device context and used to draw lines and curves.
HPEN CreatePen( int fnPenStyle , int nWidth , COLORREF crColor );
Parameters
Value | Description |
---|---|
PS_SOLID | Pen is solid. |
PS_DASH | Pen is dashed. This style is valid only when the pen width is one or less in device units. |
PS_NULL | Pen is invisible. |
CreatePenreturns 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.
Return Values
Handle to a logical pen indicates success. NULL indicates failure. To get extended error information, call GetLastError.
Remarks
After an application creates a logical pen, it can select that pen into a device context by calling the SelectObjectfunction. After a pen is selected into a device context, it can be used to draw lines and curves.
If the value specified by the nWidthparameter is zero, a line drawn with the created pen will always be a single pixel wide regardless of the current transformation.
If the value specified by nWidthis greater than 1, the fnPenStyleparameter must be PS_NULL or PS_SOLID.
User-specified endcap styles, such as PS_ENDCAP_ROUND, are not supported.
When you no longer need the pen, call the DeleteObjectfunction to delete it.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 2.0 and later | Wingdi.h | Mgdraw.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
CreatePenIndirect, DeleteObject, GetLastError, SelectObject