PDA

View Full Version : DPI scaling on multiple monitors (some lessons learned)



matthewd
6-May-2017, 08:47 PM
Tangentially related to 19.0...

I got a shiny new 4K monitor (3840x2160) to replace my primary monitor (1920x1200) last week. The 4K monitor is set to 150%, and my old primary monitor is now my secondary monitor, set to 100%.

Applications that are not "Per-Monitor DPI Aware" get DPI virtualized on the secondary monitor now, resulting in blurry text and tiny icons (16x16 icons get resized to 11x11). I think what Windows must be doing is rendering them at 150% and then scaling back down to 100%. Except (at least in the applications I've tested) only the text and window sizes are getting bumped up 150%; the icons in the toolbar aren't and they remain the standard 16x16 size when internally rendered, before being scaled down. Thus they get resized down 1/3 (to the 11x11 pixel size) on the secondary monitor.

Under a 19.0 application with pbAutoResizeIcons set to true, the 24x24 icons get used as expected, and they are resized to 16x16 on the secondary monitor. Text is still blurry though because the application is not per monitor DPI aware.

I tried changing the manifest file on one of my applications to indicate that the application is Per-Monitor Aware (set dpiAware to "True/PM"). This seems to tell Windows that it doesn't need to do any DPI virtualization because the application will handle resizing itself. This resulted in an application that was scaled 150% on both monitors. My understanding is that the application need to handle the WM_DPICHANGED message to change the scaling of the application in order to implement per monitor awareness. I assume this is something the runtime would have to do (maybe in 19.1?).

I also tried turning off dpiAware in the manifest for an 18.2 application. This looked good on the secondary monitor (no DPI virtualization) and looked ok on the primary monitor (Windows scaled it to 150%) but still not quite as good as when DPI aware is enabled on the primary monitor. Some users might prefer it this way if they mainly use the application on the secondary monitor.

Turning off dpiAware in a 19.0 application prevents pbAutoResizeIcons from working, so 16x16 icons are used instead of the 24x24 icons. Other than that it seems to behave the same as the 18.2 application.

I found when changing the scaling factors in Windows, it is always best to sign out and sign back in for the change to completely take effect. The reason is Windows may do DPI virtualization until you sign out. After I first got the monitor set up, I went for a week with my primary display being DPI virtualized. Code in the Studio editor/SSMS/NotePad++ all looked horrible until a Windows update triggered a restart. Then everything was rendering at the native resolution instead of being scaled up through DPI virtualization.

Of course the easy fix is just to get a second 4K monitor to avoid having two different scaling percentages!