Previous | Index | Next 

[PRB] Menus on MDI child forms doesn’t replace the toplevel menu of the MDI parent form

MDI applications written in VB6 exhibit the following behavior: when an MDI child form becomes active, its menu bar replaces the MDI parent form’s menu bar. MDI child forms never display a menu of their own under VB6.

MDI applications written in VB.NET have a different behavior: when an MDI child form becomes active, its menu bar is appended or merged with the MDI parent form’s menu bar and the exact result depends on the MergeAction property of individual menu items. If this property dictates that a given toplevel menu must not be appended or merged with the MDI parent form’s menu, then the menu command remains visible on the MDI child form’s menu.

All versions of VB Migration Partner up to 1.31 always append all the menu items in the MDI child form’s menu to the MDI parent form’s menu bar, a behavior that gives you more freedom in how the two menus are displayed. For example, you can set the MergeAction and MergeIndex properties of menu items on the MDI child form to obtain exactly what you want. However, this behavior reduces compatibility with the original VB6 application.

Starting with VB Migration Partner version 1.32, the VB6MdiForm class exposes a new Boolean property named HideMainMenuOnChildFormActivate. If this property is False (the default value), menus are merged as they were in previous versions. If this property is set to True, however, the menus on the MDI child form replace the toplevel menus in the MDI parent form, as it happens in VB6.

The simplest way to set this property is by means of a WriteProperty pragma in the MDI parent form, so that you don’t have to manually modify the generated VB.NET code at each subsequent migration:

        '## WriteProperty HideMainMenuOnChildFormActivate, True

Notice that the VB6 behavior can’t be emulated perfectly, though. In fact, when a VB6 child form becomes active, its menu bar is hidden completely and doesn’t occupy any space on the form. This means that the form’s height is decreased accordingly and that controls that are located immediately below the menu bar (at design time) appear to be located immediately under the form’s titlebar at runtime.

Conversely, if the HideMainMenuOnChildFormActivate property is set to True, the MDI child form’s toplevel menus are made invisible, but the menu bar still takes space and the form’s height isn’t affected.

 

Previous | Index | Next