4
\$\begingroup\$

My game, like most games, supports running in fullscreen exclusive mode. And I'd like to give my players the choice of which monitor the game will display on.

In order to prevent the player from clicking through to the desktop, I need to position my game window to exactly cover the entire monitor's area.

My game works fine when displaying on adapter 0. I simply set the window's location to 0,0 and its size to the fullscreen resolution.

However, this doesn't work if the player chooses a different monitor. The game will render on the correct monitor, but the window will still be located on the primary monitor.

How do I determine the location for my window when the player chooses a monitor other than 0?

\$\endgroup\$
  • \$\begingroup\$ Most games support "fake full screen" as well as "windowed mode". True full-screen exclusive on a multi-monitor setup is problematic and you usually have to shut one of the monitors off anyhow. \$\endgroup\$ – Chuck Walbourn Dec 3 '15 at 8:45
  • 1
    \$\begingroup\$ Huh? That hasn't been my experience. Probably 90% of the games I play support true full-screen (where I can change the resolution) and work just fine on my 3-monitor setup, though most will only run full-screen on the primary monitor. Anyway, I figured out the solution. See my answer below. \$\endgroup\$ – Walt D Dec 3 '15 at 17:04
1
\$\begingroup\$

Okay, I believe I have figured it out:

First, call GetAdapterMonitor to get an HMONITOR handle from the adapter index you passed in when creating the D3D device. Then use that handle to call GetMonitorInfo, which gives you a MONITORINFO structure. The rcMonitor field of that structure contains the location and size of that monitor.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.