Screen.PrimaryScreen.WorkingArea.Width获取的与实际电脑桌面不一致
时间: 2024-02-03 16:02:23 浏览: 177
如果使用Screen.PrimaryScreen.WorkingArea.Width获取的分辨率与实际电脑桌面不一致,可能是因为您的电脑设置了缩放比例,导致屏幕的分辨率与实际分辨率不一致。此外,如果您的电脑连接了多个显示器,那么获取到的分辨率可能是其中一个显示器的分辨率。
您可以尝试使用System.Windows.Forms.Screen类的AllScreens属性来获取所有的屏幕信息,然后分别获取它们的分辨率,示例代码如下:
```
using System.Windows.Forms;
...
// 获取所有屏幕分辨率
foreach (Screen screen in Screen.AllScreens)
{
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
Console.WriteLine("Screen Resolution: {0} x {1}", screenWidth, screenHeight);
}
```
这样可以获取所有显示器的分辨率信息,希望能够帮助到您。
相关问题
Screen.PrimaryScreen.Bounds.Width 获取的与实际电脑桌面不一致
如果使用Screen.PrimaryScreen.Bounds.Width获取的分辨率与实际电脑桌面不一致,可能是因为您的电脑设置了缩放比例,导致屏幕的分辨率与实际分辨率不一致。
在这种情况下,可以使用System.Windows.Forms.Screen类的WorkingArea属性,该属性获取的是除任务栏等系统元素外的工作区域大小,可以避免受到缩放比例的影响,示例代码如下:
```
using System.Windows.Forms;
...
// 获取当前屏幕工作区域分辨率
int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
// 输出屏幕分辨率
Console.WriteLine("Screen Resolution: {0} x {1}", screenWidth, screenHeight);
```
这样获取的分辨率就与实际电脑桌面一致了。希望能够帮助到您。
VB6.0中Screen.PrimaryScreen.WorkAreaLeft提示PrimaryScreen未找到方法
在VB6.0中,没有Screen.PrimaryScreen这个属性。相反,您可以使用Screen对象来获取屏幕的一些信息,例如工作区宽度、高度和左侧位置等。以下是获取工作区左侧位置的代码示例:
```
Dim leftPos As Long
leftPos = Screen.WorkAreaLeft
```
请注意,此代码将返回主显示器的工作区左侧位置。如果您有多个显示器,则需要使用Screen对象的其他属性来获取其他显示器的信息。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)