I want to make the XNA game window be in "windowed" mode but "always on top", is there a way to do this?
http://www.pinvoke.net/default.aspx/user32/SetWindowPos.html
Include the values from the sample Page in a WinApi class and call this function from your game class:
WinApi.SetWindowPos(this.Window.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
That should do it.
Thanks for your response, the code from that webpage wouldn't compile for me, however it did point me in the right direction, this is the code I am using (using XNA 3.1)
First, within the same namespace as the game copy and paste in this code
class User32
{
[DllImport("user32.dll")]
public static extern void SetWindowPos(uint Hwnd, int Level, int X, int Y, int W, int H, uint Flags);
}
I just wrote it above my main "Game" class, since I only use it within my Game class.
Then within the LoadContent() of the game class (MUST be within the LoadContent() method, doesn't work properly anywhere else), write this somewhere...
User32.SetWindowPos((uint)this.Window.Handle, -1, 0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);
note: "graphics" is the instance of GraphicsDeviceManager that is premade for you whenever you start your project.
This can also be used to position the game window wherever you want on the screen. For me I wanted it in the top left corner of the screen.
The easiest way is to set the graphics device to display full screen. Place the following code in your main game method:
this.graphics.IsFullScreen = true;