【问题标题】:Windows Screensaver Multi Monitor ProblemWindows 屏幕保护程序多显示器问题
【发布时间】:2009-12-18 20:16:11
【问题描述】:

我编写了一个简单的屏幕保护程序,已部署到我们公司的所有客户端 PC。

由于我们的大多数 PC 都有双显示器,因此我注意确保屏幕保护程序在两个显示器上都运行。

这可以正常工作,但是在某些系统上,主屏幕已被交换(到左显示器),屏幕保护程序仅在左(主)屏幕上工作。

有问题的代码如下。谁能看到我做错了什么,或者更好的处理方法?

对于信息,“this”的上下文是屏幕保护程序表单本身。

// Make form full screen and on top of all other forms

int minY = 0;
int maxY = 0;
int maxX = 0;
int minX = 0;

foreach (Screen screen in Screen.AllScreens)
{
    // Find the bounds of all screens attached to the system

    if (screen.Bounds.Left < minX)
        minX = screen.Bounds.Left;

    if (screen.Bounds.Width > maxX)
        maxX = screen.Bounds.Width;

    if (screen.Bounds.Bottom < minY)
        minY = screen.Bounds.Bottom;

    if (screen.Bounds.Height > maxY)
        maxY = screen.Bounds.Height;
}

// Set the location and size of the form, so that it
// fills the bounds of all screens attached to the system

Location = new Point(minX, minY);
Height = maxY - minY;
Width = maxX - minX;
Cursor.Hide();
TopMost = true;

【问题讨论】:

    标签: c# winforms screensaver multiple-monitors


    【解决方案1】:

    您想检查screen.Bounds.Right 而不是screen.Bounds.Width

    身高也是如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-18
      • 1970-01-01
      • 2015-08-29
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多