Creating MDI application: – To create MDI application, follow the following step.
- Start visual basic an open a new project. When new project is opened, select project menu then select and MDI form option to add the parent form. An add MDI form dialog box will appear on the screen. Make sure that new tab is selected. By default it is selected. If it is not selected, selected is then click open to open a new MDI form.
- Set the forms caption to MDI window.
- Choose project menu and select add form to add a regular form.
- Make this form the child form by setting in MDIchild property to true. To denote that this is a chilled form, set its caption property to MDI child form. Visual basic automatically associate this new form with the parent form. This child form cannot exist the parent form.
Menus in MDI: – In an MDI application, the menu for each child are displayed on the MDI form, rather than on the child forms themselves. When a child form has the focus, the child’s menu replaces the MDI form’s menu on the menu bar. If there are no child form visible, if the child with the focus does not have a menu, MDI form menu displayed.
It is common form MDI application to use several sets of menu. When the user open a document, the application displays the menu associated with that type of document. Usually, a different menus is displays when no child form are visible. For example, when there no files are open, Microsoft excel displays only the file and help menu. When the user opens a file, other menus such as file, edit, view, insert, format, tools, data, window and show on are displays.
Creating menus for MDI application: – We can create menus for our visual basic application by addition menu control to the MDI form and to the child form. One way to manage the menus in our MDI application is to place the menu controls we want displays all of the times, even when no child forms are visible, on the MDI form. When we run the application, the MDI forms menu is automatically displayed when there are no child form are visible. Place the menu controls that apply to a child form on the child form. At run time, as long as there is at list one child form visible, these menu titles are displayed in the menu bar of the MDI form. Some application support more the one type of document. For example, in Microsoft access, we can open table, queries, forms and other document type. To create an application such as this in visual basic, use to child form. Design one child with menu that perform spread sheet task and the other with menu that perform charting task.
At run time, when an instance of a spreadsheet form has the focus, the spreadsheet menu is displayed and when the user select, a chart that forms menu is displayed. If all the spreadsheet and chart are closed, the MDI forms is displays.
Sample of MDI application: – A simple text editor is a MDI notepad. This MDI notepad application, however, uses a MDI. At run time, when the user request a new document, the application creates a new instance of the child form. This allows the user to create as many child forms, or documents, as necessary.
To create a document centered application in visual basic, we need at list to forms such as a MDI form and a child form. At design time, we create MDI form to content the application and single child form to serve a template for the application document.