How to position window on the desktop ?
How to position window on the desktop ?
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 ?
if i understood correctly you need following.
i do this in the next way:
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:
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.
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 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 );p.s.: GetSystemMetrics() is Win32API function.
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
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.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
I'm assuming Windows, since the OP hasn't stated which OS.
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781