在Winform中获得“实际”屏幕分辨率

时间:2018-11-06 03:49:32

标签: c# winforms screen-resolution dpi

我正在尝试使用Screen.PrimaryScreen.Bounds获得当前的屏幕分辨率。我的屏幕分辨率为1920 X 1080当前,其比例为125%。 我使用了DPI设置(Screen.PrimaryScreen.Bounds.Height * (int)myForm.CreateGraphics().DpiY) / 96Screen.FromControl(myForm).WorkingArea.Height,但是它返回的值是Screen.PrimaryScreen.Bounds。如何获得1980 X 1920的值或屏幕比例的125%?我认为这两种方法都是有效的。

enter image description here

1 个答案:

答案 0 :(得分:-1)

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());
    }