Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximized screen ignores taskbar

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).

like image 913
Jeff Avatar asked Jun 10 '09 12:06

Jeff


4 Answers

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.

like image 123
Luke Avatar answered Sep 23 '22 04:09

Luke


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.

like image 29
Jeff Avatar answered Sep 21 '22 04:09

Jeff


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?

like image 34
yinyueyouge Avatar answered Sep 22 '22 04:09

yinyueyouge


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)

like image 31
Thomas Levesque Avatar answered Sep 22 '22 04:09

Thomas Levesque