dotnet / winforms

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

Recreate handle resizes the form on monitor with non-96 DPI #6125

Open RussKie opened 2 years ago

RussKie commented 2 years ago

Problem description:

On a monitor with non-default DPI (e.g. 150%, 200%, etc.) a form changes its dimensions upon recreation of its handle:

https://user-images.githubusercontent.com/4403806/140443304-0be2fda6-f37e-40b1-b1f8-d4467ba18339.mp4

On a monitor with 100% scale factor everything works as expected.

Expected behavior: The form retains the geometry.

Minimal repro:

  1. Unzip repro.zip in to .\src\System.Windows.Forms\tests\IntegrationTests\WinformsControlsTest
  2. Update Program.cs to invoke Form1
  3. F5
dreddy-work commented 2 years ago

@RussKie, I tried this on my machine with standalone app but could not repro. Only difference is, I have latest bits here.

RussKie commented 2 years ago

I'll test it against the main and see if it's been fixed.

RussKie commented 2 years ago

Tested against the latest main. It is still happening for me on a secondary monitor with 150% SF (the primary monitor is at 100%)

https://user-images.githubusercontent.com/4403806/142094113-ff1f3f9f-ff04-444a-b03a-52681a32da66.mp4

dreddy-work commented 1 year ago

@RussKie , I was going over this issue as part of the push we are making. I tried this particular scenario on a 150/200 DPIs but i see no issue. I do see Form being hidden completely when showTaskbar is set to false though. Can you try one last time and update me ?

Amy-Li03 commented 1 year ago

@dreddy-work, verified this on .NET 8.0 latest build: 8.0.100-alpha.1.22565.7, issue only repro on a high 150/200 DPIs secondary monitor, it doesn't repro on a high DPIs Primary monitor.

ghost commented 1 year ago

This submission has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days.

It will be closed if no further activity occurs within 7 days of this comment.