Reputation: 207
I'm trying to create a borderless form with custom close and minimize button. However it seems that when setting the border to none and window state to maximized will cause the form to hide the taskbar which is not what I want. Note that I'm using windows 7, I've read a couple of answers here and elsewhere nothing seems to work for me, the taskbar is always getting hidden. A couple of things tried out with no luck are listed below:
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.None;
this.TopMost = true;
Screen screen = Screen.FromPoint(this.Location);
this.Size = screen.WorkingArea.Size;
this.Location = Point.Empty;
this.Bounds = Screen.PrimaryScreen.WorkingArea;
Upvotes: 2
Views: 6691
Reputation: 1
Just set start position to manual and also property MaximizeBox to true. when form is loaded and maximized by clicking maximized button you can have task bar!
Upvotes: 0
Reputation: 71
I guess this is what you are looking for
this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
Upvotes: 7
Reputation: 11
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)
Upvotes: 1
Reputation: 1821
This seems to be the behaviour you're telling the form to exhibit - if you tell it to be topmost and set the bounds explicitly to the whole screen it will cover the task bar. (This is often done in POS and touchscreen applications)
Try just setting FormWindowState.Maximized and not telling the bounds to fill the whole screen.
Upvotes: 0
Reputation: 3063
Here is the simplest solution:
this.Width = Screen.PrimaryScreen.Bounds.Width;
this.Height = Screen.PrimaryScreen.Bounds.Height - 40;
this.Location = new Point();
this.StartPosition = FormStartPosition.Manual;
In this example, I suppose that taskbar is visible, and that taskbar is positioned at bottom. You can read this question/answers How can I determine programmatically whether the Windows taskbar is hidden or not? in order to extend my example with automatic detection of taskbar status.
And here is example how to determine taskbar size: How do I get the taskbar's position and size?.
At my resolution, taskbar size is 40.
Upvotes: 1