Multiple document interface mdi application
Download
1 / 24

Multiple Document Interface (MDI) application - PowerPoint PPT Presentation


  • 122 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Multiple Document Interface (MDI) application' - dyan


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Objectives
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



Characteristics of mdi programs
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


Mdi applications
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


Characteristics of mdi applications
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


Displaying an mdi child form
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()


Organizing procedures in mdi applications 1
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


Organizing procedures in mdi applications 2
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


Standard forms in mdi applications
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


Menus and mdi applications
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


Merging menus
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


The mergetype property
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





Using menus to select mdi child forms
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


Arranging mdi child forms
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


Context menus
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


Context menus illustration
Context Menus (Illustration)

Context menu title cannot be changed

Menu items


Mdi event relationships
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



Managing mdi child forms
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


Summary
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


ad