-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix Anchors in PermonitorV2 mode applications. #8086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In PermonitorV2 mode applications, when moving the Form from one monitor to the other, Form gets an invalid display rectangle for a brief period during the scaling of its child controls. Updating anchors, because of layout, during this period would end up invalid anchor calculations. For all scaling scenarios due to DPI changed event, we will be scaling anchors and avoid/skip recalculation of anchors and prevent using this invalid display rect. Following is the snippet where we see invalid DisplayRect of the Form for a brief period while moving from one monitor to the other.
Tanya-Solyanik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
How does this change affect your perf results?
Had you tested this change in apps where the anchored control is a container itself?
src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs
Outdated
Show resolved
Hide resolved
Yes. Form with Panel with anchored controls. And panel is anchored to Form. Works as expected. |
fixes: #8087
In PermonitorV2 mode applications, when moving the Form from one monitor to the other, Form gets an invalid display rectangle for a brief period during the scaling of its child controls. Updating anchors, because of layout, during this period would end up invalid anchor calculations. For all scaling scenarios due to DPI changed event, we will be scaling anchors and avoid/skip recalculation of anchors to prevent using this invalid display rect.
Following is the snippet where we see invalid DisplayRect of the Form for a brief period while moving from one monitor to the other.
Invalid state:

Final state:
Amending #7956
Microsoft Reviewers: Open in CodeFlow