CDC::SelectObject
This method selects an object for the device context.
CPen* SelectObject(
CPen* pPen );
CBrush* SelectObject(
CBrush* pBrush );
virtual CFont* SelectObject(
CFont* pFont );
CBitmap* SelectObject(
CBitmap* pBitmap );
int SelectObject(
CRgn* pRgn );
CGdiObject* SelectObject(
CGdiObject* pObject );
Parameters
- pPen
Pointer to a CPen object to select. - pBrush
Pointer to a CBrush object to select. - pFont
Pointer to a CFont object to select. - pBitmap
Pointer to a CBitmap object to select. - pRgn
Pointer to a CRgn object to select. - pObject
Pointer to a CGdi object to select.
Return Value
Pointer to the object being replaced. This is a pointer to an object of one of the classes derived from CGdiObject, such as CPen, depending on which version of the function is used. The return value is NULL if there is an error. This function may return a pointer to a temporary object. This temporary object is only valid during the processing of one Windows message. For more information, see CGdiObject::FromHandle.
The version of the method that takes a region parameter performs the same task as the SelectClipRgn method. Its return value can be any of the following:
- COMPLEXREGION
New clipping region has overlapping borders. - ERROR
Device context or region is not valid. - NULLREGION
New clipping region is empty. - SIMPLEREGION
New clipping region has no overlapping borders.
Remarks
The CDC class provides five Windows CE implementations specialized for particular kinds of GDI objects, including pens, brushes, fonts, bitmaps, and regions. The selected object replaces the previous object of the same type. For example, if pObject of the general version of SelectObject points to a CPen object, the method replaces the current pen with the pen specified by pObject.
An application can select a bitmap for memory device contexts only and for only one memory device context at a time. The format of the bitmap must be monochrome or compatible with the device context; if it is not, SelectObject returns an error.
Requirements
** Windows CE versions:** 1.0 and later
Header file: Declared in Afxwin.h
Platform: H/PC Pro, Palm-size PC, Pocket PC
See Also
CGdiObject::DeleteObject, CGdiObject::FromHandle, CDC::SelectClipRgn, CPen