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

CreateCompatibleDC (gdi32)
 
.
Summary
The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.

C# Signature:

/// <summary>
///        Creates a memory device context (DC) compatible with the specified device.
/// </summary>
/// <param name="hdc">A handle to an existing DC. If this handle is NULL,
///        the function creates a memory DC compatible with the application's current screen.</param>
/// <returns>
///        If the function succeeds, the return value is the handle to a memory DC.
///        If the function fails, the return value is <see cref="System.IntPtr.Zero"/>.
/// </returns>
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC", SetLastError=true)]
static extern IntPtr CreateCompatibleDC([In] IntPtr hdc);
[DllImport("gdi32.dll", SetLastError=true)]
static extern IntPtr CreateCompatibleDC(IntPtr hdc);

VB.NET Signature:

<DllImport("gdi32.dll", SetLastError:=True)> _
Private Shared Function CreateCompatibleDC(ByVal hRefDC As IntPtr) As IntPtr
End Function

VB Signature:

Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (hdc As IntPtr) As IntPtr

Parameters:

hdc Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen.

hdc in Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen.

Return Values:

If the function succeeds, the return value is the handle to a memory DC. If the function fails, the return value is NULL.

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

If you pass NULL, or zero, to this function you'll get the screen device context.

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