How to hide XNA 4.0?

I am trying to hide my XNA game window, but it seems I can not find what I have tried so far from what I could disconnect from Google.

        Form frmXNA = (Form)Form.FromHandle(this.Window.Handle);
        frmXNA.Hide();

I also tried

        Form frmXNA = (Form)Form.FromHandle(this.Window.Handle);
        frmXNA.Visible = false;

I believe that I am doing something very simple, and once he indicated that I would probably laugh at how I had not seen it. thanks for the help

+3
source share
2 answers

add the System.Windows.Form redirect to the project, and then add the entry used:

using System.Windows.Forms;

and then add this to the Initialize method:

Form MyGameForm = (Form)Form.FromHandle(Window.Handle);
            MyGameForm.FormBorderStyle = FormBorderStyle.None;

EDIT: mybee game with opacity

 Form MyGameForm = (Form)Form.FromHandle(Window.Handle);
        MyGameForm.Opacity = 0;
+3
source

You can use the function form.Hide(), you just need to call it after the form window is shown.

Here is an example that hides a window only the first time it is drawn.

Form window = (Form)Form.FromHandle(Window.Handle);
window.Shown += (e, s) => window.Hide();
+1
source

All Articles