isWindowOnCurrentVirtualDesktop method

bool isWindowOnCurrentVirtualDesktop(
  1. HWND topLevelWindow
)

Indicates whether the provided window is on the currently active virtual desktop.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ivirtualdesktopmanager-iswindowoncurrentvirtualdesktop.

Implementation

bool isWindowOnCurrentVirtualDesktop(HWND topLevelWindow) {
  final onCurrentDesktop = adaptiveCalloc<Int32>();
  final hr$ = HRESULT(
    _IsWindowOnCurrentVirtualDesktopFn(ptr, topLevelWindow, onCurrentDesktop),
  );
  if (hr$.isError) {
    free(onCurrentDesktop);
    throw WindowsException(hr$);
  }
  final result$ = onCurrentDesktop.value;
  free(onCurrentDesktop);
  return result$ != FALSE;
}