Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static n As Integer
If n = 10 Then End
n = n + 1
End Sub
Private Sub Form_Load()Combo1.ListIndex = 0
Option1.Value = True
End Sub
Private Sub Option1_Click()
Select Case Combo1.ListIndex
Case 0
Picture1.Picture = LoadPicture("e:\tmp\cd1.gif")
Case 1
Picture1.Picture = LoadPicture("e:\tmp\cd2.gif")
Case 2
Picture1.Picture = LoadPicture("e:\tmp\cd3.gif")
End Select
End Sub
Private Sub Option2_Click()
Select Case Combo1.ListIndex
Case 0
Picture1.Picture = LoadPicture("e:\tmp\cd4.gif")
Case 1
Picture1.Picture = LoadPicture("e:\tmp\cd5.gif")
Case 2
Picture1.Picture = LoadPicture("e:\tmp\cd6.gif")
End Select
End Sub
Private Sub Combo1_Click()
If Option1.Value Then
Option1_Click
Else
Option2_Click
End If
End Sub
经测试代码无问题
最简单的应该是用Picture当作容器,里面放置一个Image来显示图像,以下代码需要在窗口中放置标签、 文本框、按钮、标准对话框控件、Picuture各一个(其中Picutre控件中需要放置一个Image和一个垂直滚动条,如下图),然后使用下列代码即可:
Private Sub Command1_Click()
Dim oPic As StdPicture
With CommonDialog1
.Filter = "所有图片文件(*.jpg*.gif*.bmp*.emf)|*.jpg*.gif*.bmp*.emf"
.ShowOpen
If .FileName <> "" Then
Text1 = .FileName
Set oPic = LoadPicture(.FileName)
If Not oPic Is Nothing Then
Image1.Picture = oPic
Image1.Left = 0
Image1.Top = 0
If Image1.Height > Picture1.ScaleHeight Then
VScroll1.Max = (Image1.Height - Picture1.ScaleHeight) / 10
VScroll1.Value = 1
VScroll1.Value = 0
VScroll1.Visible = True
VScroll1.Refresh
Else
VScroll1.Visible = False
End If
End If
End If
End With
End Sub
Private Sub Form_Load()
Text1.Locked = True
Picture1.ScaleMode = vbPixels
Image1.Left = 0
Image1.Top = 0
With VScroll1
.Left = Picture1.ScaleWidth - .Width
.Top = 0
.Height = Picture1.ScaleHeight
End With
End Sub
Private Sub VScroll1_Change()
If Image1.Picture <> 0 Then
Image1.Top = -VScroll1.Value * 10
VScroll1.LargeChange = 20
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)