Game Development Community

How to change window position?

by Chris Kim · in Torque X 2D · 06/13/2007 (8:02 am) · 3 replies

I need to create two windows for network setup and want to create in a position that they don't overlap.
It's little tidious to move it by hand.
To fix this, I would like to create them in a position I want.
I've looked at XNA.Framework.GameWindow and there is ClientBounds property but it's read-only.
How would I change the position of the window?
Thanks.

#1
06/13/2007 (5:45 pm)
The property you want is the window handle. With that you can use the windows api to get or set the position of the window (however you do that in .net).

You can get the window handle like so:
using GarageGames.Torque.XNA;
...

// get the window handle
IntPtr handle = TorqueEngineComponent.Instance.Game.Window.Handle;

// blah blah system calls to set the window position
.....

Hope this helps.
#2
06/16/2007 (11:02 am)
It should be fairly easy to call win32 API but it seems to require the following declarations.
Is this true? I thought you would be simply be able to call Win32 API in C#, no?

[System.Runtime.InteropServices.DllImport("USER32.dll")]

public static extern bool MoveWindow(IntPtr hWnd,
int X,
int Y,
int nWidth,
int nHeight,
bool bRepaint
);
#3
06/16/2007 (2:30 pm)
That's actually fairly common for system calls. The new profiler does the same thing to expose the methods that keep track of time on the PC.