User32GetWindowDC(IntPtr) Method

Retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars.

A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area.

GetWindowDC(IntPtr) assigns default attributes to the window device context each time it retrieves the device context. Previous attributes are lost.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", SetLastError = true)]
public static IntPtr GetWindowDC(
	IntPtr hWnd
)

Parameters

hWnd  IntPtr
A handle to the window with a device context that is to be retrieved. If this value is Zero, GetWindowDC(IntPtr) retrieves the device context for the entire screen of the primary display monitor.

To get the device context for other display monitors, use the EnumDisplayMonitors(IntPtr, IntPtr, DelegatesEnumMonitorProc, IntPtr) and CreateDC(String, String, String, IntPtr) functions.

Return Value

IntPtr
If the function succeeds, the return value is a handle to a device context for the specified window.

If the function fails, the return value is Zero, indicating an error or an invalid hWnd parameter.

Remarks

See Also