Screen.PrimaryScreen.WorkingArea is not giving full screen?

Sean Huang 1 Reputation point
2020-06-17T08:42:17.137+00:00

I am trying to make an Windows form app that will auto scale to full screen. The problem is that I do not want to make it full screen if it is less than 1680x1050. So I tried to use Screen.PrimaryScreen.WorkingArea.Width / Height to get the resolution.

But although I am using a 1440p monitor, the returned value by the code :

if (!(size.Width >= 1680 && size.Height >= 1050))
            {
  Console.WriteLine((int)(size.Width));
  Console.WriteLine(size.Height);
  size.Width = 800;
  size.Height = 600;
  Console.WriteLine("the reso is too small");
            }

are:
960
1707
the reso is too small

Is this how the WorkingArea should be located, at some centralized area instead of the full screen?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,686 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. DaisyTian-1203 11,616 Reputation points
    2020-06-19T01:47:46.99+00:00

    The property "WorkingArea" is used to get the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars. If you want to get the resolution, you can use property "Bounds".

    int SH = Screen.PrimaryScreen.Bounds.Height;
    int SW = Screen.PrimaryScreen.Bounds.Width;