How to position window on the desktop ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
thefuzion
Posts: 10
Joined: Tue Mar 06, 2007 11:31 am

How to position window on the desktop ?

Post by thefuzion »

Is it possible to position the main window (not an irrlicht gui window, but the window in which the program is launched when you are in windowed mode) on the desktop ?
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

if i understood correctly you need following.
i do this in the next way:

Code: Select all

int x, y;
DWORD style;
DWORD style_ex;

x = ( GetSystemMetrics( SM_CXSCREEN ) - Game.Width ) / 2;
y = ( GetSystemMetrics( SM_CYSCREEN ) - Game.Height ) / 2;
style = WS_SYSMENU | WS_BORDER | WS_CAPTION |
    WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX;
style_ex = WS_EX_APPWINDOW;

Game.hWnd = CreateWindowEx( style_ex, window_classname, window_caption,
    style, x, y, Game.Width, Game.Height,
    NULL, NULL, 0, NULL );
this is code fragment from my library.
this code will always create needed window ( with dimensions Game.Windth x Fame.Height ) in the center of the screen.

any way, if you need to get current desktop resolution use this:

Code: Select all

int desktop_width = GetSystemMetrics( SM_CXSCREEN );
int desktop_height = GetSystemMetrics( SM_CYSCREEN );
having this and knowing the size of your future window -- you can create window on any place ( correct place -- for example "attached" to right bottom corner of the screen etc. ).

p.s.: GetSystemMetrics() is Win32API function.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You could modify the Irrlicht source to create the window at the position you want, or you could use MoveWindow to move the window after it is created. The hWnd parameter comes from the video drivers exposed data.

Travis
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

vitek wrote:You could modify the Irrlicht source to create the window at the position you want, or you could use MoveWindow to move the window after it is created. The hWnd parameter comes from the video drivers exposed data.

Travis
Isn't it the console window he wants to move, though? The hWnd is for the rendering window. To move the console I think you'd have to use Win32 API FindWindow (IIRC) to find the console window and then use MoveWindow.

I'm assuming Windows, since the OP hasn't stated which OS.
thefuzion
Posts: 10
Joined: Tue Mar 06, 2007 11:31 am

Post by thefuzion »

thanks !
That's what i needed :)
Post Reply