views:

510

answers:

5

I have a form I set to Maximize, but for some reason it's ignoring the taskbar and maximizing to the entire screen. Is that typical? Is there a work around?

I'm running windows XP with a dual monitor setup (taskbar in the first/primary window).

+1  A: 

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?

yinyueyouge
He means that his form covers the whole screen, even hiding the taskbar which he doesn't want.
tomlog
To add to that, he should check the FormBorderStyle property of his form and make sure it's NOT set to FormBorderStyle.None.
tomlog
+3  A: 

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.

Jeff
A: 

Is ShowInTaskbar property set to False?

Shoban
+1  A: 

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)

Thomas Levesque
+1  A: 

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.

Luke