Iam looking for some hint or solution regarding following problem.
I have a .NET 2.0 WinForm dialog which operates in Dual Screen environment. The Working area is set by .NET Framework to reflect the Primary screen. I want to MAXIMIZE Form to BOTH screens but after clicking the "maximize button", dialog is maximized only to "active" screen (active I mean screen on which dialog is currently placed).
Iam not interested in bounds solution, this works, but when clicked Maximize button it forces the dialog back to one of 2 screens.
I would be gratefull for any help or hints.
this may be late, but here is an easy way to do it. It sets the size of the form from getting the size of resolution. then it places the form so it can be visible.
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
this.Size = new System.Drawing.Size(screenWidth, screenHeight);
this.Location = new System.Drawing.Point(screenLeft, screenTop);
Combine the 2 screen sizes and set your form to that resolution. Something like:
int height = 0;
int width = 0;
foreach (screen in System.Windows.Forms.Screen.AllScreens)
{
//take smallest height
height = (screen.Bounds.Height <= height) ? screen.Bounds.Height: height;
width += screen.Bounds.Width;
}
Form1.Size = new System.Drawing.Size(width, height);
To override the maximize button you can check via WndProc for the maximize event
const int WM_SYSCOMMAND= 0x0112;
const int SC_MAXIMIZE= 0xF030;
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSCOMMAND)
{
if((int)m.WParam==SC_MAXIMIZE)
{
MessageBox.Show("Maximized!!");
return;
}
}
base.WndProc (ref m);
}
or register to the Resize event of the form (you should check if it's resize or an maximize) (MSDN)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With