Skip to content

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

@dreddy-work

Description

@dreddy-work

We fixed issue dotnet/winforms#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

dotnet/winforms#7467
and
dotnet/winforms#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

  • 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


Associated WorkItem - 60093

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 8Work items for the .NET 8 release📌 seQUESTeredIdentifies that an issue has been imported into Quest.binary incompatibleExisting binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking changewinforms/subsvc

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions