问题
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