SelectObject  VJJ.84 

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

HGDIOBJ SelectObject(

    HDC hdc,

// handle of device context

    HGDIOBJ hgdiobj

// handle of object 

   );

 

 

Parameters

hdc

Identifies the device context.

hgdiobj

Identifies the object to be selected. The specified object must have been created by using one of the following functions:

Object

Functions

Bitmap

CreateBitmapBE7ZRJ, CreateBitmapIndirectDO3E4S, CreateCompatibleBitmap21O2QYP, CreateDIBitmap90V.ZF, CreateDIBSectionGSAO6S

 

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

Brush

CreateBrushIndirectOJUPV1, CreateDIBPatternBrushYGBL.P, CreateDIBPatternBrushPt3IBLJFD, CreateHatchBrushYHBGVS, CreatePatternBrushBGUMRB, CreateSolidBrushA5QZ1V

Font

CreateFont3LH808_, CreateFontIndirectZY._9A

Pen

CreatePen10XG29A, CreatePenIndirect5F44_M_

Region

CombineRgnCYO37B, CreateEllipticRgn3ZUA_GU, CreateEllipticRgnIndirectXUX9YU, CreatePolygonRgn0KOG8Y, CreateRectRgn149ENQD, CreateRectRgnIndirectPN0VMO

 

Return Values

If the selected object is not a region and the function succeeds, the return value is the handle of the object being replaced. If the selected object is a region and the function succeeds, the return value is one of the following values:

Value

Meaning

SIMPLEREGION

Region consists of a single rectangle.

COMPLEXREGION

Region consists of more than one rectangle.

    NULLREGION

Region is empty.

 

If an error occurs and the selected object is not a region, the return value is NULL. Otherwise, it is GDI_ERROR.

Remarks

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.

See Also

CombineRgn, CreateBitmap, CreateBitmapIndirect, CreateBrushIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBPatternBrush, CreateEllipticRgn, CreateEllipticRgnIndirect, CreateFont, CreateFontIndirect, CreateHatchBrush, CreatePatternBrush, CreatePen, CreatePenIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect, CreateSolidBrush, SelectClipRgn, SelectPalette