I'm trying to open a form in front of my game, which is full-screen. However, the form seems to appear only behind the game window.

At the moment, I'm doing this:

protected override void Update(GameTime gameTime)
            graphics.IsFullScreen = true;
            new Form1().Show();
            // The form is empty, just created. 

I can reach the form with AltTab, but this is unfriendly to the user.

How can I do this correctly?

  • \$\begingroup\$ How are you exactly using forms with xna? You need to give more information or else this question is getting closed. As it is now, its impossible to give answer. \$\endgroup\$
    – Katu
    Dec 10, 2015 at 10:13
  • \$\begingroup\$ Well, upgraded. \$\endgroup\$
    – cat
    Dec 10, 2015 at 10:38
  • \$\begingroup\$ Forms are not supported in XNA. You can render XNA into a form control, however, that is also not supported and is pretty hackish. Going into full screen and still displaying the form? No that will not work. \$\endgroup\$
    – jgallant
    Dec 10, 2015 at 11:43
  • \$\begingroup\$ well it was last chance, huh, drawed forms some difficult but if i need it i'll gotta do it. Thank you, so. \$\endgroup\$
    – cat
    Dec 10, 2015 at 11:47
  • 1
    \$\begingroup\$ Check out.. xnacontrols.codeplex.com \$\endgroup\$
    – jgallant
    Dec 10, 2015 at 11:48

3 Answers 3


Here is the solution for you: (which I use myself)

Form form = new Form();

form.SetBounds(100, 100, 800, 600);
form.TopMost = true;
form.Text = "Title";

form.Show(); //You can access to parent form.
form.ShowDialog(); //You can't access to parent form.


This is my method, which I use to make my game fullscreen. I find this method better than graphics.IsFullScreen.

[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(String className, String windowName);

[DllImport("user32.dll", SetLastError = true)]
static extern void SwitchToThisWindow(IntPtr hWnd, bool turnOn);

System.Windows.Form gameForm;

protected override void Initialize()
    /* ------ OPTIONAL ------ */
    graphics.PreferredBackBufferWidth = 1280;
    graphics.PreferredBackBufferHeight = 720;
    graphics.PreferMultiSampling = false;
    /* ---------------------- */

    gameForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle);
    gameForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    //gameForm.TopMost = true;
    gameForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
    gameForm.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
    gameForm.GotFocus += new EventHandler(gameForm_GotFocus);

void gameForm_GotFocus(object sender, EventArgs e)
    gameForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
    gameForm.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;

protected override void LoadContent()
    SwitchToThisWindow(gameForm.Handle, true);
  • \$\begingroup\$ It doesn't hide XNA form \$\endgroup\$ Dec 10, 2015 at 14:58
  • \$\begingroup\$ well i was tested wrong code. This one seems working normally. You're the best. \$\endgroup\$
    – cat
    Dec 10, 2015 at 15:00
  • \$\begingroup\$ It should be noted that the technique described here for full screen is commonly referred to as "Windowed Fullscreen", and can cause worsened performance in some cases. Just something to keep in mind. \$\endgroup\$
    – JonBee
    Dec 14, 2015 at 16:30

you need real full-screen? many games have 3 options:

  1. windowed
  2. fullscreen
  3. fullscreen-windowed

the last is very simple, just create a winforms window without border and stretch it to the whole size of the screen.


WinForms are not supported in XNA. You can render XNA into a form control, however, that is also not supported, however it can work.

The better option, is to use a library that provides form controls from inside of XNA. Check out http://www.xnacontrols.codeplex.com

Or you can always write your own.

  • \$\begingroup\$ Not Supported ???? \$\endgroup\$ Dec 10, 2015 at 14:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .