dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.38k stars 971 forks source link

Opening Dialog Form on multi-monitor setup using HDPI PerMonitorV2 does not scale properly #11512

Open alanhoman opened 3 months ago

alanhoman commented 3 months ago

.NET version

.NET 9 Preview 4

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

This worked in .NET 6.0

Issue description

Opening a modal Dialog form on a 150% monitor does not scale properly and the buttons anchored to the bottom right do not anchor properly. They are rendered underneath controls above them and are unusable.

https://github.com/dotnet/winforms/assets/2184698/b60b5e9f-778c-49f2-96de-621a332c31a0

Steps to reproduce

  1. Open the project on a 100% monitor.
  2. Click on Edit Non-Modal and Edit Modal. Both forms scale properly and are the same size.
  3. Move the MDIParent to a 150% monitor.
  4. Click on Edit Non-Modal and the form looks OK, but the buttons overlap slightly with the controls above them.
  5. Click on Edit Modal and the buttons are higher and completely under other controls making them unusable. The form itself is also larger than the Non-Modal version.

Here is a sample project: DialogIssue.zip

alanhoman commented 3 months ago

Also, I tried using the new AnchorLayoutV2 and this did not solve the issue. The modal and non-modal form's buttons were in a better position at 150% (although the Modal form's buttons were a little too close to the controls above them).

The issue is when you close the frmNameList form and re-open it as shown in the attached video. The form has multiple layout issues caused by AnchorLayoutV2. The Criteria group box overlaps with the list view, the Modal buttons overlap, and the picture box controls are in the wrong location. Using AnchorLayoutV2 is not feasible since it creates more issues than it solves.

This should also be tagged as regression-release since these issues did not occur in .NET 6 and was introduced in .NET 7.

https://github.com/dotnet/winforms/assets/2184698/b6d2c1bf-c852-481c-ad00-c386051ecfab

merriemcgaw commented 3 months ago

We are hoping to holistically address scaling and layout in .NET 10. There is no real way to address these piece by piece we've determined, so we intend to look at layout from the ground up in a near future release.

alanhoman commented 3 months ago

This sounds promising and I hope this is a high priority considering how many people use multiple monitors at varying DPI’s and scaling %. The HDPI issues were originally slated to be addressed in .NET 6, 7, 8, and 9, so we have been waiting 4 years for a solution. This has prevented us from being able to migrate from .NET Framework to .NET. Our main app has over 2,500 forms, so moving to WPF or MAUI is not an option at this point. I hope that this holistic approach will not utilize the AnchorLayoutV2 approach which basically fixed one thing and broke multiple other things making it unusable to us.

I would be interested in early testing and evaluation so please let me know if I can be of help in any way.