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;

          if (SDL_GetWMInfo(&winInfo))
                      if(info.subsystem == SDL_SYSWM_X11) {
                                            d =;;
defscr =

(defscr->width - width) / 2,

(defscr->height - height) / 2);;
} 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??



return the width and height of the screen.


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
Yahoo! M?viles
Personaliza tu m?vil con tu logo y melod?a favorito