Ok…. quite simple you might think! And yes it is, but only if you know how!
For a small project that we are working on at the moment we needed to show a Windows Form in full screen mode without the taskbar etc… It is quite simple in the end but needs a couple of Win32Api calls, but that is simple enough. The one thing that is easy to forget is that you need to set the FormBorderStyle property for the form to None, otherwise you will still have the menu bar showing.
To acheive the full screen mode create a simple class with the code below in it
[DllImport(“user32.dll”, EntryPoint = “GetSystemMetrics”)]
public static extern int GetSystemMetrics(int which);
[DllImport(“user32.dll”)]
public static extern void SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int X, int Y, int width, int height, uint flags);
private const int SM_CXSCREEN = 0;
private const int SM_CYSCREEN = 1;
private static IntPtr HWND_TOP = IntPtr.Zero;
private const int SWP_SHOWWINDOW = 64;
public static int ScreenX
{
get { return GetSystemMetrics(SM_CXSCREEN); }
}
public static int ScreenY
{
get { return GetSystemMetrics(SM_CYSCREEN); }
}
public static void SetWindowFullScreen(IntPtr hwnd)
{
SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
}
Then in your application simply create a new instance of the form and call the Show method on the form.
Form form1 = new Form();
form1 .Show(this);
Then finally create an OnLoad handler for the form and call the SetWindowFullScreen method on our helper class and that is it.
WinApi.SetWindowFullScreen(Handle);