The question is simple: is there a way to expand a single form to all connected screens?
-
What do you mean by `expand`? – Oded Sep 28 '10 at 19:32
-
1do you mean this.WindowState = FormWindowState.Maximized; ? – bevacqua Sep 28 '10 at 19:33
-
What do you want to happen if the total connected area is not rectangular? – Mark Byers Sep 28 '10 at 19:33
-
I mean to show it on all screens, so user can click anywhere for me to detect coordinates. – SharpAffair Sep 28 '10 at 19:33
-
FormWindowState.Maximized doesn't seem to work, it only expands to one display. – SharpAffair Sep 28 '10 at 19:34
2 Answers
No, unless you are going to code in a reasonably low-level language, such as C and grab access to graphics memory.
Generally it's the operating system that performs the layout for you, so unless you have low-level access, or API published by the vendor, it would be quite hard I guess.

- 1,141
- 5
- 16
-
Okay then, if that's not possible, then is there a way to select in which screen the form will appear? – SharpAffair Sep 28 '10 at 19:57
-
1I suppose if you first hide your Form, grab Graphics object of your form, and direct it to draw itself anywhere in the joint x-y space of the two monitors, that could work. For example, I suppose that drawing it in the coordinates of (0.75*Xmax, 0.75*Ymax) would draw your Form in the middle of the second display. Hope this helps. – Jas Sep 29 '10 at 09:04
Yes, all of the screens make up a giant virtual surface upon which you can place your form. You need to merely set the form's location to the top-left of this surface and its size to the size of this surface.
You can find the extent of this surface with the following code:
private static Rectangle GetVirtualDisplayBounds()
{
Screen[] allScreens = Screen.AllScreens;
Point topLeft = allScreens[0].Bounds.Location;
Point bottomRight = topLeft + allScreens[0].Bounds.Size;
foreach (Screen screen in allScreens.Skip(1))
{
topLeft = new Point(Math.Min(topLeft.X, screen.Bounds.X),
Math.Min(topLeft.Y, screen.Bounds.Y));
bottomRight = new Point(Math.Max(bottomRight.X, screen.Bounds.Right),
Math.Max(bottomRight.Y, screen.Bounds.Bottom));
}
return new Rectangle(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y);
}
Then you can size your form appropriately:
var bounds = GetVirtualDisplayBounds();
form.Location = bounds.Location;
form.Size = bounds.Size;
You may also want to disable form borders:
form.FormBorderStyle = FormBorderStyle.None;
I have noticed though, that when you show your form it will pop back to a location of 0,0, which means that if you have any monitors positioned above or to the left of this point they will not be covered. To solve this you need to set the location after the form is shown.

- 37,459
- 12
- 63
- 82