Controlling position of the window

Does anybody know how to control the position of the SDL window under
Windows? I need to position it (center it on the computer screen). Then
I want the user to be able to drag it around.
The dragging part I think I can do, once I know how to position it. And
I think I have a handle to the window, but how do you move it? How do
you get Windows display resolution? Here’s how far I’ve gotten on it:

// Center the window
if (!fullscreen)
{
SDL_SysWMinfo myinfo;
Display *d;
Screen *defscr;

          SDL_VERSION(&winInfo.version);
          if (SDL_GetWMInfo(&winInfo))
          {
                      printf("moving...\n");
                      if(info.subsystem == SDL_SYSWM_X11) {
                                            d =

myinfo.info.x11.display;

myinfo.info.x11.lock_func();
defscr =
DefaultScreenOfDisplay(d);
XMoveWindow(d,
winInfo.info.x11.wmwindow,

(defscr->width - width) / 2,

(defscr->height - height) / 2);

myinfo.info.x11.unlock_func();
} else {
// Question: Is there any way to
test for Windows?
// Question: How do you get the
display resolution with Windows?
HWND window = winInfo.window;
// Here’s where I want to move the
window. How do you do it??
}
}
}

Hi,

GetSystemMetrics(SM_CXSCREEN)
GetSystemMetrics(SM_CYSCREEN)

return the width and height of the screen.

MoveWindow(…)

moves and scales the window. And use

GetWindowRect(…) or GetClientRect(…)

to get the size of the window. (GetWindowRect returns the size of the window
including borders and title, that is what you probably want.)

Maybe you could add this as a SDL_CENTER flag in SDL_SetVideoMode.

Ignacio Casta?o
@Ignacio_Castano___________________________________________________
Yahoo! M?viles
Personaliza tu m?vil con tu logo y melod?a favorito
en http://moviles.yahoo.es