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.
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.
WinForm enter fullscreen mode
Run with full screen you can use this method..
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
To Hide TaskBar
Just add this class into your project .it works as you expected.
using System;
using System.Runtime.InteropServices;
public class Taskbar
{
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
[DllImport("user32.dll")]
public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle);
[DllImport("user32.dll")]
private static extern int GetDesktopWindow();
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
protected static int Handle
{
get
{
return FindWindow("Shell_TrayWnd", "");
}
}
protected static int HandleOfStartButton
{
get
{
int handleOfDesktop = GetDesktopWindow();
int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0);
return handleOfStartButton;
}
}
private Taskbar()
{
// hide ctor
}
public static void Show()
{
ShowWindow(Handle, SW_SHOW);
ShowWindow(HandleOfStartButton, SW_SHOW);
}
public static void Hide()
{
ShowWindow(Handle, SW_HIDE);
ShowWindow(HandleOfStartButton, SW_HIDE);
}
}
USAGE:
Taskbar.Hide();
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).
Full screen Windows Form goes beyond screen dimensions
Here is the code I use for fullscreen. I create a FullScreen
property for my form and when I need, I set this.FullScreen = true;
private bool fullScreen = false;
[DefaultValue(false)]
public bool FullScreen
{
get
{
return fullScreen;
}
set
{
fullScreen = value;
if (value)
{
//this.SuspendLayout();
this.WindowState = FormWindowState.Normal;
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
//this.ResumeLayout(true);
}
else
{
this.Activate();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
}
}
}
Related Topics
Difference Between Asynchronous Programming and Multithreading
How to Check For Internet Connectivity Using .Net
What's the Main Difference Between Int.Parse() and Convert.Toint32
Difference Between Covariance & Contra-Variance
C# Convert Int to String With Padding Zeros
What Is the Purpose of a Question Mark After a Value Type (For Example: Int? Myvariable)
How to Apply an Xslt Stylesheet in C#
Find Control by Name from Windows Forms Controls
Given a Filesystem Path, Is There a Shorter Way to Extract the Filename Without Its Extension
How to Get the Ip Address of the Server on Which My C# Application Is Running On
How to Divide Two Integers to Get a Double
Dpi Awareness - Unaware in One Release, System Aware in the Other