When an MDI child form gets the focus, its menus replace those of the MDI form. This can make it hard to coordinate the menus that are shared among child forms and those that are unique to each form.
There are two basic approaches. First, you can put all menus used by any child form on the MDI form and then have the children hide those they do not need. Second, you can give each child its own menus, duplicating those that are shared. The first approach is appropriate when the child forms share many common menus. The second is appropriate when they have little in common.
This example demonstrates the first approach.
Click here to see the second approach.
Each child form has two methods ShowMenus and HideMenus. They show/hide the menus used by the form that are not needed when no child form is active. For example, if all child windows and the MDI form all use the same File menu, these routines would not involve that menu.
Note that the child forms all show and hide the mnuFileClose menu item that closes the active form because it doesn't make sense for this menu item to be visible when no child is created.
The following code shows/hides the mnuForm1Menus, mnuFileClose, and mnuFileExitSep menu items for the form Form1.
|