CPen Class |
Description
The class responsible for creating and managing pen resources.
CPen Members
Initialization and Assignment | |
CPen | CPen(); CPen(HPEN hPen); CPen(int nPenStyle, int nWidth, COLORREF crColor); CPen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL);Constructs a CPen object. |
static CPen* FromHandle(HPEN hPen);Returns the CPen associated with the specified pen handle. If a CPen object doesn't already exist, a temporary CPen object is created. This temporary CPen will be deleted sometime after the processing of the current message is complete.
operator HPEN() const;Allows a CPen object to be used as a pen handle (HPEN).
EXTLOGPEN GetExtLogPen() const;Retrieves the EXTLOGPEN struct that specifies the pen's style, width, color and brush attributes.
LOGPEN GetLogPen() const;Retrieves the LOGPEN struct that specifies the pen's style, width, and color.
HPEN CreatePen(int nPenStyle, int nWidth, COLORREF crColor);Creates a logical pen that has the specified style, width, and color.
HPEN CreatePenIndirect(LPLOGPEN lpLogPen);Creates a logical pen that has the style, width, and color specified in a structure.
HPEN ExtCreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL);Creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes.
Base class Members
For base class members, refer to the members of CGDIObject.
Remarks
CPen objects can be used anywhere a a handle to a pen (HPEN) might be used. They can be substituted for the HPEN in any of the Windows API functions which use a HPEN as a function argument. The benefit of using a CPen object is that it automatically deletes the pen when it is destroyed.
Refer to the Graphics Device Interface section of Using Win32++ for additional information on using this class.
Summary Information
Header file | gdi.h |
Win32/64 support | Yes |
WinCE support | Yes |