📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
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
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents picOuter As System.Windows.Forms.PictureBox
Friend WithEvents picInner As System.Windows.Forms.PictureBox
Friend WithEvents hsbPic As System.Windows.Forms.HScrollBar
Friend WithEvents vsbPic As System.Windows.Forms.VScrollBar
Friend WithEvents btnOpenImage As System.Windows.Forms.Button
Friend WithEvents dlgOpenFile As System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.picOuter = New System.Windows.Forms.PictureBox()
Me.picInner = New System.Windows.Forms.PictureBox()
Me.hsbPic = New System.Windows.Forms.HScrollBar()
Me.vsbPic = New System.Windows.Forms.VScrollBar()
Me.btnOpenImage = New System.Windows.Forms.Button()
Me.dlgOpenFile = New System.Windows.Forms.OpenFileDialog()
Me.SuspendLayout()
'
'picOuter
'
Me.picOuter.Location = New System.Drawing.Point(8, 8)
Me.picOuter.Name = "picOuter"
Me.picOuter.Size = New System.Drawing.Size(512, 312)
Me.picOuter.TabIndex = 0
Me.picOuter.TabStop = False
'
'picInner
'
Me.picInner.Image = CType(resources.GetObject("picInner.Image"), System.Drawing.Bitmap)
Me.picInner.Location = New System.Drawing.Point(144, 64)
Me.picInner.Name = "picInner"
Me.picInner.Size = New System.Drawing.Size(176, 120)
Me.picInner.TabIndex = 1
Me.picInner.TabStop = False
'
'hsbPic
'
Me.hsbPic.Location = New System.Drawing.Point(0, 320)
Me.hsbPic.Name = "hsbPic"
Me.hsbPic.Size = New System.Drawing.Size(520, 17)
Me.hsbPic.TabIndex = 2
'
'vsbPic
'
Me.vsbPic.Location = New System.Drawing.Point(520, 0)
Me.vsbPic.Name = "vsbPic"
Me.vsbPic.Size = New System.Drawing.Size(17, 320)
Me.vsbPic.TabIndex = 3
'
'btnOpenImage
'
Me.btnOpenImage.Location = New System.Drawing.Point(16, 344)
Me.btnOpenImage.Name = "btnOpenImage"
Me.btnOpenImage.TabIndex = 4
Me.btnOpenImage.Text = "打开图片"
'
'dlgOpenFile
'
Me.dlgOpenFile.Filter = "位图文件(*.bmp)|*.bmp|GIF文件(*.gif)|*.gif|JPEG文件(*.jpg, *.jpeg)|*.jpg;*.jpeg"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(552, 374)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnOpenImage, Me.vsbPic, Me.hsbPic, Me.picInner, Me.picOuter})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub vsbPic_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles vsbPic.Scroll
picInner.Top = -(vsbPic.Value)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
picOuter.Controls.Add(picInner)
picInner.Left = 0
picInner.Top = 0
picInner.SizeMode = PictureBoxSizeMode.AutoSize
vsbPic.Maximum = picInner.Height - picOuter.Height
hsbPic.Maximum = picInner.Width - picOuter.Width
End Sub
Private Sub hsbPic_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles hsbPic.Scroll
picInner.Left = -(hsbPic.Value)
End Sub
Private Sub btnOpenImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenImage.Click
dlgOpenFile.InitialDirectory = "c:\windows"
If dlgOpenFile.ShowDialog() = DialogResult.OK Then
picInner.Image = Image.FromFile(dlgOpenFile.FileName)
picInner.SizeMode = PictureBoxSizeMode.AutoSize
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -