Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Multiple Document Interface (MDI) Windows. Single Document Interface (SDI) A program that can only support one open window or a document For Example,

Similar presentations


Presentation on theme: "1 Multiple Document Interface (MDI) Windows. Single Document Interface (SDI) A program that can only support one open window or a document For Example,"— Presentation transcript:

1 1 Multiple Document Interface (MDI) Windows

2 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 Multiple Document Interface (MDI) Windows

3 Single Document Interface (SDI) Multiple Document Interface (MDI)

4 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.

5 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

6 Cont.

7 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

8 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.

9 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()

10

11 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.

12 Multiple Document Interface (MDI) Windows

13 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

14 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. MdiList Property

15

16

17 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.

18

19

20 1 ' Fig. 13.37: UsingMDI.vb 2 ' Demonstrating use of MDI parent and child windows. 3 4Public Class FrmUsingMDI 5Private 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

21 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

22 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 62 Private Sub mnuitmTileHorizontal_Click( _ 63 ByVal sender As System.Object, ByVal e As System.EventArgs) _ 64 Handles mnuitmTileHorizontal.Click 65 66 Me.LayoutMdi(MdiLayout.TileHorizontal) 67 End Sub ' mnuitmTileHorizontal_Click Method LayoutMdi can take values ArrangeIcons, Cascade, TileHorizontal and TileVertical

23 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

24 Multiple Document Interface (MDI) Windows Demo


Download ppt "1 Multiple Document Interface (MDI) Windows. Single Document Interface (SDI) A program that can only support one open window or a document For Example,"

Similar presentations


Ads by Google