Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full screen C# Application

Tags:

c#

fullscreen

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

like image 917
Hello all Avatar asked Nov 12 '10 19:11

Hello all


People also ask

What is the full screen command?

Full Screen Keyboard Shortcut Windows 10 For most apps and games, you can use the standard Alt+Enter combination. Simply press and hold the two buttons simultaneously, and your app/game will automatically go full screen.

How do I get out of Turbo C++?

CTRL-Break, Break and CTRL-C didn't work for me, but CTRL-ESC-ESC did! (This was tested with almost identical code in Borland C++ 3.1). Save this answer.


3 Answers

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

like image 62
Hans Passant Avatar answered Sep 29 '22 20:09

Hans Passant


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

like image 26
Rana Nadeem Avatar answered Sep 29 '22 18:09

Rana Nadeem


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;
    }
}
like image 32
myermian Avatar answered Sep 29 '22 19:09

myermian