'Visual Basic 2005 Programmer's Reference
'by Rod Stephens (Author)
'# Publisher: Wrox (October 21, 2005)
'# Language: English
'# ISBN-10: 0764571982
'# ISBN-13: 978-0764571985
Imports System.IO
Imports System.Windows.Forms
public class MDIParentEditor2
public Shared Sub Main
Application.Run(New MDIParent1)
End Sub
End class
Public Class MDIParent1
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
Dim frm As New Form1
frm.MdiParent = Me
frm.Show()
End Sub
Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click, OpenToolStripButton.Click
Dim dlgOpen As New OpenFileDialog
If dlgOpen.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
Dim frm As New Form1
frm.txtContents.Text = File.ReadAllText(dlgOpen.FileName)
frm.txtContents.Select(0, 0)
frm.Text = New FileInfo(dlgOpen.FileName).Name
frm.MdiParent = Me
frm.Show()
End If
End Sub
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt"
SaveFileDialog.ShowDialog(Me)
Dim FileName As String = SaveFileDialog.FileName
Console.WriteLine("save to "+ FileName)
End Sub
Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ToolBarToolStripMenuItem.Click
Me.ToolStrip.Visible = Me.ToolBarToolStripMenuItem.Checked
End Sub
Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles StatusBarToolStripMenuItem.Click
Me.StatusStrip.Visible = Me.StatusBarToolStripMenuItem.Checked
End Sub
Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub TileVerticleToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub
Private Sub MinimizeAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinimizeAllToolStripMenuItem.Click
For Each frm As Form In Me.MdiChildren
frm.WindowState = FormWindowState.Minimized
Next frm
End Sub
Private Sub RestoreAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RestoreAllToolStripMenuItem.Click
For Each frm As Form In Me.MdiChildren
frm.WindowState = FormWindowState.Normal
Next frm
End Sub
Private Sub MaximizeAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaximizeAllToolStripMenuItem.Click
For Each frm As Form In Me.MdiChildren
frm.WindowState = FormWindowState.Maximized
Next frm
End Sub
Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click
For Each frm As Form In Me.MdiChildren
frm.Close()
Next
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class MDIParent1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'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.components = New System.ComponentModel.Container
Me.ContentsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.HelpMenu = New System.Windows.Forms.ToolStripMenuItem
Me.IndexToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SearchToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator8 = New System.Windows.Forms.ToolStripSeparator
Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ArrangeIconsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.CloseAllToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.NewWindowToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.WindowsMenu = New System.Windows.Forms.ToolStripMenuItem
Me.CascadeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.TileVerticalToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.TileHorizontalToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.OptionsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.HelpToolStripButton = New System.Windows.Forms.ToolStripButton
Me.ToolStripSeparator2 = New System.Windows.Forms.ToolStripSeparator
Me.PrintPreviewToolStripButton = New System.Windows.Forms.ToolStripButton
Me.ToolTip = New System.Windows.Forms.ToolTip(Me.components)
Me.ToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me.StatusStrip = New System.Windows.Forms.StatusStrip
Me.PrintToolStripButton = New System.Windows.Forms.ToolStripButton
Me.NewToolStripButton = New System.Windows.Forms.ToolStripButton
Me.ToolStrip = New System.Windows.Forms.ToolStrip
Me.OpenToolStripButton = New System.Windows.Forms.ToolStripButton
Me.SaveToolStripButton = New System.Windows.Forms.ToolStripButton
Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator
Me.PrintPreviewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.PrintToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator4 = New System.Windows.Forms.ToolStripSeparator
Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator5 = New System.Windows.Forms.ToolStripSeparator
Me.PrintSetupToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SaveAsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.NewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.FileMenu = New System.Windows.Forms.ToolStripMenuItem
Me.OpenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator
Me.SaveToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.MenuStrip = New System.Windows.Forms.MenuStrip
Me.EditMenu = New System.Windows.Forms.ToolStripMenuItem
Me.UndoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.RedoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator6 = New System.Windows.Forms.ToolStripSeparator
Me.CutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.CopyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.PasteToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator7 = New System.Windows.Forms.ToolStripSeparator
Me.SelectAllToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ViewMenu = New System.Windows.Forms.ToolStripMenuItem
Me.ToolBarToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StatusBarToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolsMenu = New System.Windows.Forms.ToolStripMenuItem
Me.MaximizeAllToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.MinimizeAllToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.RestoreAllToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StatusStrip.SuspendLayout()
Me.ToolStrip.SuspendLayout()
Me.MenuStrip.SuspendLayout()
Me.SuspendLayout()
'
'ContentsToolStripMenuItem
'
Me.ContentsToolStripMenuItem.Name = "ContentsToolStripMenuItem"
Me.ContentsToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.F1), System.Windows.Forms.Keys)
Me.ContentsToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.ContentsToolStripMenuItem.Text = "&Contents"
'
'HelpMenu
'
Me.HelpMenu.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContentsToolStripMenuItem, Me.IndexToolStripMenuItem, Me.SearchToolStripMenuItem, Me.ToolStripSeparator8, Me.AboutToolStripMenuItem})
Me.HelpMenu.Name = "HelpMenu"
Me.HelpMenu.Size = New System.Drawing.Size(49, 20)
Me.HelpMenu.Text = "&Help"
'
'IndexToolStripMenuItem
'
Me.IndexToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.IndexToolStripMenuItem.Name = "IndexToolStripMenuItem"
Me.IndexToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.IndexToolStripMenuItem.Text = "&Index"
'
'SearchToolStripMenuItem
'
Me.SearchToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.SearchToolStripMenuItem.Name = "SearchToolStripMenuItem"
Me.SearchToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.SearchToolStripMenuItem.Text = "&Search"
'
'ToolStripSeparator8
'
Me.ToolStripSeparator8.Name = "ToolStripSeparator8"
Me.ToolStripSeparator8.Size = New System.Drawing.Size(191, 6)
'
'AboutToolStripMenuItem
'
Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem"
Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.AboutToolStripMenuItem.Text = "&About ..."
'
'ArrangeIconsToolStripMenuItem
'
Me.ArrangeIconsToolStripMenuItem.Name = "ArrangeIconsToolStripMenuItem"
Me.ArrangeIconsToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.ArrangeIconsToolStripMenuItem.Text = "&Arrange Icons"
'
'CloseAllToolStripMenuItem
'
Me.CloseAllToolStripMenuItem.Name = "CloseAllToolStripMenuItem"
Me.CloseAllToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.CloseAllToolStripMenuItem.Text = "C&lose All"
'
'NewWindowToolStripMenuItem
'
Me.NewWindowToolStripMenuItem.Name = "NewWindowToolStripMenuItem"
Me.NewWindowToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.NewWindowToolStripMenuItem.Text = "&New Window"
'
'WindowsMenu
'
Me.WindowsMenu.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewWindowToolStripMenuItem, Me.CascadeToolStripMenuItem, Me.TileVerticalToolStripMenuItem, Me.TileHorizontalToolStripMenuItem, Me.MinimizeAllToolStripMenuItem, Me.MaximizeAllToolStripMenuItem, Me.RestoreAllToolStripMenuItem, Me.CloseAllToolStripMenuItem, Me.ArrangeIconsToolStripMenuItem})
Me.WindowsMenu.Name = "WindowsMenu"
Me.WindowsMenu.Size = New System.Drawing.Size(78, 20)
Me.WindowsMenu.Text = "&Windows"
'
'CascadeToolStripMenuItem
'
Me.CascadeToolStripMenuItem.Name = "CascadeToolStripMenuItem"
Me.CascadeToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.CascadeToolStripMenuItem.Text = "&Cascade"
'
'TileVerticalToolStripMenuItem
'
Me.TileVerticalToolStripMenuItem.Name = "TileVerticalToolStripMenuItem"
Me.TileVerticalToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.TileVerticalToolStripMenuItem.Text = "Tile &Vertical"
'
'TileHorizontalToolStripMenuItem
'
Me.TileHorizontalToolStripMenuItem.Name = "TileHorizontalToolStripMenuItem"
Me.TileHorizontalToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.TileHorizontalToolStripMenuItem.Text = "Tile &Horizontal"
'
'OptionsToolStripMenuItem
'
Me.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem"
Me.OptionsToolStripMenuItem.Size = New System.Drawing.Size(152, 22)
Me.OptionsToolStripMenuItem.Text = "&Options"
'
'HelpToolStripButton
'
Me.HelpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.HelpToolStripButton.ImageTransparentColor = System.Drawing.Color.Black
Me.HelpToolStripButton.Name = "HelpToolStripButton"
Me.HelpToolStripButton.Size = New System.Drawing.Size(23, 22)
Me.HelpToolStripButton.Text = "Help"
'
'ToolStripSeparator2
'
Me.ToolStripSeparator2.Name = "ToolStripSeparator2"
Me.ToolStripSeparator2.Size = New System.Drawing.Size(6, 25)
'
'PrintPreviewToolStripButton
'
Me.PrintPreviewToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.PrintPreviewToolStripButton.ImageTransparentColor = System.Drawing.Color.Black
Me.PrintPreviewToolStripButton.Name = "PrintPreviewToolStripButton"
Me.PrintPreviewToolStripButton.Size = New System.Drawing.Size(23, 22)
Me.PrintPreviewToolStripButton.Text = "Print Preview"
'
'ToolStripStatusLabel
'
Me.ToolStripStatusLabel.Name = "ToolStripStatusLabel"
Me.ToolStripStatusLabel.Size = New System.Drawing.Size(47, 17)
Me.ToolStripStatusLabel.Text = "Status"
'
'StatusStrip
'
Me.StatusStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel})
Me.StatusStrip.Location = New System.Drawing.Point(0, 431)
Me.StatusStrip.Name = "StatusStrip"
Me.StatusStrip.Size = New System.Drawing.Size(632, 22)
Me.StatusStrip.TabIndex = 7
Me.StatusStrip.Text = "StatusStrip"
'
'PrintToolStripButton
'
Me.PrintToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.PrintToolStripButton.ImageTransparentColor = System.Drawing.Color.Black
Me.PrintToolStripButton.Name = "PrintToolStripButton"
Me.PrintToolStripButton.Size = New System.Drawing.Size(23, 22)
Me.PrintToolStripButton.Text = "Print"
'
'NewToolStripButton
'
Me.NewToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.NewToolStripButton.ImageTransparentColor = System.Drawing.Color.Black
Me.NewToolStripButton.Name = "NewToolStripButton"
Me.NewToolStripButton.Size = New System.Drawing.Size(23, 22)
Me.NewToolStripButton.Text = "New"
'
'ToolStrip
'
Me.ToolStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewToolStripButton, Me.OpenToolStripButton, Me.SaveToolStripButton, Me.ToolStripSeparator1, Me.PrintToolStripButton, Me.PrintPreviewToolStripButton, Me.ToolStripSeparator2, Me.HelpToolStripButton})
Me.ToolStrip.Location = New System.Drawing.Point(0, 24)
Me.ToolStrip.Name = "ToolStrip"
Me.ToolStrip.Size = New System.Drawing.Size(632, 25)
Me.ToolStrip.TabIndex = 6
Me.ToolStrip.Text = "ToolStrip"
'
'OpenToolStripButton
'
Me.OpenToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.OpenToolStripButton.ImageTransparentColor = System.Drawing.Color.Black
Me.OpenToolStripButton.Name = "OpenToolStripButton"
Me.OpenToolStripButton.Size = New System.Drawing.Size(23, 22)
Me.OpenToolStripButton.Text = "Open"
'
'SaveToolStripButton
'
Me.SaveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.SaveToolStripButton.ImageTransparentColor = System.Drawing.Color.Black
Me.SaveToolStripButton.Name = "SaveToolStripButton"
Me.SaveToolStripButton.Size = New System.Drawing.Size(23, 22)
Me.SaveToolStripButton.Text = "Save"
'
'ToolStripSeparator1
'
Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
Me.ToolStripSeparator1.Size = New System.Drawing.Size(6, 25)
'
'PrintPreviewToolStripMenuItem
'
Me.PrintPreviewToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.PrintPreviewToolStripMenuItem.Name = "PrintPreviewToolStripMenuItem"
Me.PrintPreviewToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.PrintPreviewToolStripMenuItem.Text = "Print Pre&view"
'
'PrintToolStripMenuItem
'
Me.PrintToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.PrintToolStripMenuItem.Name = "PrintToolStripMenuItem"
Me.PrintToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.P), System.Windows.Forms.Keys)
Me.PrintToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.PrintToolStripMenuItem.Text = "&Print"
'
'ToolStripSeparator4
'
Me.ToolStripSeparator4.Name = "ToolStripSeparator4"
Me.ToolStripSeparator4.Size = New System.Drawing.Size(169, 6)
'
'ExitToolStripMenuItem
'
Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem"
Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.ExitToolStripMenuItem.Text = "E&xit"
'
'ToolStripSeparator5
'
Me.ToolStripSeparator5.Name = "ToolStripSeparator5"
Me.ToolStripSeparator5.Size = New System.Drawing.Size(169, 6)
'
'PrintSetupToolStripMenuItem
'
Me.PrintSetupToolStripMenuItem.Name = "PrintSetupToolStripMenuItem"
Me.PrintSetupToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.PrintSetupToolStripMenuItem.Text = "Print Setup"
'
'SaveAsToolStripMenuItem
'
Me.SaveAsToolStripMenuItem.Name = "SaveAsToolStripMenuItem"
Me.SaveAsToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.SaveAsToolStripMenuItem.Text = "Save &As"
'
'NewToolStripMenuItem
'
Me.NewToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.NewToolStripMenuItem.Name = "NewToolStripMenuItem"
Me.NewToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.N), System.Windows.Forms.Keys)
Me.NewToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.NewToolStripMenuItem.Text = "&New"
'
'FileMenu
'
Me.FileMenu.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewToolStripMenuItem, Me.OpenToolStripMenuItem, Me.ToolStripSeparator3, Me.SaveToolStripMenuItem, Me.SaveAsToolStripMenuItem, Me.ToolStripSeparator4, Me.PrintToolStripMenuItem, Me.PrintPreviewToolStripMenuItem, Me.PrintSetupToolStripMenuItem, Me.ToolStripSeparator5, Me.ExitToolStripMenuItem})
Me.FileMenu.ImageTransparentColor = System.Drawing.SystemColors.ActiveBorder
Me.FileMenu.Name = "FileMenu"
Me.FileMenu.Size = New System.Drawing.Size(44, 20)
Me.FileMenu.Text = "&File"
'
'OpenToolStripMenuItem
'
Me.OpenToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.OpenToolStripMenuItem.Name = "OpenToolStripMenuItem"
Me.OpenToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.O), System.Windows.Forms.Keys)
Me.OpenToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.OpenToolStripMenuItem.Text = "&Open"
'
'ToolStripSeparator3
'
Me.ToolStripSeparator3.Name = "ToolStripSeparator3"
Me.ToolStripSeparator3.Size = New System.Drawing.Size(169, 6)
'
'SaveToolStripMenuItem
'
Me.SaveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"
Me.SaveToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.S), System.Windows.Forms.Keys)
Me.SaveToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.SaveToolStripMenuItem.Text = "&Save"
'
'MenuStrip
'
Me.MenuStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileMenu, Me.EditMenu, Me.ViewMenu, Me.ToolsMenu, Me.WindowsMenu, Me.HelpMenu})
Me.MenuStrip.Location = New System.Drawing.Point(0, 0)
Me.MenuStrip.MdiWindowListItem = Me.WindowsMenu
Me.MenuStrip.Name = "MenuStrip"
Me.MenuStrip.Size = New System.Drawing.Size(632, 24)
Me.MenuStrip.TabIndex = 5
Me.MenuStrip.Text = "MenuStrip"
'
'EditMenu
'
Me.EditMenu.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.UndoToolStripMenuItem, Me.RedoToolStripMenuItem, Me.ToolStripSeparator6, Me.CutToolStripMenuItem, Me.CopyToolStripMenuItem, Me.PasteToolStripMenuItem, Me.ToolStripSeparator7, Me.SelectAllToolStripMenuItem})
Me.EditMenu.Name = "EditMenu"
Me.EditMenu.Size = New System.Drawing.Size(44, 20)
Me.EditMenu.Text = "&Edit"
'
'UndoToolStripMenuItem
'
Me.UndoToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.UndoToolStripMenuItem.Name = "UndoToolStripMenuItem"
Me.UndoToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys)
Me.UndoToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.UndoToolStripMenuItem.Text = "&Undo"
'
'RedoToolStripMenuItem
'
Me.RedoToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.RedoToolStripMenuItem.Name = "RedoToolStripMenuItem"
Me.RedoToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Y), System.Windows.Forms.Keys)
Me.RedoToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.RedoToolStripMenuItem.Text = "&Redo"
'
'ToolStripSeparator6
'
Me.ToolStripSeparator6.Name = "ToolStripSeparator6"
Me.ToolStripSeparator6.Size = New System.Drawing.Size(191, 6)
'
'CutToolStripMenuItem
'
Me.CutToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.CutToolStripMenuItem.Name = "CutToolStripMenuItem"
Me.CutToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.X), System.Windows.Forms.Keys)
Me.CutToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.CutToolStripMenuItem.Text = "Cu&t"
'
'CopyToolStripMenuItem
'
Me.CopyToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.CopyToolStripMenuItem.Name = "CopyToolStripMenuItem"
Me.CopyToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys)
Me.CopyToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.CopyToolStripMenuItem.Text = "&Copy"
'
'PasteToolStripMenuItem
'
Me.PasteToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black
Me.PasteToolStripMenuItem.Name = "PasteToolStripMenuItem"
Me.PasteToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.V), System.Windows.Forms.Keys)
Me.PasteToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.PasteToolStripMenuItem.Text = "&Paste"
'
'ToolStripSeparator7
'
Me.ToolStripSeparator7.Name = "ToolStripSeparator7"
Me.ToolStripSeparator7.Size = New System.Drawing.Size(191, 6)
'
'SelectAllToolStripMenuItem
'
Me.SelectAllToolStripMenuItem.Name = "SelectAllToolStripMenuItem"
Me.SelectAllToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.A), System.Windows.Forms.Keys)
Me.SelectAllToolStripMenuItem.Size = New System.Drawing.Size(194, 22)
Me.SelectAllToolStripMenuItem.Text = "Select &All"
'
'ViewMenu
'
Me.ViewMenu.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolBarToolStripMenuItem, Me.StatusBarToolStripMenuItem})
Me.ViewMenu.Name = "ViewMenu"
Me.ViewMenu.Size = New System.Drawing.Size(52, 20)
Me.ViewMenu.Text = "&View"
'
'ToolBarToolStripMenuItem
'
Me.ToolBarToolStripMenuItem.Checked = True
Me.ToolBarToolStripMenuItem.CheckOnClick = True
Me.ToolBarToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked
Me.ToolBarToolStripMenuItem.Name = "ToolBarToolStripMenuItem"
Me.ToolBarToolStripMenuItem.Size = New System.Drawing.Size(152, 22)
Me.ToolBarToolStripMenuItem.Text = "&Toolbar"
'
'StatusBarToolStripMenuItem
'
Me.StatusBarToolStripMenuItem.Checked = True
Me.StatusBarToolStripMenuItem.CheckOnClick = True
Me.StatusBarToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked
Me.StatusBarToolStripMenuItem.Name = "StatusBarToolStripMenuItem"
Me.StatusBarToolStripMenuItem.Size = New System.Drawing.Size(152, 22)
Me.StatusBarToolStripMenuItem.Text = "&Status Bar"
'
'ToolsMenu
'
Me.ToolsMenu.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OptionsToolStripMenuItem})
Me.ToolsMenu.Name = "ToolsMenu"
Me.ToolsMenu.Size = New System.Drawing.Size(54, 20)
Me.ToolsMenu.Text = "&Tools"
'
'MaximizeAllToolStripMenuItem
'
Me.MaximizeAllToolStripMenuItem.Name = "MaximizeAllToolStripMenuItem"
Me.MaximizeAllToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.MaximizeAllToolStripMenuItem.Text = "Ma&ximize All"
'
'MinimizeAllToolStripMenuItem
'
Me.MinimizeAllToolStripMenuItem.Name = "MinimizeAllToolStripMenuItem"
Me.MinimizeAllToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.MinimizeAllToolStripMenuItem.Text = "&Minimize All"
'
'RestoreAllToolStripMenuItem
'
Me.RestoreAllToolStripMenuItem.Name = "RestoreAllToolStripMenuItem"
Me.RestoreAllToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.RestoreAllToolStripMenuItem.Text = "&Restore All"
'
'MDIParent1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(632, 453)
Me.Controls.Add(Me.ToolStrip)
Me.Controls.Add(Me.MenuStrip)
Me.Controls.Add(Me.StatusStrip)
Me.IsMdiContainer = True
Me.MainMenuStrip = Me.MenuStrip
Me.Name = "MDIParent1"
Me.Text = "MDIParent1"
Me.StatusStrip.ResumeLayout(False)
Me.StatusStrip.PerformLayout()
Me.ToolStrip.ResumeLayout(False)
Me.ToolStrip.PerformLayout()
Me.MenuStrip.ResumeLayout(False)
Me.MenuStrip.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ContentsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents HelpMenu As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents IndexToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SearchToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator8 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents AboutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ArrangeIconsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CloseAllToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents NewWindowToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents WindowsMenu As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CascadeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TileVerticalToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TileHorizontalToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents OptionsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents HelpToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolStripSeparator2 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents PrintPreviewToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolTip As System.Windows.Forms.ToolTip
Friend WithEvents ToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Friend WithEvents StatusStrip As System.Windows.Forms.StatusStrip
Friend WithEvents PrintToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents NewToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolStrip As System.Windows.Forms.ToolStrip
Friend WithEvents OpenToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents SaveToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents PrintPreviewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PrintToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator4 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator5 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents PrintSetupToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SaveAsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents NewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FileMenu As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents OpenToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator3 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents SaveToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents MenuStrip As System.Windows.Forms.MenuStrip
Friend WithEvents EditMenu As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents UndoToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents RedoToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator6 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents CutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CopyToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PasteToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator7 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents SelectAllToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ViewMenu As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolBarToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StatusBarToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolsMenu As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents MinimizeAllToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents MaximizeAllToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents RestoreAllToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
End Class
Public Class Form1
Private m_FileName As String
Private m_IsDirty As Boolean
' Load a file and set the form's MdiParent.
Public Sub LoadFile(ByVal file_name As String, ByVal mdi_parent As MDIParent1)
' Save the file name and MdiParent.
m_FileName = file_name
Me.MdiParent = mdi_parent
' Load the file.
txtContents.Text = File.ReadAllText(m_FileName)
txtContents.Select(0, 0)
' Display the file name.
Me.Text = New FileInfo(m_FileName).Name
' The data has not been modified since it was loaded.
m_IsDirty = False
End Sub
' Close the form.
Private Sub mnuFileClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileClose.Click
Me.Close()
End Sub
' See if it's safe to close the form.
Private Sub mdiChild_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If m_IsDirty Then
' There are unsaved changes.
' Ask the user if we should save them.
Select Case MessageBox.Show( _
"The data has changed. Save the changes?", _
"Save Changes?", _
MessageBoxButtons.YesNoCancel, _
MessageBoxIcon.Question)
Case Windows.Forms.DialogResult.Yes
' Save the changes.
SaveFile()
' See if we succeeded.
e.Cancel = m_IsDirty
Case Windows.Forms.DialogResult.No
' Discard the changes.
' Leave e.Cancel = False.
Case Windows.Forms.DialogResult.Cancel
' Cancel the close.
e.Cancel = True
End Select
End If
End Sub
' Save the file.
Private Sub SaveFile()
File.WriteAllText(m_FileName, txtContents.Text)
m_IsDirty = False
Me.Text = New FileInfo(m_FileName).Name
End Sub
' Mark the data as modified.
Private Sub txtContents_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtContents.TextChanged
m_IsDirty = True
If Not Me.Text.EndsWith("*") Then
Me.Text = New FileInfo(m_FileName).Name & "*"
End If
End Sub
' Save the changes.
Private Sub mnuFileSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click
SaveFile()
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'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.txtContents = New System.Windows.Forms.TextBox
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip
Me.mnuFile = New System.Windows.Forms.ToolStripMenuItem
Me.mnuFileSave = New System.Windows.Forms.ToolStripMenuItem
Me.mnuFileClose = New System.Windows.Forms.ToolStripMenuItem
Me.MenuStrip1.SuspendLayout()
Me.SuspendLayout()
'
'txtContents
'
Me.txtContents.Dock = System.Windows.Forms.DockStyle.Fill
Me.txtContents.Location = New System.Drawing.Point(0, 24)
Me.txtContents.Multiline = True
Me.txtContents.Name = "txtContents"
Me.txtContents.Size = New System.Drawing.Size(292, 249)
Me.txtContents.TabIndex = 7
'
'MenuStrip1
'
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuFile})
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
Me.MenuStrip1.Name = "MenuStrip1"
Me.MenuStrip1.Size = New System.Drawing.Size(292, 24)
Me.MenuStrip1.TabIndex = 8
Me.MenuStrip1.Text = "MenuStrip1"
'
'mnuFile
'
Me.mnuFile.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuFileSave, Me.mnuFileClose})
Me.mnuFile.Name = "mnuFile"
Me.mnuFile.Size = New System.Drawing.Size(44, 20)
Me.mnuFile.Text = "&File"
'
'mnuFileSave
'
Me.mnuFileSave.Name = "mnuFileSave"
Me.mnuFileSave.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.S), System.Windows.Forms.Keys)
Me.mnuFileSave.Size = New System.Drawing.Size(165, 22)
Me.mnuFileSave.Text = "&Save"
'
'mnuFileClose
'
Me.mnuFileClose.Name = "mnuFileClose"
Me.mnuFileClose.Size = New System.Drawing.Size(165, 22)
Me.mnuFileClose.Text = "&Close"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.txtContents)
Me.Controls.Add(Me.MenuStrip1)
Me.Name = "Form1"
Me.Text = "MdiEdit []"
Me.MenuStrip1.ResumeLayout(False)
Me.MenuStrip1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents txtContents As System.Windows.Forms.TextBox
Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
Friend WithEvents mnuFile As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents mnuFileSave As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents mnuFileClose As System.Windows.Forms.ToolStripMenuItem
End Class
|