docs icon indicating copy to clipboard operation
docs copied to clipboard

[Breaking Change] Top level Forms scale their minsize and maxsize values according to the Dpi of the monitor

Open dreddy-work opened this issue 3 years ago • 1 comments

We fixed issue https://github.com/dotnet/winforms/issues/7251 in .NET 7.0 but put behind a quirk to avoid any potential breaks to existing applications. We introduced runtimeconfig.options for WinForms and put this change behind quirk System.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi. More information about this change is available at

https://github.com/dotnet/winforms/pull/7467
and https://github.com/dotnet/winforms/issues/7251

Description

Starting from .NET 8, WinForms top level Forms scale their minsize and maxsize values according to the Dpi of the monitor when running in permonV2 Dpi mode.

Version

.NET 8 and Opt-in in .NET 7 RC1.

Previous behavior

WinForms top level Forms minsize and maxsize values remain const irrespective of the Dpi of the monitor where it is being rendered and application Dpi mode. This could result in scaling limitations of the top-level Form as specified in #7251.

New behavior

Starting from .NET 8, WinForms top level Forms scale their minsize and maxsize values according to the Dpi of the monitor when running in permonV2 Dpi mode. And in .NET 7.0 RC1 onwards, developer can opt-in to this new behavior using runtime config option System.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi described here

Type of breaking change

  • [X] Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as

  • Minimum and Maximum size of the Form will be changed and any runtime dependency on these might be impacted.

  • Raising MinimumSizeChnaged and/or MaximumSizeChnaged events that were not before.

  • Scaled Form size now have new constraint values for Minimum and Maximum sizes.

Reason for change

We have been improving the user experience for WinForm on high Dpi monitors. This change is enabling the developers to set min and max sizes for top-Level forms and not worry about the Dpi of the monitor

Recommended action

If user wanted to opt-out of this new behavior, they could do so by setting System.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi to false in runtimeconfig.json file as defined here

Feature area

High Dpi

dreddy-work avatar Sep 06 '22 17:09 dreddy-work

Given this is a opt-in .NET 7.0, and will be default in .NET8.0, it would be breaking for .NET 8.0 only.

dreddy-work avatar Sep 06 '22 17:09 dreddy-work

described here

image

The doc is now located here: https://github.com/dotnet/winforms/blob/main/docs/runtime-configuration.md

RussKie avatar Oct 19 '22 11:10 RussKie

It is worth noting, that in .NET 7 the behaviour is opt-in (i.e., disabled by default), and in .NET 8 it will opt-out.

RussKie avatar Oct 19 '22 23:10 RussKie