繁体   English   中英

Windows屏幕保护程序多监视器问题

[英]Windows Screensaver Multi Monitor Problem

我编写了一个简单的屏幕保护程序,该屏幕保护程序已部署到我们公司的所有客户端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;

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

高度也一样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM