CPen::FromHandle

Returns a pointer to a CPen object given a handle to a Windows GDI pen object.

static CPen* PASCAL FromHandle(
   HPEN hPen 
);

Parameters

  • hPen
    HPEN handle to Windows GDI pen.

Return Value

A pointer to a CPen object if successful; otherwise NULL.

Remarks

If a CPen object is not attached to the handle, a temporary CPen object is created and attached. This temporary CPen object is valid only until the next time the application has idle time in its event loop, at which time all temporary graphic objects are deleted. In other words, the temporary object is only valid during the processing of one window message.

Example

// Convert an HPEN to a CPen*.
// NOTE: hPen is a valid pen handle.
CPen* pPen = CPen::FromHandle(hPen);

Requirements

Header: afxwin.h

See Also

Reference

CPen Class

Hierarchy Chart

Other Resources

CPen Members