Skip to content
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

Please make the demo project DPI-aware #9

Open
wmjordan opened this issue Mar 14, 2021 · 5 comments
Open

Please make the demo project DPI-aware #9

wmjordan opened this issue Mar 14, 2021 · 5 comments

Comments

@wmjordan
Copy link

app.zip

You can add the above app.manifest file and use it in the demo project's Manifest property.
After that, it is DPI-aware.
Tab height will be automatically adjusted in various DPI settings.

@rlktradewright
Copy link
Contributor

Ok, thanks for that.

I was already aware of this manifest setting, but what I need a better understanding of is exactly what happens 'under the hood'.

@wmjordan
Copy link
Author

Before applying this, the system simply scales the interface to a larger size as a bitmap when working with high-DPI environment.
Consequently everything on the user interface is blurry.

After applying this, you can see that all text on the interface is crisp and the #8 issue that the close button is relatively small since the application now is responsible for sizing and painting the close button.

@rlktradewright
Copy link
Contributor

Well, I'm baffled here.

I don't have a high DPI monitor, but I do have two Surface Pro's with native resolutions of 1920x1080 and 2160x1440. Their screens are presumably192dpi, so I would think that counts as high DPI.

If I run the demo project on these, with the resolution set to the native, then no matter what I set the scaling to via the Windows display settings, everything is crisp and clean. This is true even if I compile the demo app without a manifest.

Also if I set the AutoScaleMode property in the form to Dpi (as opposed to None), the app displays at the same size no matter how the resolution and scaling are set.

In other words, I'm not able to replicate your problem with the equipment available to me. Perhaps using a 4K display would show the problem, but I don't really see why that should make any difference, especially since the actual DPI on large 4K monitors is considerably less than on the Surface screens. (I am actually considering buying a 32" 4K monitor, but this probably won't be imminent.)

So I'd be grateful if you could supply answers to the following:

  • What is the native resolution of your high DPI monitor?
  • What is the actual DPI?
  • What setting do you have for Scaling in the Windows Display settings?
  • Do you have 'Fix scaling for apps' turned on in the 'Advanced scaling settings'?
  • I presume you're using Windows 10?
  • Could you provide a high-res screen capture showing the problem?

Thanks.

@wmjordan
Copy link
Author

Your Surface Pro machines should count as high DPI.

Here's my configuration:

  • Native resolution: 2256*1504
  • DPI: 96*150%=144
  • Windows Display - Scale: 150%
  • Fix scaling: On
  • Windows 10 1909

By comparing with/without the manifest, I found that the displays were quite different.

Here's the one without the manifest--it has the largest display size.
no-manifest
Here's the one with the manifest.
with-manifest
I found that the AutoScaleMode of the demo form was set to None. I changed it to be Font (the default one in the WinForm designer), and compiled without the manifest. I got the following one.
no-manifest-font-scaling

Comparing the 2nd and the 3rd screenshot side-by-side within two image viewer windows:
image

The one with the manifest has crisper text. And the text is correctly scaled to a larger size matching the display setting (150%). But the icon and close buttons are not automatically scaled.
Without the manifest, the icon and close buttons are scaled, but whole interface is a blurry since the whole form is scaled by the system.

@rlktradewright
Copy link
Contributor

Sorry for the long delay in getting back to this. Actually I've spent quite a bit of time looking at this, and my problem is that on my systems I can't replicate what you observe at all.

The most peculiar thing about your screenshots is that the sizes of the tabs are completely different between the left and right images, as is the tab page area. Also the form's title bar is a different colour.

I find it hard to believe that these images were created from the same source code and that the only difference is the presence or absence of the manifest.

And in fact the manifest really is irrelevant for this simple app. If you read up on the technical details of what the dpiaware setting does, there's nothing of relevance to this app, apart from single-pass versus multi-pass scaling.

It's just possible that the difference between what you see and what I see is that your windows 10 version is rather out-of-date. I doubt that this would account for it, but it will be interesting to see what happens when you move up to a more current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants