dotnet / winforms

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

RadioButton and CheckBox are not scaled well on the secondary monitor when application is in PerMonitorV2 mode #9200

Open Philip-Wang01 opened 1 year ago

Philip-Wang01 commented 1 year ago

.NET version

.NET 8.0.100-preview.6.23280.13

Did it work in .NET Framework?

Yes

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

Yes, it works in .NET 6.0/7.0/8.0.100-preview.5.23262.2, doesn't work in 8.0.100-preview.5.23268.15.

Issue description

Testapp: Testapp.zip

https://github.com/dotnet/winforms/assets/86937911/6d4d445c-930f-4d03-a3ea-a439026670e4

100%DPI: image 100% primary monitor -> 300% secondary monitor image 300%DPI: image 300% primary monitor -> 100% secondary monitor image

Steps to reproduce

  1. Launch VS instance on 100% primary monitor.
  2. Add <ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode> in csproj file.
  3. Close and reopen Solution.
  4. Add some radioButton and checkBox controls to form designer.
  5. Build and run the application.
  6. Move to 300% secondary monitor.

More Info:

  1. This issue does not happen at design time.
  2. This issue only repro on radiobutton and checkbox control.
  3. This issue also occurs when move from 300% primary monitor to 100% secondary monitor.
elachlan commented 1 year ago

Cc: @dreddy-work

dreddy-work commented 1 year ago

@Philip-Wang01, can you track to which commit caused it?

dreddy-work commented 1 year ago

@Philip-Wang01, can you track to which commit caused it?

Nevermind. Its result form here: https://github.com/dotnet/winforms/commit/31fcf979bb2627373f320c5dd6a970f60b08dcbd

dreddy-work commented 1 year ago

Analyzed and found the root cause. Planning to get it in preview 6.

dreddy-work commented 1 year ago

@Philip-Wang01, can you please validate this change for the anchor issues you found? Please validate on all high DPI modes in runtime as well as designer scenarios to check if there are no regressions.

Philip-Wang01 commented 1 year ago

@dreddy-work tested private binaries for GH PR: 9214 on run time for Multi-Monitors, two issues were found in PerMonitorV2 mode.

Issue1: When switching between the main and secondary monitors, the coordinate of the control will be shifted. (This issue also reproduced in other control when their anchor property is a non-default setting)

https://github.com/dotnet/winforms/assets/86937911/daa6e02a-efe9-4be4-9578-118d9910b28f

Issue2: For https://github.com/dotnet/winforms/issues/9209, controls still don't scale well when their anchor property is a non-default setting

https://github.com/dotnet/winforms/assets/86937911/c01ff582-5fbc-4d32-a4c7-af5471b5964b

dreddy-work commented 1 year ago

Thanks @Philip-Wang01 for the update. I will go over these and update the PR.

dreddy-work commented 1 year ago

@Philip-Wang01, updated PR and i cross checked these two examples. Can you run your tests again and see if there any other issues/regressions? please check both runtime and design scenarios for regressions.

Philip-Wang01 commented 1 year ago

@dreddy-work tested private binaries for GH PR: https://github.com/dotnet/winforms/pull/9214 on design time and run time for Multi-Monitors.

For runtime: Not fully fixed.

Issue: Anchor issue still repro in ListBox, CheckedListBox, TabControl and DateTimePicker control with non-default settings. And the controls in the tabcontrol are not scaled well when their anchor property both non-default setting. Test9200.zip

https://github.com/dotnet/winforms/assets/86937911/46c3f1f3-f22d-4129-b218-269c64e3af0e

For design time: one issue was found in PerMonitorV2 mode and hitting known issue: 5193 (all are not regressed from https://github.com/dotnet/winforms/commit/31fcf979bb2627373f320c5dd6a970f60b08dcbd).

Issue: When switching between the main and secondary monitors, the coordinate of the control with a non-default anchor setting will be shifted.

More Info:

  1. This issue also repro on radiobutton and checkbox with a default anchor setting.
  2. This issue was fixed in this testing on run time, but repro in design time.
  3. It's a regression issue from .NET 8.0, but not regressed from https://github.com/dotnet/winforms/commit/31fcf979bb2627373f320c5dd6a970f60b08dcbd, not repro on .NET6.0/7.0.

Do we need to open a designer issue to track it?

https://github.com/dotnet/winforms/assets/86937911/cd690929-f1e8-49e3-82d1-179c2f805e57