0% found this document useful (0 votes)
74 views24 pages

Multiple Document Interface (MDI) Windows

An MDI (Multiple Document Interface) allows a program to have multiple child windows open within a single parent window. The parent window is called the MDI container and each open document or form is contained within its own child window. Child windows can be manipulated independently but are closed when the parent closes. The LayoutMDI method arranges child windows within the parent window using options like Cascade, TileHorizontal, and TileVertical.

Uploaded by

ARVIND H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views24 pages

Multiple Document Interface (MDI) Windows

An MDI (Multiple Document Interface) allows a program to have multiple child windows open within a single parent window. The parent window is called the MDI container and each open document or form is contained within its own child window. Child windows can be manipulated independently but are closed when the parent closes. The LayoutMDI method arranges child windows within the parent window using options like Cascade, TileHorizontal, and TileVertical.

Uploaded by

ARVIND H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Multiple Document Interface

(MDI) Windows

1
Multiple Document Interface
(MDI) Windows
Single Document Interface (SDI)
 A program that can only support one open
window or a document
 For Example, paint and Notepad are SDI’s
 MDI programs enable users to edit multiple
documents at once.
 For example, Photoshop and Adobe Acrobat
Reader are MDI’s
Single Document Interface Multiple Document Interface
(SDI) (MDI)
Cont.
 The application window of an MDI program is called
the parent window.

 Each window inside the application is referred to as a


child window.
Cont…
 MDI
 Allows multiple windows
 Parent window
 Application window
 Can have many child windows
 Child window
 Cannot be parent
 Has exactly one parent
 Cannot be moved outside parent
 Functionality can be different than other child windows from
same parent
Cont.
How to create and MDI form?
 To create and MDI form, create a new form and set its
IsMDIContainer property to True. The form will
then change appearance
How to create a child?
 Next, create a child form
class to be added to the
form.
 To do this, right-click the
project in the Solution
Explorer, select Add
Windows Form... and
name the file.
Cont.
 To add the child form to the parent, we must create a
new child form object, set its MDIParent property to
the parent form and call method Show:

Dim frmChild As New ChildFormClass()


frmChild.MdiParent = frmParent
frmChild.Show()
MDI Form events and Description / Delegate and Event Arguments
properties
Common MDI Child
Properties
IsMdiChild Indicates whether the Form is an MDI child. If True, Form is an
MDI child (read-only property).
MdiParent Specifies the MDI parent Form of the child.
Common MDI Parent
Properties
ActiveMdiChild Returns the Form that is the currently active MDI child (returns
Nothing if no children are active).
IsMdiContainer Indicates whether a Form can be an MDI parent. If True, the Form
can be an MDI parent. The default value is False.
MdiChildren Returns the MDI children as an array of Forms.
Common Method
LayoutMdi Determines the display of child forms on an MDI parent. Takes as a
parameter an MdiLayout enumeration with possible values
ArrangeIcons, Cascade, TileHorizontal and
TileVertical. Figure 13.36 depicts the effects of these values.
Common Event (Delegate EventHandler, event arguments EventArgs)
MdiChildActivate Generated when an MDI child is closed or activated.
Cont.
 Child windows can be minimized, maximized and
closed independently of each other and of the parent
window.

 When the parent is minimized or closed, the child


windows are minimized or closed as well.
Multiple Document Interface
(MDI) Windows
MdiList Property
 VB .NET provides a property that facilitates the
tracking of which child windows are opened in an MDI
container.
 Property MdiList (a Boolean) of class Menu-
Item determines whether a MenuItem displays a list
of open child windows.
 The list appears at the bottom of the menu following a
separator bar
MdiList Property
 When a new child window is opened, an entry is
added to the list.
 If nine or more child windows are open, the list
includes the option More Windows..., which allows
the user to select a window from a list, using a
scrollbar.
 Multiple MenuItems can have their
MdiList property set; each displays a list of open child
windows.
LayoutMdi Property
 MDI containers allow developers to organize the
placement of child windows.
 The child windows in an MDI application can be
arranged by calling method LayoutMdi of the parent
form.
 Method LayoutMdi takes a LayoutMdi enumeration,
which can have values ArrangeIcons, Cascade,
TileHorizontal and TileVertical.
1 ' Fig. 13.37: UsingMDI.vb
2 ' Demonstrating use of MDI parent and child windows.
3
4 Public Class FrmUsingMDI
5 Private childWindow as FrmChild
6 ' create Child1 when menu clicked
7 Private Sub mnuitmChild1_Click( _
8 ByVal sender As System.Object, _
9 ByVal e As System.EventArgs) Handles mnuitmChild1.Click
10
11 ' create image path
12 Dim imagePath As String = _
13 Directory.GetCurrentDirectory() & "\images\image0.jpg"
14
15 ' create new child
16 childWindow = New FrmChild(imagePath, "Child1")
17 childWindow.MdiParent = Me ' set parent
18 childWindow.Show() ' display child
19 End Sub ' mnuitmChild1_Click
20
21 ' create Child2 when menu clicked
22 Private Sub mnuitmChild2_Click( _
23 ByVal sender As System.Object, _
24 ByVal e As System.EventArgs) Handles
mnuitmChild2.Click
25 ' create image path
26 Dim imagePath As String = _
27 Directory.GetCurrentDirectory() & "\images\image1.jpg"
28
29 ' create new child
30 childWindow = New FrmChild(imagePath, "Child2")
31 childWindow.MdiParent = Me ' set parent
32 childWindow.Show() ' display child
33 End Sub ' mnuitmChild2_Click
34
35 ' create Child3 when menu clicked
36 Private Sub mnuitmChild3_Click( _
37 ByVal sender As System.Object, _
38 ByVal e As System.EventArgs) Handles mnuitmChild3.Click
39
40 ' create image path
41 Dim imagePath As String = _
42 Directory.GetCurrentDirectory() & "\images\image2.jpg"
43 ' create new child
44 childWindow = New FrmChild(imagePath, "Child3")
45 childWindow.MdiParent = Me ' set parent
46 childWindow.Show() ' display child
47 End Sub ' mnuitmChild3_Click
48 ' exit application
49 Private Sub mnuitmExit_Click(ByVal sender As System.Object, _
50 ByVal e As System.EventArgs) Handles mnuitmExit.Click
51
52 Application.Exit()
53 End Sub ' mnuitmExit_Click
55
54 ' set cascade layout
55 Private Sub mnuitmCascade_Click(ByVal sender As System.Object, _
56 ByVal e As System.EventArgs) Handles mnuitmCascade.Click
57
58 Me.LayoutMdi(MdiLayout.Cascade)
59 End Sub ' mnuitmCascade_Click
60
61 ' set TileHorizontal layout Method LayoutMdi can take
62 Private Sub mnuitmTileHorizontal_Click( _ values ArrangeIcons, Cascade,
63 ByVal sender As System.Object, ByVal e As System.EventArgs) _ TileHorizontal and TileVertical
64 Handles mnuitmTileHorizontal.Click
65
66 Me.LayoutMdi(MdiLayout.TileHorizontal)
67 End Sub ' mnuitmTileHorizontal_Click
68 ' set TileVertical layout
69 Private Sub mnuitmTileVertical_Click( _
70 ByVal sender As System.Object, _
71 ByVal e As System.EventArgs) Handles mnuitmTileVertical.Click
72
73 Me.LayoutMdi(MdiLayout.TileVertical)
74 End Sub ' mnuitmTileVertical_Click
75
76 End Class ' FrmUsingMDI
Multiple Document Interface
(MDI) Windows

Demo

You might also like