I have a Winforms Application (C#, .NET 4.7) that has no problems on my system with a 1920x1080 monitor. I have set the AutoScaleMode to Font for my main window, and added the true to my manifest. Running the program on a computer with a High resolution (3840x2160) screen seems to work fine as well. All is scaled correct and everything is readable. Until I open a datafile and display the results on the Map or Chart control. Then the whole program suddenly rescales to about 50% of it's original size and all fonts become unreadable small. Changing the font size or resolution using the Windows display settings has no effect. What could cause this runtime scaling, and how can I work around this ?
1 Answers
After following all best practices as described in this post: it still does not work. Another comprehensive explanation on the Telerik website however put me on the right track. The problem was caused by the GMap control, but could be caused by any third party control that was designed on a different system. The control contained a scaling setting in the Designer.cs file:
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
This setting is added automatically by the IDE when you create a new control and is based on the DPI settings of system it is created on. On a 96 DPI system this is always
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
So all the forms I had created for my app had this 96DPI based setting, but the GMap control had a different setting. And when the GMap control was redrawn it caused the whole application to scale using the incorrect AutoScaleDimensions. The solution is simply to search for all occurrences of AutoScaleDimensions and set them all to (6F,13F).

- 742
- 2
- 8
- 23
-
1[Read the notes here](https://stackoverflow.com/a/50276714/7444103) and the duplicate marked by Hans Passant. – Jimi Jan 16 '19 at 15:53
-
@Jimi : I have read it, and it indeed contains a lot extra info. No mention of the 'AutoScaleDimensions' settings though. (As far as I can see) – Cees Meijer Jan 16 '19 at 16:15
-
1Have you seen that the Telerik controls are mentioned there? Some of Telerik's controls reference WPF assemblies. As a direct consequence, the DPI Awareness of an application can change; to which model, it depends on the library in use. You can enable your application to support DPI awareness, you can disable it or you can enable it on a per-thread/per-process basis. Anyway, scaling the UI based on Font size can be tricky, you never know what it's going to be. Possibly, scale on DPI. If you read the last note on that link, it exaplains how to disable the WPF auto DPI scaling, if needed. – Jimi Jan 16 '19 at 16:23