⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 Visual.Basic.NET实用编程百例-47.6M.zip
💻 VB
字号:
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim count As Integer = 0

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()
        Form0 = Me
        '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 Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents MdiClient1 As System.Windows.Forms.MdiClient
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents miFile As System.Windows.Forms.MenuItem
    Friend WithEvents miAdd As System.Windows.Forms.MenuItem
    Friend WithEvents miExit As System.Windows.Forms.MenuItem
    Friend WithEvents misp1 As System.Windows.Forms.MenuItem
    Private WithEvents Form0 As System.Windows.Forms.Form
    '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.misp1 = New System.Windows.Forms.MenuItem
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.miFile = New System.Windows.Forms.MenuItem
        Me.miAdd = New System.Windows.Forms.MenuItem
        Me.miExit = New System.Windows.Forms.MenuItem
        Me.MdiClient1 = New System.Windows.Forms.MdiClient
        Me.SuspendLayout()
        '
        'misp1
        '
        Me.misp1.Index = 1
        Me.misp1.Text = "-"
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miFile})
        '
        'miFile
        '
        Me.miFile.Index = 0
        Me.miFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miAdd, Me.misp1, Me.miExit})
        Me.miFile.MergeType = System.Windows.Forms.MenuMerge.MergeItems
        Me.miFile.Text = "&File"
        '
        'miAdd
        '
        Me.miAdd.Index = 0
        Me.miAdd.Shortcut = System.Windows.Forms.Shortcut.CtrlA
        Me.miAdd.Text = "&OpenNewImage"
        '
        'miExit
        '
        Me.miExit.Index = 2
        Me.miExit.MergeOrder = 2
        Me.miExit.Shortcut = System.Windows.Forms.Shortcut.AltF4
        Me.miExit.Text = "E&xit"
        '
        'MdiClient1
        '
        Me.MdiClient1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.MdiClient1.Location = New System.Drawing.Point(0, 0)
        Me.MdiClient1.Name = "MdiClient1"
        Me.MdiClient1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(408, 309)
        Me.Controls.Add(Me.MdiClient1)
        Me.IsMdiContainer = True
        Me.Menu = Me.MainMenu1
        Me.Name = "Form1"
        Me.Text = "MDI多文档应用程序"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub AddChild(ByVal pic As Image, ByVal title As String)
        count = count + 1
        Dim ch As child = New child(title)
        ch.MdiParent = Me
        ch.Show()
        ch.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        ch.PictureBox1.Image = pic
    End Sub


    Private Sub miAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miAdd.Click
        Dim pic As Image
        Dim title As String
        Dim opendialog As New OpenFileDialog
        opendialog.Filter = "位图文件|*.bmp|图标文件|*.ico|JPG图片|*.jpg"
        If opendialog.ShowDialog = DialogResult.OK Then
            pic = Image.FromFile(opendialog.FileName)
            title = opendialog.FileName
            AddChild(pic, title)

        Else
            Exit Sub
        End If

    End Sub

    Private Sub miExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miExit.Click
        Me.Close()
    End Sub

    Private Sub miCas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub

    Private Sub miTH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub

    Private Sub miTV_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub

    Private Sub MDIChildActivated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Form0.MdiChildActivate
        Try
            Me.Text = "MdiApplication" + Me.ActiveMdiChild.Text
        Catch ex As Exception
            Me.Text = "MdiApplication"
        End Try
    End Sub



End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -