Demonstrating the use of MDI parent and child windows : MDI « GUI « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » GUI » MDI 
13. 57. 2. Demonstrating the use of MDI parent and child windows
Demonstrating the use of MDI parent and child windows
 



Imports System.IO

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class UsingMDI
   public Shared Sub Main
        Application.Run(New FrmUsingMDI)
   End Sub
End class

Public Class FrmUsingMDI
   Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

   Public Sub New()
      MyBase.New()

      'This call is required by the Windows Form Designer.
      InitializeComponent()

      'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
         If Not (components Is NothingThen
            components.Dispose()
         End If
      End If
      MyBase.Dispose(disposing)
   End Sub

   ' main menu containing menu items File and Window
   Friend WithEvents mnuMain As MainMenu

   ' menu containing submenu New and menu item Exit
   Friend WithEvents mnuitmFile As MenuItem
   Friend WithEvents mnuitmExit As MenuItem

   ' submenu New
   Friend WithEvents mnuitmNew As MenuItem
   Friend WithEvents mnuitmChild1 As MenuItem
   Friend WithEvents mnuitmChild2 As MenuItem
   Friend WithEvents mnuitmChild3 As MenuItem

   ' menu containing menu items Cascade, TileHorizontal and 
   ' TileVertical
   Friend WithEvents mnuitmWindow As MenuItem
   Friend WithEvents mnuitmCascade As MenuItem
   Friend WithEvents mnuitmTileHorizontal As MenuItem
   Friend WithEvents mnuitmTileVertical As MenuItem
   'Required by the Windows Form Designer
   Private components As System.ComponentModel.Container

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
      Me.mnuitmTileHorizontal = New System.Windows.Forms.MenuItem()
      Me.mnuitmTileVertical = New System.Windows.Forms.MenuItem()
      Me.mnuitmChild1 = New System.Windows.Forms.MenuItem()
      Me.mnuitmCascade = New System.Windows.Forms.MenuItem()
      Me.mnuitmChild2 = New System.Windows.Forms.MenuItem()
      Me.mnuMain = New System.Windows.Forms.MainMenu()
      Me.mnuitmFile = New System.Windows.Forms.MenuItem()
      Me.mnuitmNew = New System.Windows.Forms.MenuItem()
      Me.mnuitmChild3 = New System.Windows.Forms.MenuItem()
      Me.mnuitmExit = New System.Windows.Forms.MenuItem()
      Me.mnuitmWindow = New System.Windows.Forms.MenuItem()
      '
      'mnuitmTileHorizontal
      '
      Me.mnuitmTileHorizontal.Index = 1
      Me.mnuitmTileHorizontal.Text = "Tile Horizontal"
      '
      'mnuitmTileVertical
      '
      Me.mnuitmTileVertical.Index = 2
      Me.mnuitmTileVertical.Text = "Tile Vertical"
      '
      'mnuitmChild1
      '
      Me.mnuitmChild1.Index = 0
      Me.mnuitmChild1.Text = "Child1"
      '
      'mnuitmCascade
      '
      Me.mnuitmCascade.Index = 0
      Me.mnuitmCascade.Text = "Cascade"
      '
      'mnuitmChild2
      '
      Me.mnuitmChild2.Index = 1
      Me.mnuitmChild2.Text = "Child2"
      '
      'mnuMain
      '
      Me.mnuMain.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmFile, Me.mnuitmWindow})
      '
      'mnuitmFile
      '
      Me.mnuitmFile.Index = 0
      Me.mnuitmFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmNew, Me.mnuitmExit})
      Me.mnuitmFile.Text = "File"
      '
      'mnuitmNew
      '
      Me.mnuitmNew.Index = 0
      Me.mnuitmNew.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmChild1, Me.mnuitmChild2, Me.mnuitmChild3})
      Me.mnuitmNew.Text = "New"
      '
      'mnuitmChild3
      '
      Me.mnuitmChild3.Index = 2
      Me.mnuitmChild3.Text = "Child3"
      '
      'mnuitmExit
      '
      Me.mnuitmExit.Index = 1
      Me.mnuitmExit.Text = "Exit"
      '
      'mnuitmWindow
      '
      Me.mnuitmWindow.Index = 1
      Me.mnuitmWindow.MdiList = True
      Me.mnuitmWindow.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmCascade, Me.mnuitmTileHorizontal, Me.mnuitmTileVertical})
      Me.mnuitmWindow.Text = "Window"
      '
      'FrmUsingMDI
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(513)
      Me.ClientSize = New System.Drawing.Size(360301)
      Me.IsMdiContainer = True
      Me.Menu = Me.mnuMain
      Me.Name = "FrmUsingMDI"
      Me.Text = "UsingMDI"

   End Sub

#End Region
   Private childWindow As FrmChild

   Private Sub mnuitmChild1_Click_
      ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles mnuitmChild1.Click

      childWindow = New FrmChild("Child1")
      childWindow.MdiParent = Me 
      childWindow.Show()         
   End Sub 

   Private Sub mnuitmChild2_Click_
      ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles mnuitmChild2.Click

      childWindow = New FrmChild("Child2")
      childWindow.MdiParent = Me 
      childWindow.Show()         
   End Sub 

   Private Sub mnuitmChild3_Click_
      ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles mnuitmChild3.Click


      childWindow = New FrmChild("Child3")
      childWindow.MdiParent = Me 
      childWindow.Show()         
   End Sub 
   
   Private Sub mnuitmExit_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles mnuitmExit.Click

      Application.Exit()
   End Sub 
   
   Private Sub mnuitmCascade_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles mnuitmCascade.Click

      Me.LayoutMdi(MdiLayout.Cascade)
   End Sub
   
   Private Sub mnuitmTileHorizontal_Click _
      (ByVal sender As System.Object, ByVal e As System.EventArgs_
      Handles mnuitmTileHorizontal.Click

      Me.LayoutMdi(MdiLayout.TileHorizontal)
   End Sub

   Private Sub mnuitmTileVertical_Click _
      (ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles mnuitmTileVertical.Click

      Me.LayoutMdi(MdiLayout.TileVertical)
   End Sub

End Class

Public Class FrmChild
   Inherits Form

#Region " Windows Form Designer generated code "

   Public Sub New()
      MyBase.New()

      'This call is required by the Windows Form Designer.
      InitializeComponent()

      'Add any initialization after the InitializeComponent() call

   End Sub

   '   Public Sub New(ByVal imageInformation As String, ByVal windowName As String)
   '      Display(imageInformation, windowName)
   '   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
         If Not (components Is NothingThen
            components.Dispose()
         End If
      End If
      MyBase.Dispose(disposing)
   End Sub

   ' contains an image loaded from disk
   Friend WithEvents picDisplay As PictureBox

   'Required by the Windows Form Designer
   Private components As System.ComponentModel.Container

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
      Me.picDisplay = New System.Windows.Forms.PictureBox()
      Me.SuspendLayout()
      '
      'picDisplay
      '
      Me.picDisplay.Location = New System.Drawing.Point(88)
      Me.picDisplay.Name = "picDisplay"
      Me.picDisplay.Size = New System.Drawing.Size(256208)
      Me.picDisplay.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
      Me.picDisplay.TabIndex = 0
      Me.picDisplay.TabStop = False
      '
      'FrmChild1
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(513)
      Me.ClientSize = New System.Drawing.Size(272221)
      Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.picDisplay})
      Me.Name = "FrmChild"
      Me.Text = ""
      Me.ResumeLayout(False)

   End Sub

#End Region

   Public Sub NewByVal name As String)
      Me.New()

      Me.Text = name

      picDisplay.Image = Image.FromFile("YourFile.bmp")
   End Sub  ' New

End Class 

        
13. 57. MDI
13. 57. 1. MDI Children Form ArrayMDI Children Form Array
13. 57. 2. Demonstrating the use of MDI parent and child windowsDemonstrating the use of MDI parent and child windows
13. 57. 3. Use a tree to manage MDI Child windowUse a tree to manage MDI Child window
13. 57. 4. RichText MDI EditorRichText MDI Editor
13. 57. 5. Add children form to parent formAdd children form to parent form
13. 57. 6. Open children window in menu actionOpen children window in menu action
w_w__w_.___ja___v___a___2__s__.__c_om | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.