Windows Screensaver Multi Monitor Problem
Posted
by Bryan
on Stack Overflow
See other posts from Stack Overflow
or by Bryan
Published on 2009-12-18T20:16:11Z
Indexed on
2010/06/11
1:12 UTC
Read the original article
Hit count: 354
I have a simple screensaver that I've written, which has been deployed to all of our company's client PCs.
As most of our PCs have dual monitors, I took care to ensure that the screensaver ran on both displays.
This works fine, however on some systems, where the primary screen has been swapped (to the left monitor), the screensaver only works on the left (primary) screen.
The offending code is below. Can anyone see anything I've done wrong, or a better way of handling this?
For info, the context of "this", is the screensaver form itself.
// 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;
© Stack Overflow or respective owner