1 / 24

Multiple Document Interface (MDI) application

Multiple Document Interface (MDI) application. Part 1. Objectives. Understand the characteristics of MDI applications Organize the procedures between forms in MDI applications Understand the role of standard forms in an MDI application

Download Presentation

Multiple Document Interface (MDI) application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Multiple Document Interface (MDI) application Part 1

  2. Objectives • Understand the characteristics of MDI applications • Organize the procedures between forms in MDI applications • Understand the role of standard forms in an MDI application • Integrate menus in an MDI application and create context menus • Understand the relationships between events in an MDI application • Manage and organize the forms that make up an MDI application

  3. Solution Organization

  4. Characteristics of MDI Programs • Single-document interface applications • Create one instance of a particular form • Multiple-document interface (MDI) applications • Create multiple instances of the same form • Display those multiple form instances such that they appear inside the region of another form • Excel is an MDI application, for example

  5. MDI Applications • You can use three different types of forms in an MDI application • An MDI parent form acts as the container for the MDI child forms in the solution • An MDI child form always appears inside the visible region of its MDI parent form • A project may have one or more MDI child forms • Standard forms can be displayed anywhere on the screen and are not contained by the MDI parent form • Standard forms are typically displayed as dialog boxes

  6. Characteristics of MDI Applications • MDI child forms can not be extended beyond the visible region of the containing MDI parent form • Iconified MDI child forms do not appear on the task bar • The user positions the icon inside the visible region of the MDI parent form • Menus of MDI parent and MDI child forms are integrated

  7. Displaying an MDI Child Form • Code to create MDI child form appears in MDI parent form • Create the child form instance Dim frmCurrentChild As New frmMdiChild() • Designate the form as a child form frmCurrentChild.MdiParent = Me • Display the child form frmCurrentChild.Show()

  8. Organizing Proceduresin MDI Applications (1) • The following list describes the problems shared by nearly all MDI applications • Procedures and data must often be shared by both MDI parent forms and MDI child forms • An MDI parent form often needs to know which MDI child form instance is active • From the MDI child form, you must often reference members of the MDI parent form or the MDI parent form itself

  9. Organizing Proceduresin MDI Applications (2) • When organizing the procedures and variables in an MDI application, consider the following rules • Locate the procedures that create instances of the MDI child forms in the MDI parent form • In the MDI child form(s), create the procedures responsible for managing each instance of the MDI child form • To share a global reference to the MDI parent form, declare a Friend or global variable in a module file • When the MDI parent form loads, store a reference to the MDI parent form in the Friend or global variable

  10. Standard Forms in MDI Applications • MDI applications can have standard forms • Characteristics • Standard forms typically do not have menus • Standard forms are typically displayed as modal dialog boxes

  11. Menus and MDI Applications • Each MDI parent form and any MDI child form in a solution can have its own menu system • MDI application menus have unique characteristics • One menu bar appears below the title bar of the MDI parent form • An MDI parent form’s menu appears when no MDI child forms are loaded • When an instance of an MDI child form is loaded or has focus, the menu of the MDI parent form is merged with the menu of the MDI child form • Standard forms in an MDI application can have an associated menu but typically they do not

  12. Merging Menus • Menus of MDI parent and MDI child forms are merged based on the following property values: • MergeOrder property • Applies to a MenuItem and contains an Integer value • Indicates the relative order in which two menus or menu items will be merged • MergeType property • Works in conjunction with the MergeOrder property • Defines whether one menu will replace another menu, whether one menu will be added to another menu, or whether menu items will be merged together

  13. The MergeType Property • The MergeType property has a data type of MenuMerge • Possible enumeration values • Add- menu on the MDI child form will be added to the menu of the MDI parent form • MergeItems - menu items on the MDI child form menu will be merged with the menu items on the MDI parent form menu • Remove - MDI parent form menu or menu item will not appear in the merged menu • Replace - causes the menu of the MDI child form to replace the menu appearing on the MDI parent form

  14. Merging Menus (1)

  15. Merging Menus (2)

  16. Merging Menus (3)

  17. Using Menus to Select MDI Child Forms • To select and display an MDI child form from a menu • Set the MdiList property of a menu item to True • This setting causes the menu item to display a list of MDI child form instances • The caption appearing in the menu is the same as the caption appearing in the title bar of the MDI child form • The process is automatic - you need not write any statements to display the MDI child forms

  18. Arranging MDI Child Forms • The LayoutMdi method applies to the MDI parent form • Use to configure display of child forms • Four valid enumeration values • ArrangeIcons - iconified MDI child windows are arranged along the bottom of the MDI parent form • Cascade - visible MDI child windows are arranged such that each MDI child window appears below another MDI child window and is indented • TileHorizontal - divides the MDI child forms horizontally to fill the visible region of the MDI parent form • TileVertical - divides the MDI child forms vertically to fill the visible region of the MDI parent form

  19. Context Menus • Context menus typically appear when the user right-clicks on a control instance or the form itself • To create a context menu: • Create an instance of the ContextMenu control • Create the menu items in-place • Associate the context menu with a form or control instance by setting the ContextMenu property of the desired form or control instance to the context menu

  20. Context Menus (Illustration) Context menu title cannot be changed Menu items

  21. MDI Event Relationships • Windows fires various events as the user navigates from form to form in an MDI application • Events • The Closing event fires for both the MDI parent and MDI child forms • Fires first for all children and then the parent • Event can be cancelled • The Enter event fires for the MDI child form getting focus • Use to update status information • The Leave event fires just before an instance of the MDI child form loses focus

  22. Order of Closing Events

  23. Managing MDI Child Forms • There is no Forms collection to manage the loaded MDI forms of an application • Create a class to enable the developer to add and remove forms from the collection, and enumerate the collection with a For Each loop

  24. Summary • MDI application consists of • MDI form and multiple MDI child forms • Child forms • Can be multiple instances of the same class, or each child can be an instance of different classes • Basics of building an MDI application • Designate one form as an MDI form by setting its IsMdiContainer property to True • Add another form (Form2) to the project, which becomes a child form • Because the form is defined as a class, the (parent) MDI form must instantiate a new (child) form2 (Form2Temp) • Declare Form2Temp’s MdiParent property to be the MDI form itself • Finally, show Form2Temp

More Related