SDL Window Location

Started by
0 comments, last by Drew_Benton 18 years, 3 months ago
How can I set the initial location of an SDL window with respect to my screen?
Advertisement
You can only do it in a platform specific way. Here's an example of how to do it on Windows:

#include <sdl_syswm.h>void SetWindowPosition(int sX, int sY){	RECT sRect;	static SDL_SysWMinfo sInfo;	SDL_VERSION(&sInfo.version);	SDL_GetWMInfo(&sInfo);		GetWindowRect(sInfo.window, &sRect);	MoveWindow(sInfo.window, sX, sY, sRect.right, sRect.top, true);}


Also note how I get and use the actual window dimensions rather than use the known resolution of the main screen. Just something to keep in mind. You need that header file to be able to use most of that code, it automatically includes windows.h for you.

This topic is closed to new replies.

Advertisement