Sintrigue Sintrigue
Sintrigue Sintrigue

Reputation: 41

One form on dual monitors, full screen

I'm in the process of making a screensaver for a non-profit business. I have everything done and working except the main desk uses dual monitors, and the Windows form won't display on both monitors. My code is below (the correct dual monitor resolution is detected). The form size reports correctly for dual monitors - but the actual form doesn't display as extended on the second monitor.

My code below is in the Form_Load event. Any help in getting this to work right would be appreciated.

Screen[] monitors = Screen.AllScreens;

foreach (Screen screen in monitors)
{
    totalwidth += screen.WorkingArea.Width;
}

this.Size = new Size(totalwidth, ClientSize.Height);

Upvotes: 1

Views: 209

Answers (1)

TheGeneral
TheGeneral

Reputation: 81493

You need to do more than what you have.

In essence you will have to create a new form for each screen

Program

for (int i = Screen.AllScreens.GetLowerBound(0);  
     i <= Screen.AllScreens.GetUpperBound(0); i++)
       System.Windows.Forms.Application.Run(new frmScreenSaver(i));

Example form constructor

public frmScreenSaver(int scrn)
{
  ...
  ScreenNumber = scrn;
  ...
}

Example form OnLoad event

private void frmScreenSaver_Load(object sender, System.EventArgs e)
{
  ...
  // fit the screen
  Bounds = Screen.AllScreens[ScreenNumber].Bounds;
  // hide the cursor... seems appropriate
  Cursor.Hide(); 
  // make it TopMost
  TopMost = true;
  ...
}

There are more caveats with screen savers, however this should point you in the right direction

also, you could probably just pass in the bounds, instead of the index

Upvotes: 1

Related Questions