我有这个代码,让我的游戏窗口看起来最大化,任务栏可见,这正是我需要的。
protected override void Initialize()
{
IntPtr hWnd = this.Window.Handle;
var control = System.Windows.Forms.Control.FromHandle(hWnd);
var form = control.FindForm();
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.WindowState = System.Windows.Forms.FormWindowState.Normal;
form.Location = new System.Drawing.Point(0,-1); // doesnt seem to make any diffrence when X or Y = anything but 0
graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height-1;
graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
graphics.IsFullScreen = false;
graphics.ApplyChanges();
base.Initialize();
}
问题是我的游戏正上方有一个小的1像素间隙,我试图通过form.Location(0,-1)
提升游戏窗口来摆脱它,但它根本不会移动窗口。现在,如果我摆脱.CurrentDisplayMode.Height-1;
只是Height
,那么游戏会全屏隐藏任务栏!