how to Hide XNA 4.0?

梦想与她 提交于 2019-12-10 20:09:21

问题


I'm Trying to hide my XNA game window but i don't seem to be able to here's what I've tried so far from what i could get off google.

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

I have also tried

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

I figure I'm doing something very simple wrong and once it's pointed out I'll probably laugh at how i didn't see it. Thanks for the help


回答1:


add the System.Windows.Form refrence to the project and then add the using statment:

using System.Windows.Forms;

and then add this in the Initialize method:

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

EDIT: mybee the playing with the opacity

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



回答2:


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

Here is a sample, which hides the window only the first time it is drawn.

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


来源:https://stackoverflow.com/questions/10539031/how-to-hide-xna-4-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!