Repository navigation
fix MDI forms lost sub control box - #3461
Conversation
This comment has been minimized.
This comment has been minimized.
JeremyKuhne
left a comment
There was a problem hiding this comment.
Clean up the commented out code in the tests, otherwise looks good.
2eb095c to
c9523a4
Compare
Codecov Report
@@ Coverage Diff @@
## master #3461 +/- ##
====================================================
+ Coverage 66.58268% 98.49746% +31.91478%
====================================================
Files 1338 443 -895
Lines 501686 248046 -253640
Branches 40864 4088 -36776
====================================================
- Hits 334036 244319 -89717
+ Misses 162104 3015 -159089
+ Partials 5546 712 -4834
|
merriemcgaw
left a comment
There was a problem hiding this comment.
More work needed. I'd recommend optimizing for the case of both parent and child having menus that need to merge smoothly.
c9523a4 to
8557999
Compare
Codecov Report
@@ Coverage Diff @@
## master #3461 +/- ##
=============================================
Coverage 97.96398% 97.96398%
=============================================
Files 538 538
Lines 262669 262669
Branches 4912 4912
=============================================
Hits 257321 257321
Misses 4468 4468
Partials 880 880
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
See issue discussion of #3029, the code before the |
This comment has been minimized.
This comment has been minimized.
But it does on .NET Core 3.1 ? Or are you using different code there ? |
This comment has been minimized.
This comment has been minimized.
|
Today I went all the way back to .NET Core 3.0 branch, and started cleaning from scratch. I managed to rid the Now I need to project the same change on to the master branch, and see what we've missed. |
|
I copied the change from release/3.0...RussKie:Investigate_3.0 on to the master branch and..... it didn't work as I expected. The icons are still missing. |
85348a5 to
dd99bb7
Compare
|
CTI confirmed the fix |
weltkante
left a comment
There was a problem hiding this comment.
Besides some whitespace issues I'm missing the refreshes I identified here as having been removed incorrectly in the initial cleanup PR.
In particular the MdiParentInternal setter and SetVisibleCore would reapply WM_MDISETMENU on the form. This refresh from MDI child to parent is missing otherwise (i.e. when the child is made visible or attached at a later point the parent needs to refresh its menu)
In my local tests there were scenarios where these refreshes were necessary to correctly show the menus as they used to before. Does the test code at the end of my branch work correctly for you? On Desktop Framework it will show the MDI menu bar, on .NET Core it is missing because the MDI child is loaded after the parent and no refresh happens.
41e9574 to
718ea61
Compare
|
Thank you @weltkante, I'm going to retest it again. In my previous tests |
Running the test app on the latest master with the comparable change to your sample diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MdiParent.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MdiParent.cs
index 63c1cc57a..4dd8f550f 100644
--- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MdiParent.cs
+++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MdiParent.cs
@@ -30,6 +39,7 @@ namespace WinformsControlsTest
MdiChild frm = new MdiChild();
frm.MdiParent = this;
+ frm.WindowState = FormWindowState.Maximized;
frm.Show();
}
}Adding the missing plumbing fixes the issue: Though instead of this: I was able to achieve it with a smaller change: + /// <summary>
+ /// Invalidates the merged menu, forcing the menu to be recreated if
+ /// needed again.
+ /// </summary>
+ private void InvalidateMergedMenu() => ParentForm?.UpdateMenuHandles();
+In your version we invoke |
weltkante
left a comment
There was a problem hiding this comment.
In your version we invoke
MenuChangedon a parent, then the code withinMenuChangedis looking for a parent of the original parent, and I couldn't get it to execute. The only thing that matter, it appears, is the call toUpdateMenuHandles.
Is there some other use case that I'm overlooking?
Thats just a straight port of the pre-PR version, had to remove lots of redundant stuff and might have missed this. No I can't think of any purpose that branch may serve. On Desktop Framework there are more HMENU-related callers and it may be used by those.
PR looks good to me.
|
Thank you! |
With the deprecation and removal of `MainMenu` control in dotnet#2091 one of MDI scenarios got broken where both parent and child forms don't have `MainMenuStrip` property set nor have `MainMenuStrip` instance added to their respective `Controls` collection. The fix restores setting an MDI menu via `WM_MDISETMENU` message to the parent form. Fixes dotnet#3029
a1d3703 to
8d9b1e6
Compare



Fixes #3029
Proposed changes
With the deprecation and removal of
MainMenucontrol in #2091 one of MDI scenarios got broken where both parent and child forms don't haveMainMenuStripproperty set nor haveMainMenuStripinstance added to their respectiveControlscollection.The fix restores setting an MDI menu via
WM_MDISETMENUmessage to the parent form.Customer Impact
Customers who use MDI scenarios without main menu in both parent or child forms won't be able to minimise maximised child forms
Regression?
Risk
Screenshots
👉 👉 👉 Click for lots of pretty pictures... 🖼️ 🖼️ 🖼️
Controls.Add(menuStrip),MainMenuStrip= nullControls.Add(menuStrip),MainMenuStrip=menuStripControls.Add(menuStrip),MainMenuStrip= nullControls.Add(menuStrip),MainMenuStrip=menuStripControls.Add(menuStrip),MainMenuStrip= nullControls.Add(menuStrip),MainMenuStrip=null/menuStripControls.Add(menuStrip),MainMenuStrip=menuStripControls.Add(menuStrip),MainMenuStrip= nullControls.Add(menuStrip),MainMenuStrip=menuStripControls.Add(menuStrip),MainMenuStrip=menuStripTest methodology
Microsoft Reviewers: Open in CodeFlow