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

📄 5-4.frm

📁 vb6.0编程实例详解,很详细的介绍,对学习VB有帮助
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   ClientHeight    =   3855
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4875
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   3855
   ScaleWidth      =   4875
   Begin VB.HScrollBar HScroll1 
      Height          =   255
      Left            =   1560
      TabIndex        =   3
      Top             =   3120
      Width           =   1335
   End
   Begin VB.VScrollBar VScroll1 
      Height          =   2655
      Left            =   4440
      TabIndex        =   1
      Top             =   360
      Width           =   255
   End
   Begin VB.PictureBox Picture1 
      Height          =   2535
      Left            =   360
      ScaleHeight     =   2475
      ScaleWidth      =   2835
      TabIndex        =   0
      Top             =   120
      Width           =   2895
      Begin VB.PictureBox Picture2 
         AutoSize        =   -1  'True
         BorderStyle     =   0  'None
         Height          =   1335
         Left            =   240
         ScaleHeight     =   1335
         ScaleWidth      =   1695
         TabIndex        =   2
         Top             =   120
         Width           =   1695
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'该函数用于调整滚动条范围
Public Sub Init_Scroll()
    Dim i As Integer
    
    i = Picture2.Height - Picture1.Height
    '如果加入如下条件语句,则当图片高度小于窗体时,不能滚动
    '如果无此条件语句,则当图片高度小于窗体时,图片将反方向滚动
    'If i < 0 Then i = 0
    VScroll1.Max = i
    i = Picture2.Width - Picture1.Width
    'If i < 0 Then i = 0
    HScroll1.Max = i
End Sub

Private Sub Form_Load()
    '装载窗体时触发该事件
    Picture1.Top = 0
    Picture1.Left = 0
    Picture2.Top = 0
    Picture2.Left = 0
    VScroll1.Top = 0
    HScroll1.Left = 0
End Sub

Private Sub Form_Resize()
'改变窗体大小时触发该事件
    '为获得窗体Form1的大小,要使用ScaleWidth和ScaleHeight属性
    '不要使用其Width和Height属性。
    'ScaleWidth属性代表窗体Form1可用宽度,
    '而Width属性代表其外边界宽度,既在Screen对象中的宽度。
    If Me.ScaleWidth > VScroll1.Width Then
    'Picture1.Width属性不能小于0
        Picture1.Width = Me.ScaleWidth - VScroll1.Width
    End If
    If Me.ScaleHeight > HScroll1.Height Then
    'Picture1.Height属性不能小于0
        Picture1.Height = Me.ScaleHeight - HScroll1.Height
    End If
    
    '设置滚动条属性
    VScroll1.Left = Picture1.Width '垂直滚动条
    VScroll1.Height = Picture1.Height
    VScroll1.SmallChange = Picture1.Height / 10
    VScroll1.LargeChange = Picture1.Height
    HScroll1.Top = Picture1.Height '水平滚动条
    HScroll1.Width = Picture1.Width
    HScroll1.SmallChange = Picture1.Width / 10
    HScroll1.LargeChange = Picture1.Width
    Init_Scroll '设置滚动条范围
End Sub

Private Sub HScroll1_Change()
    Picture2.Left = -HScroll1.Value
End Sub

Private Sub HScroll1_Scroll()
    Picture2.Left = -HScroll1.Value
End Sub

Private Sub VScroll1_Change()
    Picture2.Top = -VScroll1.Value
End Sub

Private Sub VScroll1_Scroll()
    Picture2.Top = -VScroll1.Value
End Sub

⌨️ 快捷键说明

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