Click to Rate and Give Feedback
MSDN
MSDN Library
GWES Reference
GDI Reference
GDI Functions
 SelectObject

  Switch on low bandwidth view
SelectObject
Windows Mobile SupportedWindows Embedded CE Supported
8/28/2008

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
); 
hdc

[in] Handle to the device context.

hgdiobj

[in] Handle to the object to be selected.

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

Object Functions

Bitmap

CreateBitmap, CreateCompatibleBitmap, CreateDIBSection

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

Brush

CreateDIBPatternBrushPt, CreatePatternBrush, CreateSolidBrush

Font

CreateFontIndirect

Pen

CreatePen, CreatePenIndirect

Region

CombineRgn, CreateRectRgn, CreateRectRgnIndirect

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.

Value Description

SIMPLEREGION

Region consists of a single rectangle.

COMPLEXREGION

Region consists of more than one rectangle.

NULLREGION

Region 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.

Headerwindows.h
Librarycoredll.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
If NULL is returned, should GetLastError be called to identify reason?      yazhang ... Thomas Lee   |   Edit   |   Show History

Please specify if GetLastError call is necessary or not.

[tfl - 13 04 09] You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or 
the MSDN Newsgroups at http://www.microsoft.com/communities/newsgroups/en-us/. You are much more likely get a
quicker response using the forums than through the Community Content.
For specific help about:
Visual Studio  : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.vstudio%2C&
.NET Framework : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.dotnet.framework
All Public     : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public%2C&
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker