I have an HWND window in my app, and I want to know the size of the monitor it's on. This will help me position my HWND on the monitor in some scenarios.
How can I get the resolution of the monitor for a given window/HWND in WinUI 3 and Win32 (in C++, preferrably)?
Once you have an HWND for your window (for example, see Retrieve a window handle (HWND) for WinUI 3, WPF, and WinForms), you can use Win32 functions for this:
If you're looking for usable space, you probably want the work area, and not the actual size of the monitor (
rcWork, notrcMonitor). See the Taskbar#Taskbar Display Options andMONITORINFO.See MonitorFromWindow and GetMonitorInfo.