Microsoft Foundation Classes (mfc.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CDC::SelectObject
◄CDC► ◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
CGdiObject* SelectObject( CGdiObject* pObject );
CPen* SelectObject( CPen* pPen );
CBrush* SelectObject( CBrush* pBrush );
CFont* SelectObject( CFont* pFont );
CBitmap* SelectObject( CBitmap* pBitmap );
int SelectObject( CRgn* pRgn );
Parameter Description
<pObject> Identifies the object to be selected.
Note that this general version of the SelectObject member
function does not work for regions. To select regions, see
the version of SelectObject in the next group that is
specialized for regions.
<pPen> A pointer to a ◄CPen► object to be selected.
<pBrush> A pointer to a ◄CBrush► object to be selected.
<pFont> A pointer to a ◄CFont► object to be selected.
<pBitmap> A pointer to a ◄CBitmap► object to be selected.
<pRgn> A pointer to a ◄CRgn► object to be selected.
Remarks
Selects an object into the current device context. Class CDC provides a
general version of SelectObject and five versions specialized for
particular kinds of GDI objects, including pens, brushes, fonts,
bitmaps, and regions.
The newly 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 function replaces the current pen with the pen
specified by <pObject>.
Note that class ◄CMetaFileDC► overrides the SelectObject member
function. The CMetaFileDC class is derived from class CDC specifically
for use with metafiles. For information on object selection in
metafiles, see the CMetaFileDC class.
An application can select a bitmap into memory device contexts only, and
into only one memory device context at a time. The format of the bitmap
must either be monochrome or compatible with the specified device; if it
is not, SelectObject returns an error.
Return Value
A pointer to a ◄CGdiObject► object or to an object of one of the classes
derived from CGdiObject, such as CPen, depending on which version of the
function used. The object pointed to is being replaced by the object
specified by the function's parameter. It is NULL if there is an error.
For the version of the member function that takes a region parameter,
<pRgn>, the return value is one of the following:
Value Meaning
COMPLEXREGION New clipping region has overlapping borders.
ERROR Device context or region handle is not valid.
NULLREGION New clipping region is empty.
SIMPLEREGION New clipping region has no overlapping borders.
See Also
◄CGdiObject::DeleteObject►, ◄CDC::SelectClipRgn►, ◄CDC::SelectPalette►,
◄::SelectObject►
-♦-