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

📄 picturebrowser.frm

📁 个人VB学习源码精选,自己学习时的一些编程小程序,希望对大家有帮助
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6855
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5265
   LinkTopic       =   "Form1"
   ScaleHeight     =   6855
   ScaleWidth      =   5265
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   60
      Top             =   6180
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   315
      Left            =   4080
      TabIndex        =   4
      Top             =   6360
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打开图片"
      Height          =   315
      Left            =   2820
      TabIndex        =   3
      Top             =   6360
      Width           =   975
   End
   Begin VB.HScrollBar HScroll1 
      Height          =   255
      Left            =   0
      TabIndex        =   2
      Top             =   5835
      Width           =   5055
   End
   Begin VB.VScrollBar VScroll1 
      Height          =   5835
      Left            =   4995
      TabIndex        =   1
      Top             =   0
      Width           =   255
   End
   Begin VB.PictureBox Picture1 
      Height          =   5835
      Left            =   0
      ScaleHeight     =   5775
      ScaleWidth      =   4935
      TabIndex        =   0
      Top             =   0
      Width           =   4995
      Begin VB.PictureBox Picture2 
         AutoSize        =   -1  'True
         BorderStyle     =   0  'None
         Height          =   4515
         Left            =   1140
         ScaleHeight     =   4515
         ScaleWidth      =   2715
         TabIndex        =   5
         Top             =   660
         Width           =   2715
      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
Private Sub Command1_Click()
    On Error GoTo error
    
    CommonDialog1.Filter = "(*.jpg)|*.jpg|(*.bmp)|*.bmp"
    CommonDialog1.ShowOpen
    If CommonDialog1.FileName <> "" Then
        Picture2.Picture = LoadPicture(CommonDialog1.FileName)
        VScroll1.Value = 0
        HScroll1.Value = 0
        CheckSize
    End If
error:
End Sub

Private Sub Command2_Click()
    End
End Sub

Private Sub Form_Resize()
    Picture1.Width = Form1.Width - 390
    Picture1.Top = 0
    Picture1.Height = Abs(Form1.Height - 1425)
    Command1.Left = Form1.Width - 2565
    Command1.Top = Form1.Height - 900
    Command2.Left = Form1.Width - 1305
    Command2.Top = Form1.Height - 900
    HScroll1.Top = Picture1.Height
    HScroll1.Width = Picture1.Width
    VScroll1.Height = Picture1.Height
    VScroll1.Left = Picture1.Width
    CheckSize
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
Private Sub CheckSize()
    If Picture2.Picture <> 0 Then
        Picture2.BorderStyle = 1
    End If
    If Picture2.Height <= Picture1.Height Then
        VScroll1.Enabled = False
        Picture2.Top = (Picture1.Height - Picture2.Height) / 2
    Else
        Picture2.Top = 0
        VScroll1.Enabled = True
        VScroll1.Max = (Picture2.Height - Picture1.Height)
        VScroll1.LargeChange = (Picture2.Height - Picture1.Height)
        VScroll1.SmallChange = (Picture2.Height - Picture1.Height) / 4
    End If
    If Picture2.Width <= Picture1.Width Then
        HScroll1.Enabled = False
        Picture2.Left = (Picture1.Width - Picture2.Width) / 2
    Else
        Picture2.Left = 0
        HScroll1.Enabled = True
        HScroll1.Max = Picture2.Width - Picture1.Width
        Debug.Print Picture2.Width
        Debug.Print Picture1.Width
        HScroll1.LargeChange = (Picture2.Width - Picture1.Width)
        HScroll1.SmallChange = (Picture2.Width - Picture1.Width) / 4
    End If
End Sub

⌨️ 快捷键说明

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