Search code examples
c#xnafullscreenaerowindowed

XNA losing title bar theme on fullscreen->windowed transition


(I think Aero is the term).

When I start my XNA program in Windowed mode, I have the glossy bar as seen on Win7/Vista programs.

When I set to fullscreen and then revert, I will have a plain blue 'basic' title border.

How can I set the theme or style of this back to the Aero style?


Solution

  • If you call the following before switching back to windowed mode, you will get the Aero style, but it requires you reference System.Windows.Forms.

    System.Windows.Forms.Application.EnableVisualStyles();
    

    I'm not certain if that's the best way to do it, but it works. I've used it in my XNA games.

    As an example you can hang it off your Game class:

    public class FooGame : Game
    {
        ... 
    
        private void SetWindow(bool fullscreen)
        {
            if(!fullscreen)
            {
                System.Windows.Forms.Application.EnableVisualStyles();
            }
    
            this.graphicsDeviceManager.IsFullScreen = fullscreen;
            this.graphicsDeviceManager.ApplyChanges();
        }
    }
    

    Good luck.