Making It Fullscreen

I'm writing an application which runs automatically when Windows starts and I want make it fullscreen but without taskbar and Start button. I also want disable red button (x) for shutting form in upper right corner of the screen. Could somebody post source code in C# for this tasks. I'll be greatfull, because I'm not very experienced in C#.

Answer this question

Making It Fullscreen

  • scruzer

    In Form properties:

    FormBorderStyle = none



  • SoGa

    sure ...

    here`s your code.. for maximizing window

    private void Form1_Load(object sender, EventArgs e)
    {
    this.WindowState=FormWindowState.Maximized
    }

    and for the x button..
    i dont really know how to do that.. but you can cancel the x button operation..
    on the form1_closing event put this code
    e.Cancel


  • SteveOC

    using System.Runtime.InteropServices;

    namespace WindowsApplication1

    {

    public partial class Form1 : Form

    {

    private const int MF_BYPOSITION = 0x400;

    private const int MF_REMOVE = 0x1000;

    private const int MF_DISABLED = 0x2;

    [DllImport("user32.Dll")]

    public static extern IntPtr RemoveMenu(int hMenu, int nPosition, int wFlags);

    [DllImport("User32.Dll")]

    public static extern IntPtr GetSystemMenu(int hWnd, bool bRevert);

    [DllImport("User32.Dll")]

    public static extern IntPtr GetMenuItemCount(int hMenu);

    [DllImport("User32.Dll")]

    public static extern IntPtr DrawMenuBar(int hwnd);

    public Form1()

    {

    InitializeComponent();

    }

    private void Form1_Load(object sender, EventArgs e)

    {

    DisableCloseButton(this.Handle.ToInt32());

    }

    public void DisableCloseButton(int hWnd)

    {

    IntPtr hMenu;

    IntPtr menuItemCount;

    //Obtain the handle to the form's system menu

    hMenu = GetSystemMenu(hWnd, false);

    // Get the count of the items in the system menu

    menuItemCount = GetMenuItemCount(hMenu.ToInt32());

    // Remove the close menuitem

    RemoveMenu(hMenu.ToInt32(), menuItemCount.ToInt32() - 1, MF_DISABLED | MF_BYPOSITION);

    // Remove the Separator

    RemoveMenu(hMenu.ToInt32(), menuItemCount.ToInt32() - 2, MF_DISABLED | MF_BYPOSITION);

    // redraw the menu bar

    DrawMenuBar(hWnd);

    }

    }

    }



  • Jason Manfield

    i dont thinks he doesnt want the border .. he sad that he just want to unenable the x close button.. and the hole from boder..

    anyway


  • Making It Fullscreen