I am using C# to give an application ‘fullscreen mode’ using borderless form and maximise method.
This works perfectly when i am making the form borderless while it is not maximised – all you can see on the screen is the form, taskbar is covered.. However, if i maximise the form manually (user interaction), and then attempt to make it borderless & maximised, the task bar is drawn over the form (as i am not using WorkingArea, part of the controls on the form are hidden. It is the intended behaviour to NOT show the taskbar).
I tried setting the form’s property TopMost to true, but that doesn’t seem to have any effect.
Is there any way to rework this to always cover the taskbar?
if (this.FormBorderStyle != System.Windows.Forms.FormBorderStyle.None)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
else
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
}
if (this.WindowState != FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
if (this.FormBorderStyle == System.Windows.Forms.FormBorderStyle.Sizable) this.WindowState=FormWindowState.Normal;
}
The issue is that your window is already internally marked as being in the maximized state. So maximizing it again will not change the current size of the form. Which will leave the taskbar exposed. You’ll need to restore it first back to Normal, then back to Maximized. Yes, that flickers a bit.