Skip to content

[GEN][ZH] Add Windows application manifest to executables #595

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 1 commit into
base: main
Choose a base branch
from

Conversation

valeronm
Copy link

@valeronm valeronm commented Apr 4, 2025

Currently, Windows treats the Gen and ZH executables as DPI unaware and forcefully scales the content of all application windows when the display scaling factor is set to something other than 100%. This means that when running the game in windowed mode with a resolution of 800x600, the real window size on screens with scaling set to 200% will be 1600x1200, and every pixel will simply be stretched to four pixels. To prevent this system scaling, the application should indicate to the system that it is DPI aware. The best way to achieve this is to add an application manifest with the dpiAware setting.

Another feature that can be configured via the application manifest is the application of modern visual styles. By default, applications are linked to ComCtl32.dll version 5, which contains UI elements styled like Windows 98/ME/2000. To use modern-looking elements, the application should request loading ComCtl32.dll version 6, which supports themed UI elements from Windows XP and later.

Changes

This PR adds an application manifest that addresses both issues:

  • Specifies that the application is DPI aware, preventing Windows from scaling the app’s windows.
  • Requests the modern version of the common controls library, ensuring that system dialogs in the app have a modern look.

Screenshots on screen with 200% display scaling

Without Manifest
Splash screen window scaled to 1600x1200 from 800x600, and the message dialog has stretched pixelated text, a Windows 98-style button, and an icon.
With Manifest
Splash screen remains unscaled at 800x600, and the message dialog has crisp text, a modern-looking button, and an icon.

@xezon
Copy link

xezon commented Apr 5, 2025

Is this more an enhancement or a fix? I have difficulties to decide.

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Build Anything related to building, compiling labels Apr 5, 2025
@valeronm
Copy link
Author

valeronm commented Apr 5, 2025

I'd say that this is more enhancement. It's also currently possible to disable windows scaling by using "Compatibility" section on executable, but with this change there will be no need to do that. Also, looks like windows already applies this compatibility setting for original executables, possibly using some kind of compatibility database, so the issue happens only on manually built executable which is unknown to Windows.
Applying visual styles is definitely just an enhancement.

@xezon xezon added the Enhancement Is new feature or request label Apr 6, 2025
@helmutbuhler helmutbuhler self-requested a review April 14, 2025 21:42
Copy link

@helmutbuhler helmutbuhler left a comment

Choose a reason for hiding this comment

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

I just reviewed it and tested this with VS6 and VS19 and it looks good.
Some things to note regarding the DPI Aware Setting:

  • We should use AdjustWindowRectExForDpi instead of AdjustWindowRect when we declare us dpi aware. But my Center Window PR [ZH] Center Window on Startup #541 touches that code as well, so I'd wait until that is merged before we fix that.
  • We probably also should make the window resizeable to make different scalings on different monitors work.

But both issues shouldn't block this PR, we'll just have to fix those things eventually.

Not sure if I'm actually allowed to approve this and xezon want's this merged already though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Anything related to building, compiling Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants