How to display a Windows Form in full screen on top of the taskbar?
My simple fix it turned out to be calling the form's Activate()
method, so there's no need to use TopMost
(which is what I was aiming at).
how to make a winform application fullscreen and cover taskbar
This goes full screen and over the taskbar for me
(also with AutoSize = true
and AutoSizeMode = AutoSizeMode.GrowAndShrink
)
public void fullScreenDisplay()
{
// This is required if the form reaches this code in maximized state
// otherwise the TaskBar remains on top of the form
this.WindowState = FormWindowState.Normal;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.mainPanel.Dock = DockStyle.Fill;
this.BringToFront();
}
In other words, don't try to set the dimensions neither for the form and for the panel if you want the get the default behavior. Instead force the Panel to Dock inside the full size of the form.
How to display a form in Full Screen with the taskbar on top of the form?
Set the maximum size of the form:
public Form1()
{
InitializeComponent();
this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
this.WindowState = FormWindowState.Maximized;
}
How do I make a WinForms app go Full Screen
To the base question, the following will do the trick (hiding the taskbar)
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
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.
full screen mode, but don't cover the taskbar
This is probably what you want. It creates a 'maximized' window without hiding the taskbar.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load( object sender, EventArgs e )
{
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Left = Top = 0;
Width = Screen.PrimaryScreen.WorkingArea.Width;
Height = Screen.PrimaryScreen.WorkingArea.Height;
}
}
How to run winform with showing taskbar?
Setting a Forms WindowState
to Maximized when your BorderStyle
is none will always lay over the taskbar. This is a typical behaviour of a "Fullscreen" application.
However you are on the right track. If you want to have a semi-fullscreen experience without laying over the taskbar you have to set the Location and Size of your Form manually.
Important here is that you not only set these values manually but also take away control from the OS itself as it will always try to position a Form by some ruleset.
private void Form1_Load(object sender, EventArgs e)
{
//Hiding the Border to simulate a fullscreen-experience
this.FormBorderStyle = FormBorderStyle.None;
//Telling the operating system that we want to set the start position manually
this.StartPosition = FormStartPosition.Manual;
//Actually setting our Width, Height, and Location
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
this.Width = Screen.PrimaryScreen.WorkingArea.Width;
this.Location = Screen.PrimaryScreen.WorkingArea.Location;
}
Just a little side node: You might want to think about people with multiple screens and on which screen your application should appear (maybe let the user decide by some setting etc).
Menu out of place when application is in full screen by Windows API
This problem is caused by having the task bar set to the top of the screen.
It can be resolved by either moving the task bar to the bottom of the screen, or by enabling the Auto-hide task bar
check box in the Properties
window of the task bar.
EDIT: As stated by @slashp
's comments. The root cause of this issue comes from some inner mechanics in drawing the menu. The menu has a safety to be always drawn within the working area. Which seems to be your screen - task bar
. Because the application is placed over the task bar, the calculation is placing the menu below the task bar. (you can't see it, but it's still there)
Related Topics
Looking for a Command Line Argument Parser for .Net
Find the Next Tcp Port in .Net
Calling a Method in Parent Page from User Control
Find Methods That Have Custom Attribute Using Reflection
When Using a Settings.Settings File in .Net, Where Is the Config Actually Stored
Read Appsettings JSON Values in .Net Core Test Project
Cssrewriteurltransform with or Without Virtual Directory
Convert an Object to an Xml String
How to Do Logging in C# Without Using 3Rd Party Libraries
Spinwait VS Sleep Waiting. Which One to Use
Best Way to Handle Integer Overflow in C#
In C# What Does 'Where T:Class' Mean
How to Implement Solid Principles into an Existing Project
Convert Transparent Png to Jpg with Non-Black Background Color
Ef Data Context - Async/Await & Multithreading