Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SelectObject (gdi32)
 
.
Summary
Selects an object into the specified device context (DC). The new object replaces the previous object of the same type.

C# Signature:

/// <summary>Selects an object into the specified device context (DC). The new object replaces the previous object of the same type.</summary>
/// <summary>
/// Selects an object into the specified device context (DC). The new object replaces the previous object of the same type.
/// </summary>
/// <param name="hdc">A handle to the DC.</param>
/// <param name="hgdiobj">A handle to the object to be selected.</param>
/// <param name="hgdiobj">A handle to the object to be selected. The specified object must have been created by using one of the following functions.</param>
/// <returns>
///   <para>If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced. If the selected object is a region and the function succeeds, the return value is one of the following values.</para>
///   <para>SIMPLEREGION - Region consists of a single rectangle.</para>
///   <para>COMPLEXREGION - Region consists of more than one rectangle.</para>
///   <para>NULLREGION - Region is empty.</para>
///   <para>If an error occurs and the selected object is not a region, the return value is <c>NULL</c>. Otherwise, it is <c>HGDI_ERROR</c>.</para>
///        <para>If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced.
///        If the selected object is a region and the function succeeds, the return value is one of the values of RegionFlags".</para>
///        <para>If an error occurs and the selected object is not a region, the return value is <see cref="System.IntPtr.Zero"/>. Otherwise, it is HGDI_ERROR.</para>
/// </returns>
/// <remarks>
///   <para>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.</para>
///   <para>An application cannot select a single bitmap into more than one DC at a time.</para>
///   <para>ICM: If the object being selected is a brush or a pen, color management is performed.</para>
/// </remarks>
[DllImport("gdi32.dll", EntryPoint = "SelectObject")]
public static extern IntPtr SelectObject([In] IntPtr hdc, [In] IntPtr hgdiobj);
[DllImport("gdi32.dll", EntryPoint = "SelectObject", SetLastError=true)]
static extern IntPtr SelectObject([In] IntPtr hdc, [In] IntPtr hgdiobj);

VB.NET Signature:

<DllImport("Gdi32.dll")> _
Public Shared Function SelectObject(ByVal hdc As IntPtr, ByVal hObject As IntPtr) As IntPtr
End Function

VB Signature

Public Declare Function SelectObject Lib "gdi32.dll" _
          (ByVal prmlngHDc As Long, _
           ByVal hObject As Long) As Long

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please see BitBlt

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions