User32MonitorFromWindow(SafeHandle, MonitorFromFlags) Method

Retrieves a handle to the display monitor that has the largest area of intersection with the bounding rectangle of a specified window.

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 MonitorFromWindow(
	SafeHandle hWnd,
	MonitorFromFlags flags
)

Parameters

hWnd  SafeHandle
A handle to the window whose parent monitor handle is to be retrieved.
flags  MonitorFromFlags
Determines the function's return value if the window does not intersect any display monitor.

Return Value

IntPtr
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 flags parameters.

Remarks

See Also