I have a form I set to Maximized, but for some reason it's ignoring the taskbar and maximizing to the entire screen. Is that typical? Is there a workaround?
I'm running Windows XP with a dual monitor setup (taskbar in the first/primary window).
If you are using FormBorderStyle.None then it is very simple to make sure it doesn't cover the taskbar when maximized:
this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
It will probably work for other border styles and is probably the cleanest way to ensure your form does not cover the taskbar.
One thing I left out of the description--I'd turned off the maximize button. When I tested turning that property back on, the task bar showed up again. Apparently it assumes if you don't want a maximize button you are creating a kiosk-style application where you don't want your users to see anything but the application screen. Not exactly what I'd expect, but works I guess.
Set the form border to None before making it maximized.
This code will work in a single monitor:
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
I haven't tested the dual monitor scenario since i don't have this at this moment. :P
EDIT: I didn't get it "Maximized Screen Ignores Taskbar". What does Ignores mean?
Do you want your form to cover the taskbar and fill the entire screen?
If you don't want to re-enable the maximize button, you could manually set the size of the window :
private void Maximize()
{
Screen screen = Screen.FromPoint(this.Location);
this.Size = screen.WorkingArea.Size;
this.Location = Point.Empty;
}
(WorkingArea is the area of the screen that can be used by applications, excluding the TaskBar and other toolbars)
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