2

I'm trying to get current screen resolution using Screen.PrimaryScreen.Bounds. My screen resolution is 1920 X 1080 current, and its scale is 125%. I've used DPI settings (Screen.PrimaryScreen.Bounds.Height * (int)myForm.CreateGraphics().DpiY) / 96 and Screen.FromControl(myForm).WorkingArea.Height, but it returns the same value of Screen.PrimaryScreen.Bounds. How can I get the value 1980 X 1920, or get screen scale 125%? I think both ways are valid.

enter image description here

Siavash
  • 2,813
  • 4
  • 29
  • 42
Inkyu Lee
  • 67
  • 1
  • 1
  • 7
  • I've tried it, but it also returns the same value with ``(Screen.PrimaryScreen.Bounds.Height * (int)myForm.CreateGraphics().DpiY) / 96``. – Inkyu Lee Nov 06 '18 at 04:02
  • Posted a few days ago: [Using SetWindowPos with multiple monitors](https://stackoverflow.com/questions/53012896/c-sharp-user32-using-setwindowpos-with-multiple-monitors?answertab=active#tab-top). This answer supposes that your application is DPIAware. Is it? Otherwise, you'll always get a 96Dpi *virtualized* **Size** and **Resolution** (two different things). In case, see: [Configure an app to run correctly on a machine with a high DPI setting](https://stackoverflow.com/questions/13228185/how-to-configure-an-app-to-run-correctly-on-a-machine-with-a-high-dpi-setting-e?answertab=active#tab-top) – Jimi Nov 06 '18 at 04:35

1 Answers1

-2
foreach (var screen in System.Windows.Forms.Screen.AllScreens)
    {
       Console.WriteLine("Device Name: " + screen.DeviceName);
      Console.WriteLine("Bounds: " + 
            screen.Bounds.ToString());
        Console.WriteLine("Type: " + 
            screen.GetType().ToString());
        Console.WriteLine("Working Area: " + 
            screen.WorkingArea.ToString());
        Console.WriteLine("Primary Screen: " + 
            screen.Primary.ToString());
    }
Eranga Gamagedara
  • 536
  • 1
  • 3
  • 10