How can I get the results of SystemInformation.VirtualScreen
AND Screen.PrimaryScreen.Bounds
to work the same both inside and outside of Visual Studio for a WinForms application?
private void ShowScreenSize()
{
MessageBox.Show( SystemInformation.VirtualScreen.ToString() );
}
When I run the code above INSIDE Visual Studio it shows:{X=0,Y=0,Width=3840,Height=2160}
When I run the code above OUTSIDE Visual Studio it shows: {X=0,Y=0,Width=3072,Height=1728}
I also get the same value difference when using Screen.PrimaryScreen.Bounds
My OS is Windows 8.1 and my native monitor resolution is 3840x2160
Also, I notice UI scaling of the application is normal when run inside of Visual Studio, but is stretched slightly when outside. I'm guessing that Visual Studio prevents the built in Windows UI scaling as my system is configured for UI scaling one step larger than minimum. Might that be affecting the value of SystemInformation.VirtualScreen
?
My final goal is to capture the full desktop using Graphics.CopyFromScreen()
. I want to get the full rectangle that includes all monitors in the whole virtual desktop.