question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MDI forms lost sub control box

See original GitHub issue
  • .NET Core Version:
  • Have you experienced this same bug with .NET Framework?: No

Problem description:

  • .NET 5 current master and Preview2 image

  • .NET Core 3.1 image

Expected behavior:

.NET 5 variant must look like .NET Core 3.1 variant.

Minimal repro:

Run a repro app provided in #2979

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:32 (30 by maintainers)

github_iconTop GitHub Comments

9reactions
RussKiecommented, Dec 21, 2020

#4388 is a dup, I just never realised the buttons were the all along. @kirsan31 I ran your sample on a 5.0-rc2, and the issue was there, so it would be the result of bad merge of 3.1->5.0.

I do kind of feel like an archeologist, dig through an ancient codebase, not really knowing where to start. Here’s my understanding of how MDI control box is working. Posting here to provide more context, and so I can recall after I’m back from holidays.

Whenever an MDI windows is being maximised or minimised there’s a call to update MDI parent’s toolstrip: https://github.com/dotnet/winforms/blob/4bca5b30aea871a2c1761b39f8ff8128cb155119/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs#L5613 If the child is being maximised - we merge its menu into the main menu of the parent (line:5671): https://github.com/dotnet/winforms/blob/4bca5b30aea871a2c1761b39f8ff8128cb155119/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs#L5654-L5676 For that we create MdiControlStrip that contains three buttons: “Minimize”, “Maximize” and “Close”: https://github.com/dotnet/winforms/blob/4bca5b30aea871a2c1761b39f8ff8128cb155119/src/System.Windows.Forms/src/System/Windows/Forms/MDIControlStrip.cs#L32-L40 These buttons get native Windows images for respective operations via GetNativeMenuItemImage() call, which retrieves those via https://github.com/dotnet/winforms/blob/4bca5b30aea871a2c1761b39f8ff8128cb155119/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs#L795-L800 …and fails. Because the default system menu doesn’t have any images.

Notice the menu in .NET 5.0 version doesn’t have any images: image

Whilst in .NET Framework does: image

Just for laughs I decided to set images manually, and voila: image

#3461 addresses the issue by creating a new menu, which has images (magic?). Granted that PR isn’t complete like-for-like, and needs further work.

I wouldn’t be surprised if there are still things that I missed, and hopefully @JeremyKuhne and @weltkante can help me filling the gaps.

4reactions
RussKiecommented, Jan 11, 2021

Had two hours of “fun” bisecting, and it looks like we regressed back on 13 Nov 2019 in 07ae711 😱

I rolled back to 922e41002e66fb10d703705d9be700c8b30cd63d (my branch), the last commit on 3.1 branch before the merge, it is working as far as the broken use case is concerned: image

I then rolled back to a0e12b1408ae45a3cc08dfd3e928c9ab8b5a45df (my branch), the last commit on 5.0 branch before the merge, and with global.json some trickery was able to build it. The broken use case is working correctly too: image

I then build 07ae71178eda9d1e4ebf73be44879d969cea7dc5 and lo and behold the icons are there: image

…3 hours bisecting later…

The images disappeared in https://github.com/dotnet/winforms/pull/2659 (21821568afe4f566f2d18cfece56cff666de1955)

There are probably multiple bugs, I was focusing on the regression.

So, yes, there are two distinct issues here:

  1. the loss of icons in certain scenarios,
  2. the loss of the control box in some other scenarios.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Skinned MDI application - the control box disappears after ...
Disable form skinning in the application, and you'll notice that the mdi child's control box is displayed properly. The problem only occurs when ......
Read more >
Prevent MDI child Control box from showing
i Solved it !! simply add this line and disable any changes you made in the Properties window. Child.FormBorderStyle =(FormBorderStyle) ...
Read more >
Thread: Problem with controls on an MDI Form
I have a project with an MDI form The MDI form has a menu on the top. When the user selects a menu...
Read more >
MDI Child Form Problem (not showing)
I am having difficulty with a MDI child/parent relationship for my C# winforms project. I currently have a several controls (button, ...
Read more >
[Solved] Controls inside MDI container form
I have an MDI form and I've put some controls inside it. But when I open any MDI child forms, the controls appear...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found