9

How can I create a full screen C# Windows Forms application in Visual Studio Express 2010? I have tried this link, but it just shows http://pixpipeline.com/d/57a8554712e8.png

Dylan Corriveau
  • 2,561
  • 4
  • 29
  • 36
Hello all
  • 91
  • 1
  • 1
  • 4
  • 3
    possible duplicate of [How do I make a WinForms app go Full Screen](http://stackoverflow.com/questions/505167/how-do-i-make-a-winforms-app-go-full-screen) – H H Nov 12 '10 at 20:04

5 Answers5

14

No special tricks are necessary. Set the FormBorderStyle property to None, WindowState to Maximized.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • 3
    It bears mentioning, that no 'special tricks' are needed to hide the taskbar. Windows recognizes that windows created like this would like to be fullscreen, and puts them on top of the taskbar. – Nick Nov 12 '10 at 19:55
  • Except there is an issue, if you set your taskbar settings to "Always on top" it hides the app. If I'm understanding what the OP is asking for, he wants the window to be truly full screen... on top of everything and covering all the monitor real estate. – myermian Nov 12 '10 at 19:58
  • 1
    How do you set the taskbar to "always on top"? I don't find this option in Windows 7... – Lars Nov 12 '10 at 20:03
  • That feature has been removed in Windows 7, however in Windows XP it is still available under "Taskbar and Start Menu Properties". – myermian Nov 12 '10 at 20:08
12

http://www.vesic.org/english/blog/winforms/full-screen-maximize/
Example: http://www.vesic.org/blog/upload/MaxWinForm.zip

/// <summary>
/// Selected Win AI Function Calls
/// </summary>

public class WinApi
{
    [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; // 0x0040

    public static int ScreenX
    {
        get { return GetSystemMetrics(SM_CXSCREEN);}
    }

    public static int ScreenY
    {
        get { return GetSystemMetrics(SM_CYSCREEN);}
    }

    public static void SetWinFullScreen(IntPtr hwnd)
    {
        SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
    }
}

/// <summary>
/// Class used to preserve / restore state of the form
/// </summary>
public class FormState
{
    private FormWindowState winState;
    private FormBorderStyle brdStyle;
    private bool topMost;
    private Rectangle bounds;

    private bool IsMaximized = false;

    public void Maximize(Form targetForm)
    {
        if (!IsMaximized)
        {
            IsMaximized = true;
            Save(targetForm);
            targetForm.WindowState = FormWindowState.Maximized;
            targetForm.FormBorderStyle = FormBorderStyle.None;
            targetForm.TopMost = true;
            WinApi.SetWinFullScreen(targetForm.Handle);
        }
    }

    public void Save(Form targetForm)
    {
        winState = targetForm.WindowState;
        brdStyle = targetForm.FormBorderStyle;
        topMost = targetForm.TopMost;
        bounds = targetForm.Bounds;
    }

    public void Restore(Form targetForm)
    {
        targetForm.WindowState = winState;
        targetForm.FormBorderStyle = brdStyle;
        targetForm.TopMost = topMost;
        targetForm.Bounds = bounds;
        IsMaximized = false;
    }
}
myermian
  • 31,823
  • 24
  • 123
  • 215
4

Kiosk mode are the words you want to use for a search.

form.MaximizeBox = false;
form.MinimizeBox = false;
form.TopMost = true;
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.WindowState = System.Windows.Forms.FormWindowState.Maximized;
Lars
  • 6,421
  • 1
  • 23
  • 24
  • 6
    When 'BorderStyle' is set to 'None' there is no need to disable maximize and minimize boxes. When 'BorderStyle' is 'None' the entire window header is removed and that includes the minimize, maximize, and close boxes. – Gerald Davis Nov 12 '10 at 22:05
1

In properties of form set 'Window state' to 'Maximized' (https://i.stack.imgur.com/UfCvY.jpg)

0

For make a full screen application you have to do something like this...

this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;

this is the name of the form.

Brandon Aguilar
  • 389
  • 6
  • 14