Uh oh!
There was an error while loading. Please reload this page.
Update Form's Minimum and Maximum sizes with DPI_CHANGED event - #7467
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Tests succeed locally. Seems thread awareness is not being set on lab machines. Looking on how to confirm this theory. Review can continue knowing test failed with lab specific issue. |
RussKie
left a comment
There was a problem hiding this comment.
Pass over the docs only. Will continue to the code later.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
RussKie
left a comment
There was a problem hiding this comment.
The animation is great, but we'll need to redo it. I understand that it's showing two desktops, but it's too wide (a lot of our users still use HD monitors), and it contains information completely unrelated (i.e., the email).
The app could be tweaked to appear significantly closer to the monitor boundary, so that we can clip the view and dragging will require less distance.
It could be also great to add some test to the animation to indicate each monitor's settings.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
dreddy-work
commented
Aug 11, 2022
I tried but now screen separation isn't clear with latest one. I am sure people reading will understand and demo was just to show how it is picked up. Not planning on spending more time on this for now. |
RussKie
left a comment
There was a problem hiding this comment.
Reviewed just the code-related changes, as this what we'll ship. We can iterate over the docs later.
LGTM with few minor changes.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Tanya-Solyanik
left a comment
There was a problem hiding this comment.
I added some more nits
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // Borrowed from https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/LocalAppContextSwitches.Common.cs | ||
| internal static partial class LocalAppContextSwitches | ||
| { | ||
| private const string ScaleTopLevelFormMinMaxSizeForDpiSwitchName = "System.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi"; |
There was a problem hiding this comment.
Make it internal for use in tests or access the private dynamically via the test helper.
There was a problem hiding this comment.
Also going forward we might want to keep all these names in a special file, potentially in the common folder.
There was a problem hiding this comment.
Agree on moving to a common file for these string const. Will make that change along with fixing skipped test. I enable auto-merge and it did merge when you approved.
Uh oh!
There was an error while loading. Please reload this page.
| /// </summary> | ||
| /// <param name="xScaleFactor">The scale factor to be applied on width of the property being scaled.</param> | ||
| /// <param name="yScaleFactor">The scale factor to be applied on height of the property being scaled.</param> | ||
| /// <param name="updateContainerSize"><see langword="true"/> to resize of the container control along with properties being scaled; otherwise, <see langword="false"/>.</param> |
There was a problem hiding this comment.
nit: break this line into multiple lines
| form.Show(); | ||
| // Explicitly opt-in to resize min and max sizes with Dpi changed event. | ||
| const string runtimeSwitchName = "System.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi"; |
There was a problem hiding this comment.
Use the const from the source code here
| Assert.NotEqual(form.MaximumSize, maxSize); | ||
| // Reset switch. | ||
| AppContext.SetSwitch(runtimeSwitchName, false); |
There was a problem hiding this comment.
If another tests that relies on this switch runs at the same time, you might have a problem. Perhaps these tests should be moved to the other test project, where they run sequentially.
RussKie
commented
Sep 4, 2022
@dreddy-work a friendly reminder that this change must be documented, please raise a new "breaking change" issue at https://github.com/dotnet/docs. |
RussKie
commented
Oct 18, 2022
@dreddy-work has a breaking doc issue been raised? |
dreddy-work
commented
Oct 18, 2022
Its linked above. |
RussKie
commented
Oct 18, 2022
Ah, right, thanks! The doc: dotnet/docs#31020 |
Description:
Currently, Form's
MinimumSizeandMaximumSizeare not updated when aDPI_CHNAGEDevent received by the Form. This prevents scaling of Form to match with the Dpi when its minimum or maximum size properties are set. Users trying to work around this issue may see problems like #7251.Creating this draft PR to assess the risk for .NET 7.0.
Change in behavior:
Application running in PermonitorV2 mode will see following behavioral change when application moved from one monitor to the other that have different Dpi/Scaling settings and Form has either Minimum and/or Maximum size property set.
MinimumSizeChnagedand/orMaximumSizeChnagedevents that were not before.Before fix: ( moving from 100% to 300%)

After fix:


Microsoft Reviewers: Open in CodeFlow
fixes#7251
fixes#7535