interop::GetMonitorFromDisplayId function (microsoft.ui.interop.h)

Gets the HMONITOR that corresponds to the specified DisplayId, if the displayId argument is valid and the system has an HMONITOR that represents the display monitor.

Note

The microsoft.ui.interop.h header has a dependency on microsoft.ui.h, which is not shipped as part of the Windows App SDK. You can run the MIDL compiler (midl.exe) on Microsoft.UI.idl in order to generate microsoft.ui.h. Or just use the functions in the winrt/Microsoft.ui.interop.h header instead.

C#. For C# desktop application developers, the interop functions in this header are wrapped by the methods of the Microsoft.UI.Win32Interop class.

Syntax

HRESULT GetMonitorFromDisplayId(
  ::ABI::Microsoft::UI::DisplayId displayId,
  HMONITOR                        *hmonitor
) noexcept;

Parameters

displayId

Type: DisplayId

The identifier for the display.

hmonitor

Type: HMONITOR

The display monitor handle that corresponds to displayId, if displayId is valid and the system has an HMONITOR that represents the display monitor. Otherwise, null.

Return value

Type: HRESULT

Returns S_OK if the function succeeds. Otherwise, returns a value that indicates the error.

Requirements

Requirement Value
Minimum supported client Windows 10, version 1809 (with Windows App SDK 1.0 or later)
Header microsoft.ui.interop.h

See also

Manage app windows