I am working on a WPF/Winforms hybrid app. We have a winforms window where the user can choose which displays that this window will use, and then the window is positioned and scaled so that it takes up the entire display(s).
We have come across a weird issue with windows. We use the Screen.AllScreens
to get the bounds of the screens and these bounds are used to snap our window to the screen. However, we have found that when the scaling settings are different on different displays, then there are actual gaps between the displays.
For example, I have a 3 monitor system where monitor 3 is set to 100% and monitors 1 and 2 are set to 125%. The system dialog looks like this (no gaps).
We have an in-app visualization of what the Screen.AllScreens returns as the bounds for each monitor and here is what it looks like
And here is a printout of the screen coordinates for each monitor
\\.\DISPLAY1: {X=0,Y=0,Width=2048,Height=1536}
\\.\DISPLAY3: {X=-2400,Y=561,Width=2400,Height=1350}
\\.\DISPLAY2: {X=2560,Y=0,Width=2048,Height=1536}
Judging by the numbers, it looks like display 2's x coordinate is 2560 because it is trying to give room for display 1's 2048 width * 125% = 2560. However, it seems that this gap only exists in the bad coordinates as spanning a window across this gap does not hide part of the window. What's weirder, is the printout says that display 3's size is 2400x1350 which is 125% bigger than its actual size of 1920x1080.
So long story short, I know that Screen.AllScreens is a winforms call and perhaps a little outdated. Is there a better way to grab screen coordinates that wont be affected by scaling or am I just stuck to warning the user if I detect that there are gaps between the screens?