IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

DPI awareness, screen resolution and scaling #5223

Open isedwards opened 5 years ago

isedwards commented 5 years ago

Describe the bug Some users experience display problems when using the application with high resolution (high-DPI) devices and display scaling. Some of the controls are sized incorrectly and some elements are only partially visible.

To Reproduce This bug has currently been observed on Windows 7 machines with the resolution set to 1366 x 768 and scaling set to 125%. The next step is to see whether the bug can be replicated in a virtual machine running Windows 7 with 125% scaling.

Screenshots dpi-awareness2

isedwards commented 5 years ago

I think I've read that display scaling works differently on Windows 7 vs Windows 10, and one article that I've read suggests it differs depending on the version of Visual Studio that is used during development.

Here are a couple of articles that I have in my bookmarks - the first is to make the application DPI aware, so that it knows how to correctly scale: http://www.visualstudioextensibility.com/2015/02/01/visual-studio-extensions-and-dpi-awareness/

The second article aims to do the opposite - by making the application "DPI unaware" we can be certain that all of the controls will be scaled correctly, but the application may look a bit more fuzzy/blurred because Windows is just magnifying the bitmap pixels so that everything will appear larger. http://www.visualstudioresources.com/2017/01/13/running-visual-studio-or-setups-with-dpi-virtualization-dpi-unaware-on-high-dpi-displays/

The second approach is the easiest, and is probably the best place to start.

dannyparsons commented 5 years ago

@isedwards thanks for looking into this. I have just tested on a virtual Windows 7 machine and can confirm that the same issue appears both with 125% and 150% scaling.

dannyparsons commented 5 years ago

These two points may be useful information for https://github.com/opencdms/Climsoft/issues/450

  1. We previously noticed the issue for developers who have dpi scaling above 100% on their machines. With this scaling the designers were modified to match the scaling and made everything too big when viewed with no scaling. So we have been careful to only modify the designer files when dpi scaling is 100% (I think only me and Patrick have dpi scaling > 100% on our machines).
  2. In the new Visual Studio Community 2017 it has a great option to make it "dpi unaware" when it detects you have dpi scaling > 100%, which reloads VS and it becomes slightly fuzzy but means you can edit the designer files without causing problems and without needing to change the dpi scaling of your whole machine.

So I think we have carefully maintaining our designer files correctly.

  1. We noticed here that adding a WPF object made the software dpi aware, even on Windows 10, and so from the suggestion here we disabled dpi awareness by adding:

<Assembly: System.Windows.Media.DisableDpiAwareness>

to the assembly.

So I thought we had made the application dpi unaware, but it seems that this was sufficient for Windows 10 but not for Windows 7. An article here which is quite old, suggests setting AutoScaleMode to Dpi. image

However, this is an interesting comment at the bottom of the article:

I was having a related issue with dot net forms on a windows 7 machine which had default DPI of 125%. In particular datagridviews inside of TabStrips were not sizing correctly to fill the TabStrips page. I tried switching the AutoScaleMode property of the form to Dpi, and it did not help. Surprisingly what fixed the issue was switching the AutoScaleMode to None. (The default AutoScaleMode was Font).

This seems to be very similar to our problem. On all our forms AutoScaleMode is Font. From the Microsoft Docs it says that None is "Automatic scaling is disabled." so maybe that is what we want? We can now replicate this with Virtual Machines so it would be easy to make a test installer to try it out.