VB Migration Partner

KNOWLEDGE BASE - Forms and controls


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 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers