Skip to content
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

Resume invocation of OnParentHandleRecreated for child control when form recreates handle #6113

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Nov 3, 2021

Fixes #6093, the regression introduced in #2262.

Proposed changes

Restore the required state after the handle was re-created.

#2262 has added a check to the method handling recreation of a control handle to verify that the control is created before any child controls can be re-parented on to it.
image

However it was missed that DestroyHandle() method resets the state (i.e. removes Created state), but CreateHandle() method doesn't set the state back.

Customer Impact

  • Child controls sited on a form that recreates its handle while shown (e.g. while changing the value of ShowInTaskbar property) will be correctly rendered.

Regression?

Risk

  • Small

Screenshots

Before

image
On the left ListBox and CheckedListBox controls, on the right ListView controls.

After

image

Test methodology

  • git bisect to establish the commit that regressed the behaviour
  • manual
  • unit tests
Microsoft Reviewers: Open in CodeFlow

@RussKie RussKie requested a review from a team as a code owner November 3, 2021 06:27
@ghost ghost assigned RussKie Nov 3, 2021
@RussKie
Copy link
Member Author

RussKie commented Nov 3, 2021

/cc: @chenxinyanc

…orm recreates handle

Fixes dotnet#6093

Fix the regression introduced in dotnet#2262.
@RussKie RussKie force-pushed the fix_6093_children_controls_not_rendered_when_parent_recreated branch from e8bda90 to cca5560 Compare November 4, 2021 01:02
@@ -9827,6 +9827,9 @@ internal virtual void RecreateHandleCore()
// the call shouldn't fail.
// However, it could fail if this.CreateParams.Parent is changed outside our control.
CreateHandle();

// DestroyHandle resets the state, but CreateHandle doesn't set the state back.
SetState(States.Created, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag is set in CreateControl:

@dreddy-work dreddy-work added the 📬 waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) label Nov 4, 2021
@RussKie RussKie merged commit 86a9084 into dotnet:main Nov 5, 2021
@RussKie RussKie deleted the fix_6093_children_controls_not_rendered_when_parent_recreated branch November 5, 2021 01:38
@ghost ghost added this to the 7.0 alpha1 milestone Nov 5, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jan 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📬 waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET 5.0, WinForms: Changing ShowInTaskbar will let CheckedListBox-items disappear.
2 participants