开发者

Move fullscreen window to secondary monitor with Win32/SDL

开发者 https://www.devze.com 2023-04-02 14:21 出处:网络
I am using SDL 1.2.14, and I\'ve found a case where I need to be able to select which monitor gets the fullscreen window. With Xorg, I found Xinerama could do the job using the SDL_VIDEO_FULLSCREEN_HE

I am using SDL 1.2.14, and I've found a case where I need to be able to select which monitor gets the fullscreen window. With Xorg, I found Xinerama could do the job using the SDL_VIDEO_FULLSCREEN_HEAD environment variable, however, I've been unable to find something similar for Win32.

The fullscreen window is always created on the primary monitor, and since SDL 1.2 does not (SDL 1.3 can, but it's not stable) provide the API to select which monitor is to be used on Win32, I wonder if 开发者_StackOverflowit's possible to programmatically move the fullscreened window to the secondary monitor using Win32 API after it has been created.

I am able to get the underlying Win32 handles for the window/context.


Raymond Chen wrote a useful article on how to switch an application between windowed and full screen. The important part for you would be this section of the code:

GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &mi))

This gets the monitor information for a specific monitor, but uses the value returned from MonitorFromWindow to pick the monitor on which the window currently resides. There are several other methods of picking a monitor, such as providing an X,Y coordinate, or enumerating them (using EnumDisplayMonitors(...)).

GetMonitorInfo(...) passes a MONITORINFO back out, which contains the relative position and size of the display, which you can use to position your full-screen window.

The full API is detailed on MSDN.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号