I have a WinForms app that I am trying to make full screen (somewhat like what VS does in full screen mode).
Currently I am setting FormBorderStyle
to None
and WindowState
to Maximized
which gives me a little more space, but it doesn't cover over the taskbar if it is visible.
What do I need to do to use that space as well?
For bonus points, is there something I can do to make my MenuStrip
autohide to give up that space as well?
I recently made an Mediaplayer application and I used API-calls to make sure the taskbar was hidden when the program was running fullscreen and then restored the taskbar when the program was not in fullscreen or not had focus or was exited.
And for the menustrip-question, try set
when in fullscreen mode, it should then disapear.
And when exiting fullscreenmode, reset the
menustrip1.parent
to the form again and the menustrip will be normal again.I don't know if it will work on .NET 2.0, but it worked me on .NET 4.5.2. Here is the code:
Usage:
To the base question, the following will do the trick (hiding the taskbar)
But, interestingly, if you swap those last two lines the Taskbar remains visible. I think the sequence of these actions will be hard to control with the properties window.
A tested and simple solution
I've been looking for an answer for this question in SO and some other sites, but one gave an answer was very complex to me and some others answers simply doesn't work correctly, so after a lot code testing I solved this puzzle.
Note: I'm using Windows 8 and my taskbar isn't on auto-hide mode.
I discovered that setting the WindowState to Normal before performing any modifications will stop the error with the not covered taskbar.
The code
I created this class that have two methods, the first enters in the "full screen mode" and the second leaves the "full screen mode". So you just need to create an object of this class and pass the Form you want to set full screen as an argument to the EnterFullScreenMode method or to the LeaveFullScreenMode method:
Usage example
I have placed this same answer on another question that I'm not sure if is a duplicate or not of this one. (Link to the other question: How to display a Windows Form in full screen on top of the taskbar?)
You can use the following code to fit your system screen and task bar is visible.
No need to use:
That line interferes with
alt+tab
to switch to other application. ("TopMost" means the window stays on top of other windows, unless they are also marked "TopMost".)