I have a WPF window which runs on multiple monitors having different resolutions. It'll be good but not required to be smart enough to change max height when I move the window from high-resolution monitor to low-resolution monitor or vice-versa.
Current requirement is simple enough to set the max height of my modal window based on my current monitor's height.
I have tested a few things like
Screen.PrimaryScreen.WorkingArea.Height
Screen.PrimaryScreen.WorkingArea.Width
But it gives the height of only primary screen of system where I need the height of screen where window currently resides.
Also a major concern in multiple monitors is the top property of windows, in high resolution monitors it is fine but in low-resolution or secondary monitors it starts from a different number like 160.
bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
IntPtr MonitorFromWindow(IntPtr handle, int flags);
andIntPtr MonitorFromPoint(POINT point, int flags);
from user32.dll – Pavel Anikhouski