tradewright / tabcontrol-extra

An improved TabControl for Windows Forms (.Net)
Other
31 stars 8 forks source link

Please make the demo project DPI-aware #9

Open wmjordan opened 3 years ago

wmjordan commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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:

Thanks.

wmjordan commented 3 years ago

Your Surface Pro machines should count as high DPI.

Here's my configuration:

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 commented 3 years ago

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.