Skip to content

[ZH] Make game start on the monitor that it is launched from #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

helmutbuhler
Copy link

This PR fixes the window creation to open on the monitor the game is launched on.
This way, when the executable or a shortcut to it is opened on a certain monitor, the window opens on the same monitor. This also works when the game is started from the taskbar.
The code to do this may seem hacky, but it's exactly what the documentation for GetStartupInfo recommends.

Also note that I needed to #define WINVER 0x0500, because the Monitor API didn't exist in Win 95 yet. This causes the compiler to emit a message when compiling WinMain.cpp, but generates no error or warning. The game will also no longer run on Win95, but I think we can live with that.

Change list

  • fix: The game starts now on the monitor it's launched from

@DevGeniusCode
Copy link

Is this to solve a specific problem? What about those who would like the game to open on a different monitor or where it was last opened?

@DevGeniusCode DevGeniusCode added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour labels Mar 29, 2025
roossienb pushed a commit to roossienb/GeneralsGameCode that referenced this pull request Mar 29, 2025
roossienb pushed a commit to roossienb/GeneralsGameCode that referenced this pull request Mar 29, 2025
@helmutbuhler
Copy link
Author

Well, right now it always starts up on the primary monitor, and I figured people prefer to have it launch where they start it.
We can also add commandline arguments to specify the position/monitor where the game should launch, but probably in another PR.
And maybe we can also try to remember the last position, but that tends to be not so reliable in case monitor configurations change between runs.

@tintinhamans
Copy link

Ideally this becomes a setting in display options which you can choose in-game.

See Call of Duty implementation:

image

@helmutbuhler
Copy link
Author

Yes, that would be ideal.
But it's also quite a bit of work to implement that. And even when we have that implemented, we'd still need to decide on a monitor on first startup, so I don't think we should block this PR until we have all that implemented.

@helmutbuhler
Copy link
Author

I just updated the comments a bit

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change will produce the following user feedback:

"My game no longer launches on the correct screen !!!"

"Correct" meaning the primary screen that it was originally launched on, regardless where their exe or shortcut was.

I wonder if there is a strategy to avoid users running into unexpected window spawn locations that they do not like. We can assume that most players will take no issue with the original behaviour, but eventually will like or dislike this new behaviour, and the negative feedback will naturally overwhelm the positive feedback, which we need to avoid somehow.

Also, Noob players will not intuitively understand how to solve this situation.

rect.right-rect.left,
rect.bottom-rect.top,
(mi.rcMonitor.right+mi.rcMonitor.left-startWidth) / 2,
(mi.rcMonitor.bottom+mi.rcMonitor.top-startHeight) / 2,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add some spacings around + to make easier on the eyes.

(GetSystemMetrics( SM_CXSCREEN ) / 2) - (startWidth / 2), // original position X
(GetSystemMetrics( SM_CYSCREEN ) / 2) - (startHeight / 2),// original position Y
//(GetSystemMetrics( SM_CXSCREEN ) / 2) - (startWidth / 2), // original position X
//(GetSystemMetrics( SM_CYSCREEN ) / 2) - (startHeight / 2),// original position Y
// Lorenzen nudged the window higher
// so the constantdebug report would
// not get obliterated by assert windows, thank you.
//(GetSystemMetrics( SM_CXSCREEN ) / 2) - (startWidth / 2), //this works with any screen res
//(GetSystemMetrics( SM_CYSCREEN ) / 25) - (startHeight / 25),//this works with any screen res
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove all this commented code or do we need it for something?

@aliendroid1
Copy link

I think this change will produce the following user feedback:

"My game no longer launches on the correct screen !!!"

"Correct" meaning the primary screen that it was originally launched on, regardless where their exe or shortcut was.

I wonder if there is a strategy to avoid users running into unexpected window spawn locations that they do not like. We can assume that most players will take no issue with the original behaviour, but eventually will like or dislike this new behaviour, and the negative feedback will naturally overwhelm the positive feedback, which we need to avoid somehow.

Also, Noob players will not intuitively understand how to solve this situation.

I don't think most "noob" or accurately less tech savvy players would be likely to have a multi-monitor setup and have the game being launched from the second monitor. Regardless, having the program launch on the to display you launched it on is expected behavior and the default behavior of almost every other program

Before working on the code I too found it to be quite an issue that I couldn't make the game launch on my secondary monitor. The easy fix for that should be win+shift+→ but that crashes without the alt tab fix and even with it still has issues such as not adjusting to the resolution of the second monitor and more. Changing the primary monitor isn't a feasible option because then task bar stuff isn't accessible

@xezon
Copy link

xezon commented May 18, 2025

It does not matter so much what other games do. There are plenty players who only play Generals, and nothing else. If we want to appeal to the established player base, then we need to give this thought.

@helmutbuhler
Copy link
Author

I understand both arguments.

Personally, I just use one monitor anyway, so I don't really mind. But if I were using multiple monitors, I'd definitely find it annoying that the monitor cannot be selected.

How about this: I add a commandline option which allows you to explicitely specify the monitor number to this PR, we merge this, and then we wait and see if anyone actually complains about the default and isn't happy to override the monitor via commandline..

@xezon
Copy link

xezon commented May 18, 2025

Yes a command line option would probably be good enough for now. Should the new behaviour be the default or should the legacy behavior be the default? I currently only have one monitor, so I cannot test this change.

How likely is it that users expect the game to launch where the shortcut is located, rather than launch on the Primary Monitor? I for one always expected the game to launch on the Primary Monitor, simply because it has done it since 20 years.

@xezon
Copy link

xezon commented May 30, 2025

Leave the original behaviour as the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants