From 3123e582abd928822fcd5f2d55ca201b7ec66b76 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Mon, 16 Apr 2007 13:36:31 +0000 Subject: [PATCH] 2007-04-16 Jonathan Pobst * MdiClient.cs: Implement implicit menu merging for MDI children. When a child form is active, if it has a menustrip and the parent form has a MainMenuStrip, automatically merge the menus. svn path=/trunk/mcs/; revision=75764 --- .../System.Windows.Forms/ChangeLog | 7 +++++++ .../System.Windows.Forms/MdiClient.cs | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index e79307fbde7..9f5b1d6fe02 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,10 @@ +2007-04-16 Jonathan Pobst + + * MdiClient.cs: Implement implicit menu merging for MDI + children. When a child form is active, if it has a menustrip + and the parent form has a MainMenuStrip, automatically merge + the menus. + 2007-04-15 Andreia Gaita * TabControl.cs: Refactored sizing methods to not repeat diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs index e3550f6f0d4..5a14c51eab3 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs @@ -776,6 +776,27 @@ namespace System.Windows.Forms { #if NET_2_0 if (form.MdiParent.MainMenuStrip != null) form.MdiParent.MainMenuStrip.RefreshMdiItems (); + + // Implicit menu strip merging + // - When child is activated + // - Parent form must have a MainMenuStrip + // - Find the first menustrip on the child + // - Merge + MenuStrip parent_menu = form.MdiParent.MainMenuStrip; + + if (parent_menu != null) { + if (parent_menu.IsCurrentlyMerged) + ToolStripManager.RevertMerge (parent_menu); + + MenuStrip child_menu = null; + + foreach (Control c in form.Controls) + if (c is MenuStrip) + child_menu = (MenuStrip)c; + + if (child_menu != null) + ToolStripManager.Merge (child_menu, parent_menu); + } #endif return maximize_this; -- 2.25.1