MonitorFromWindow function (winuser.h)
The MonitorFromWindow function retrieves a handle to the display monitor that has the largest area of intersection with the bounding rectangle of a specified window.
HMONITOR MonitorFromWindow( HWND hwnd, DWORD dwFlags );
A handle to the window of interest.
Determines the function's return value if the window does not intersect any display monitor.
This parameter can be one of the following values.
||Returns a handle to the display monitor that is nearest to the window.|
||Returns a handle to the primary display monitor.|
If the window intersects one or more display monitor rectangles, the return value is an HMONITOR handle to the display monitor that has the largest area of intersection with the window.
If the window does not intersect a display monitor, the return value depends on the value of dwFlags.
If the window is currently minimized, MonitorFromWindow uses the rectangle of the window before it was minimized.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||winuser.h (include Windows.h)|
|API set||ext-ms-win-ntuser-sysparams-ext-l1-1-1 (introduced in Windows 10, version 10.0.14393)|