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).
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).
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.
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.
Screen.FromControl(this)
instead of Screen.PrimaryScreen
. If the user has multiple screens, your control won't necessarily be on the primary screen. –
Roadability MaximumSize
in form OnMove
event you'll end up with a form that is constrained to the screen's width in non-maximized mode (this isn't the default behavior). –
Porterporterage 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)
Maximize()
method –
Porterporterage 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.
I had this problem and solved it by Jeff's help. First, set the windowstate to Maximized. but Do not disable the MaximizeBox. Then if you want MaximizeBox to be disabled you should do it programmatically:
private void frmMain_Load(object sender, EventArgs e)
{
this.MaximizeBox = false;
}
Taskbar can be docked at left, top, bottom, right side. If you want maximized window without overlayed taskbar, use this code:
...cut... public partial class Form2 : Form { public Form2() { // set default start position to manual this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; // set position and size to the Form. this.Bounds = Screen.PrimaryScreen.WorkingArea; .... InitializeComponent(); } ...cut...
When you set the form border style to none the form will hide the taskbar. To get around this you have to set the the MaximumSize of the form manually. If windows auto-hides the taskbar the form will cover even the hidden taskbar! To get around this reduce the max size height by one pixel (if your taskbar is in the bottom)!
Me.MaximumSize = New Size(My.Computer.Screen.WorkingArea.Size.Width, _
My.Computer.Screen.WorkingArea.Size.Height - 1)
What I did is the following:
In constructor of the form, wrote the following:
this.Bounds = Screen.PrimaryScreen.WorkingArea;
© 2022 - 2024 — McMap. All rights reserved.