WindowFromDC

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

HWND WindowFromDC(
  HDC hDC   // handle of window
);
 

Parameters

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

Return Values

The return value is the handle of the window associated with the given DC. If no window is associated with the given DC, the return value is NULL.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also

Painting and Drawing Overview, Painting and Drawing Functions, GetDC, GetDCEx, GetWindowDC