SelectObject (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function selects an object into a specified device context. The new object replaces the previous object of the same type.

HGDIOBJ SelectObject(
  HDC hdc, 
  HGDIOBJ hgdiobj


[in] Handle to the device context.
[in] Handle to the object to be selected.

The specified object must have been created by using one of the following functions.

BitmapCreateBitmap, CreateCompatibleBitmap, CreateDIBSection

(Bitmaps can be selected for memory device contexts only, and for only one device context at a time.)

BrushCreateDIBPatternBrushPt, CreatePatternBrush, CreateSolidBrush
PenCreatePen, CreatePenIndirect
RegionCombineRgn, CreateRectRgn, CreateRectRgnIndirect

Return Values

If the selected object is not a region, the handle of the object being replaced indicates success.

If the selected object is a region, one of the following values indicates success.

SIMPLEREGIONRegion consists of a single rectangle.
COMPLEXREGIONRegion consists of more than one rectangle.
NULLREGIONRegion is empty.

NULL indicates that an error occurred and the selected object is not a region. Otherwise, a GDI_ERROR value is returned.


This function returns the previously selected object of the specified type.

An application should always replace a new object with the original, default object after it has finished drawing with the new object.

An application cannot select a bitmap into more than one device context at a time.


OS Versions: Windows CE 1.0 and later.
Header: Windows.h.
Link Library: Coredll.lib.

See Also

CombineRgn | CreateBitmap | CreateCompatibleBitmap | CreateDIBPatternBrushPt | CreateDIBSection | CreateFontIndirect | CreatePatternBrush | CreatePen | CreatePenIndirect | CreateRectRgn | CreateRectRgnIndirect | CreateSolidBrush | SelectClipRgn | GDI Functions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.