|
| 1 | +## High DPI (HDPI) improvements in Windows Forms controls for .NET 4.8 |
| 2 | + |
| 3 | +### Scope |
| 4 | +Major |
| 5 | + |
| 6 | +### Version Introduced |
| 7 | +4.8 |
| 8 | + |
| 9 | +### Source Analyzer Status |
| 10 | +NotPlanned |
| 11 | + |
| 12 | +### Change Description |
| 13 | +The Windows Forms Framework is continuing to improve the scaling and rendering of its controls to better support Windows Forms customers on high resolution devices. As a result of these improvemeents, Windows Forms applications are able to better handle DPI changes that occur, for example, when moving the application from one monitor to another monitor that has different DPI settings. These include the following changes: |
| 14 | +- Changes to improve the scaling of <xref:System.Windows.Forms.PropertyGrid> controls when the DPI of the application changes. |
| 15 | +- Changes to improve the scaling of Toolstrip menus, buttons, and glyphs when the DPI of the application changes. |
| 16 | +- Changes to improve the scaling of <xref:System.Windows.Forms.RadioButton> and <xref:System.Windows.Forms.CheckBox> controls when setting different styles on them, and the DPI of the application changes. |
| 17 | +- Changes to improve the scaling of font-based controls when the DPI of the application changes. |
| 18 | +- Changes to improve the scaling of the <xref:System.Windows.Forms.Button> control when the DPI of the application changes. |
| 19 | + |
| 20 | +- [x] Quirked |
| 21 | +- [ ] Build-time break |
| 22 | + |
| 23 | +### Recommended Action |
| 24 | +__How to opt in or out of these changes__ |
| 25 | + |
| 26 | +In order for the application to benefit from these changes, it must run on the .NET Framework 4.8. The application can opt in to these changes in either of the following ways: |
| 27 | +- It is recompiled to target the .NET Framework 4.8. These high DPI improvement changes are enabled by default on Windows Forms applications that target the .NET Framework 4.8. |
| 28 | +- It targets the .NET Framework 4.7.2 or earlier versions and opts in to this new behaviour by adding the following [Windows Forms Configuration Section](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/winforms/) to the app config file and then adding the required flag to opt-in specific feature improvements. |
| 29 | + |
| 30 | +```xml |
| 31 | + <?xml version="1.0" encoding="utf-8"?> |
| 32 | + <configuration> |
| 33 | + <startup> |
| 34 | + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/> |
| 35 | + </startup> |
| 36 | + <configuration> |
| 37 | + <System.Windows.Forms.ApplicationConfigurationSection> |
| 38 | + ... |
| 39 | + </System.Windows.Forms.ApplicationConfigurationSection> |
| 40 | + </configuration> |
| 41 | + </configuration> |
| 42 | +``` |
| 43 | +- High DPI improvements in each major category has its own opt-in setting. Applications can set the required setting by following instructions found at [High DPI support in Windows Forms](~/docs/framework/winforms/high-dpi-support-in-windows-forms.md) and the [Windows Forms add configuration element](~/docs/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element.md) . |
| 44 | + |
| 45 | +Note that many of these improvements are enabled only on Windows 10, and your application must be enabled to run in Windows 10 compatible mode. You can set this in the application manifest file as defined in [High DPI support in Windows Forms](~/docs/framework/winforms/high-dpi-support-in-windows-forms.md). |
| 46 | + |
| 47 | +__Opting out |
| 48 | +Applications that target the .NET Framework 4.8 and want to preserve the legacy high dpi behavior can do so by explicitly setting the switches described below to `true`. |
| 49 | + |
| 50 | +__Improved PropertyGrid scaling when DPI changes.__ |
| 51 | +- Improved scaling of the PropertyGrid control and its child controls when the DPI of the application is changed (for example, when the application moves from one monitor to another with different DPI settings). All changes made for this improvement are controlled by the `DisableDpiChangedHighDpiImprovements` switch. |
| 52 | + |
| 53 | +__Improved scaling of Toolstrip Menus/Buttons/Glyphs when the DPI of the application changed__ |
| 54 | +All changes in this area are controlled by the `ToolStrip.DisableHighDpiImprovements` & `DisableDpiChangedHighDpiImprovements` switches. |
| 55 | + |
| 56 | +__Improved scaling of RadioButton and CheckBox when application DPI changes__ |
| 57 | +- Improved the scaling of the RadioButton and CheckBox, when setting different styles on them and the DPI of the application changes. All changes made for this improvement are quirked under the `DisableDpiChangedHighDpiImprovements` switch. |
| 58 | + |
| 59 | +__Improved scaling of Button control when application DPI changed__ |
| 60 | +All changes made in this area are controlled by the `DisableDpiChangedHighDpiImprovements` switch. |
| 61 | + |
| 62 | +__Improved scaling of Font based controls when application DPI changes__ |
| 63 | +All changes made in this area are controlled by the `DisableDpiChangedHighDpiImprovements` switch. |
| 64 | + |
| 65 | +### Affected APIs |
| 66 | +- Not detectable via API analysis. |
| 67 | + |
| 68 | +### Category |
| 69 | +Windows Forms |
| 70 | + |
| 71 | +<!-- |
| 72 | + ### Original Bug |
| 73 | +616661 |
| 74 | +378542 |
| 75 | +519500 |
| 76 | +597091 |
| 77 | +645041 |
| 78 | +656271 |
| 79 | +664147 |
| 80 | +671791 |
| 81 | +--> |
| 82 | + |
| 83 | +<!-- breaking change id: --> |
| 84 | + |
0 commit comments