发表评论(0)作者:Sam Huggill, 平台:VB6.0+Win98, 阅读:7822, 日期:2001-05-09
Create a scrollable viewpoint
Tip by Sam Huggill
Tip description
Use scrollbars and picture boxes to create a scollable picture viewer.
Tip Code
Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
Private Sub Form_Resize()
With Picture1
.Height = Form1.Height
.Width = Form1.Width
End With
Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
ScaleHeight - HScroll1.Height
Picture2.Move 0, 0
With HScroll1
.Top = Picture1.Height
.Left = 0
.Width = Picture1.Width
.Max = Picture2.Width - Picture1.Width
End With
With VScroll1
.Top = 0
.Left = Picture1.Width
.Height = Picture1.Height
.Max = Picture2.Height - Picture1.Height
End With
VScroll1.Visible = (Picture1.Height < Picture2.Height)
HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub
Private Sub Form_Load()
Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
ScaleHeight - HScroll1.Height
With Picture2
.AutoSize = True
.Picture = LoadPicture("d:\vbcode\examples\demos\banner.jpg")
.Move 0, 0
End With
With HScroll1
.Top = Picture1.Height
.Left = 0
.Width = Picture1.Width
End With
With VScroll1
.Top = 0
.Left = Picture1.Width
.Height = Picture1.Height
End With
HScroll1.Max = Picture2.Width - Picture1.Width
VScroll1.Max = Picture2.Height - Picture1.Height
注释: HScroll1.LargeChange = HScroll1.Max / 10
注释: VScroll1.LargeChange = VScroll1.Max / 10
VScroll1.Visible = (Picture1.Height < Picture2.Height)
HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub
Tip by Sam Huggill
Tip description
Use scrollbars and picture boxes to create a scollable picture viewer.
Tip Code
Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
Private Sub Form_Resize()
With Picture1
.Height = Form1.Height
.Width = Form1.Width
End With
Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
ScaleHeight - HScroll1.Height
Picture2.Move 0, 0
With HScroll1
.Top = Picture1.Height
.Left = 0
.Width = Picture1.Width
.Max = Picture2.Width - Picture1.Width
End With
With VScroll1
.Top = 0
.Left = Picture1.Width
.Height = Picture1.Height
.Max = Picture2.Height - Picture1.Height
End With
VScroll1.Visible = (Picture1.Height < Picture2.Height)
HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub
Private Sub Form_Load()
Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
ScaleHeight - HScroll1.Height
With Picture2
.AutoSize = True
.Picture = LoadPicture("d:\vbcode\examples\demos\banner.jpg")
.Move 0, 0
End With
With HScroll1
.Top = Picture1.Height
.Left = 0
.Width = Picture1.Width
End With
With VScroll1
.Top = 0
.Left = Picture1.Width
.Height = Picture1.Height
End With
HScroll1.Max = Picture2.Width - Picture1.Width
VScroll1.Max = Picture2.Height - Picture1.Height
注释: HScroll1.LargeChange = HScroll1.Max / 10
注释: VScroll1.LargeChange = VScroll1.Max / 10
VScroll1.Visible = (Picture1.Height < Picture2.Height)
HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub