c#屏幕边界不正确[重复]

问题描述 投票:1回答:2

我的屏幕尺寸有问题。我希望从Windows窗体程序中获取屏幕大小,但是当我这样做时:

Rectangle bounds = Screen.AllScreens[0].Bounds;

bounds.Width = 1536而不是1920(我的分辨率屏幕)。

请问你能帮帮我吗 ?

c# forms screen
2个回答
0
投票

也许试试这个:

Screen.PrimaryScreen.Bounds.Width;
Screen.PrimaryScreen.Bounds.Height;
Screen.PrimaryScreen.Bounds.Size;

也许你选错了显示器?因为Screen是用于获取屏幕res的主要lib。


0
投票
Rectangle resolution = Screen.PrimaryScreen.Bounds

这有帮助吗?您的代码为我返回正确的屏幕尺寸

int count = Screen.AllScreens.Count();
for (int itr = 0; itr < count; itr++) {
    Console.WriteLine("The width of screen {0} is {1}", itr, Screen.AllScreens[itr].Bounds.Width);
}

上面的代码将遍历您的所有监视器

© www.soinside.com 2019 - 2024. All rights reserved.