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

📄 12.8.frm

📁 vb编程+从基础到实践光盘代码
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1 
   Caption         =   "图片浏览与缩放"
   ClientHeight    =   4785
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   9645
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   319
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   643
   StartUpPosition =   3  'Windows Default
   Begin MSComctlLib.Slider Slider1 
      Height          =   375
      Left            =   6600
      TabIndex        =   7
      Top             =   3120
      Width           =   2895
      _ExtentX        =   5106
      _ExtentY        =   661
      _Version        =   393216
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   8760
      Top             =   4080
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.HScrollBar HScroll1 
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   3840
      Width           =   5655
   End
   Begin VB.VScrollBar VScroll1 
      Height          =   3735
      Left            =   5880
      TabIndex        =   5
      Top             =   0
      Width           =   255
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退   出"
      Height          =   375
      Left            =   5400
      TabIndex        =   3
      Top             =   4320
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "清   除"
      Height          =   375
      Left            =   3240
      TabIndex        =   2
      Top             =   4320
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打   开"
      Height          =   375
      Left            =   1200
      TabIndex        =   1
      Top             =   4320
      Width           =   1215
   End
   Begin VB.PictureBox Picture1 
      Height          =   3735
      Left            =   120
      ScaleHeight     =   245
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   373
      TabIndex        =   0
      Top             =   0
      Width           =   5655
      Begin VB.Image Image2 
         Appearance      =   0  'Flat
         Height          =   1815
         Left            =   0
         Stretch         =   -1  'True
         Top             =   0
         Width           =   2415
      End
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H80000001&
      Height          =   855
      Left            =   6720
      Top             =   0
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "滑动滑块缩放图片"
      Height          =   255
      Left            =   7080
      TabIndex        =   4
      Top             =   2640
      Width           =   1575
   End
   Begin VB.Image Image1 
      BorderStyle     =   1  'Fixed Single
      Height          =   2175
      Left            =   6720
      Stretch         =   -1  'True
      Top             =   0
      Width           =   2415
   End
   Begin VB.Menu file 
      Caption         =   "文件(&F)"
      Index           =   1
      Begin VB.Menu open 
         Caption         =   "打开(&O)"
         Index           =   1
      End
      Begin VB.Menu clear 
         Caption         =   "清除(&C)"
         Index           =   2
      End
      Begin VB.Menu exit 
         Caption         =   "退出(&E)"
         Index           =   3
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Private Sub clear_Click(Index As Integer)
    Image1.Picture = LoadPicture()
    Image2.Picture = LoadPicture()
End Sub
Private Sub Command1_Click()                       '打开文件
    CommonDialog1.FileName = ""
    CommonDialog1.Filter = "Picture File(*.BMP;*.GIF;*.JPG)|*.BMP;*.GIF;*.JPG"
    CommonDialog1.ShowOpen
    If CommonDialog1.FileName <> "" Then
        Image1.Picture = LoadPicture(CommonDialog1.FileName)
        Image2.Picture = LoadPicture(CommonDialog1.FileName)
    End If
    Slider1.Value = CInt(Shape1.Width / Image1.Width * 100)
    i = Slider1.Value
End Sub
Private Sub Command2_Click()
    Image1.Picture = LoadPicture()
    Image2.Picture = LoadPicture()
End Sub
Private Sub Command3_Click()                             '退出
    End
End Sub
Private Sub exit_Click(Index As Integer)
    End
End Sub
Private Sub Form_Load()
    Picture1.AutoSize = False
    Image1.Stretch = True
    Image2.Top = 0: Image2.Left = 0
    Image2.Width = 800: Image2.Height = 600
    Shape1.Width = Image1.Width * Picture1.Width / Image2.Width + 15
    Shape1.Height = Image1.Height * Picture1.Height / Image2.Height
    zShapeWidth = Shape1.Width: zShapeHeight = Shape1.Height
    HScroll1.Visible = (Picture1.Width < Image2.Width)
    HScroll1.Max = (Image2.Width - Picture1.Width)
    VScroll1.Visible = (Picture1.Height < Image2.Height)
    VScroll1.Max = (Image2.Height - Picture1.Height)
End Sub
Private Sub open_Click(Index As Integer)
    CommonDialog1.FileName = ""
    CommonDialog1.Filter = "Picture File(*.BMP;*.GIF;*.JPG)|*.BMP;*.GIF;*.JPG"
    CommonDialog1.ShowOpen
    If CommonDialog1.FileName <> "" Then
        Image1.Picture = LoadPicture(CommonDialog1.FileName)
        Image2.Picture = LoadPicture(CommonDialog1.FileName)
    End If
    Slider1.Value = CInt(Shape1.Width / Image1.Width * 100)
    i = Slider1.Value
End Sub

Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    Image2.Width = 800 * Slider1.Value / i                            '放大与缩小图片
    Image2.Height = 600 * Slider1.Value / i
    Shape1.Width = Picture1.Width * Image1.Width / Image2.Width + 15
    Shape1.Height = Picture1.Height * Image1.Height / Image2.Height
    HScroll1.Visible = (Picture1.Width < Image2.Width)
    HScroll1.Max = (Image2.Width - Picture1.Width)
    VScroll1.Visible = (Picture1.Height < Image2.Height)
    VScroll1.Max = (Image2.Height - Picture1.Height)
End Sub
Private Sub HScroll1_Change()                                     '根据滚动条的值,滚动图片
    Image2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
    Image2.Top = -VScroll1.Value
End Sub
Private Sub HScroll1_Scroll()                                     '滚动时触发Change事件
    HScroll1_Change
End Sub
Private Sub VScroll1_Scroll()
    VScroll1_Change
End Sub

⌨️ 快捷键说明

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