WindowFromDC function (winuser.h)

The WindowFromDC function returns a handle to the window associated with the specified display device context (DC). Output functions that use the specified device context draw into this window.

Syntax

HWND WindowFromDC(
  [in] HDC hDC
);

Parameters

[in] hDC

Handle to the device context from which a handle to the associated window is to be retrieved.

Return value

The return value is a handle to the window associated with the specified DC. If no window is associated with the specified DC, the return value is NULL.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-draw-l1-1-1 (introduced in Windows 8.1)

See also

GetDC

GetDCEx

GetWindowDC

Painting and Drawing Functions

Painting and Drawing Overview