Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleManage menus in an MDI application, approach 2
KeywordsMDI, background, draw, MDIForm, child menus
CategoriesTips and Tricks, Controls
 
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 second approach. Click here to see the first approach.

The MDI form contains only the menu items it should display when there are no child forms. The child forms have their own menus and usually duplicate some common menus like the File menu's Exit command. Visual Basic automatically replaces the program's menus with those of the active child window.

This routine shows how Form1 calls its Black subroutine directly.

 
' Make the form's label black.
Public Sub Black()
    Label1.ForeColor = vbBlack
End Sub
 
This routine shows how Form1 forwards calls to the shared Exit command to the MDI form's Exit command for processing. This way the child forms do not need to duplicate the functionality in the MDI form, just the menu items.
 
Public Sub mnuFileExit_Click()
    MDIForm1.mnuFileExit_Click
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated