Hey guys. Main question - How do I center the GameWindow? I’ve looked online and I can only seem to find unrelated answers. When I run the program, I want the GameWindow to be in the center of the monitor. I looked up the GameWindow class for XNA and some other things too, but I can’t seem to find anything that alludes to changing the GameWindow position.
I know how to resize the GameWindow:
graphics.PreferredBackBufferWidth = screenWidth; // +Height
I also know how to offset the GameWindow relative to the System.Windows.Form:
// After adding references System.Windows.Forms and System.Drawing: var form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle); form.Location = new System.Drawing.Point(xOffset, yOffset);
Also, as a side question: How do I get the current screen resolution of the graphics card? I’ve been able to center my GameWindow the hard way using offset arithmetic, but that assumes that I know what the screen resolution is. I want my game to adjust itself to the end users screen resolution (when not in Full Screen mode, as I assume Full Screen mode does this automatically?).
Thanks for any help.