CreateCompatibleDC (gdi32)
Last changed: -74.212.46.220

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

C# Signature:

[DllImport("gdi32.dll", SetLastError=true)]
static extern IntPtr CreateCompatibleDC(IntPtr hdc);

VB.Net Signature:

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

OR

<DllImport("GDI32.dll", EntryPoint:="CreateCompatibleDC", _
                        SetLastError:=True, _
                        CharSet:=CharSet.Unicode, _
                        ExactSpelling:=True, _
                        CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CreateCompatibleDC(ByVal hRefDC As IntPtr) As IntPtr
End Function

Parameters:

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