set a HscrollBar (named hbar) and a VscrollBar (named vbar)
a module with :
Private Sub ArrangeScrollbars()
Dim need_hgt As Single
Dim need_wid As Single
Dim got_hgt As Single
Dim got_wid As Single
Dim need_hbar As Boolean
Dim need_vbar As Boolean
' kijken welke scrollbar we nodig hebben
need_wid = Picture1.Width
need_hgt = Picture1.Height
got_wid = ScaleWidth - picScroller.Left
got_hgt = ScaleHeight - picScroller.Top
' hebben we de horizontale nodig
need_hbar = (got_wid < need_wid)
If need_hbar Then
got_hgt = got_hgt - hbar.Height
End If
' hebben we de verticale nodig
need_vbar = (got_hgt < need_hgt)
If need_vbar Then
got_wid = got_wid - vbar.Width
If Not need_hbar Then
need_hbar = (got_wid < need_wid)
If need_hbar Then
got_hgt = got_hgt - hbar.Height
End If
End If
End If
If got_hgt < 120 Then got_hgt = 120
If got_wid < 120 Then got_wid = 120
' toon de nodige scrollbar
If need_hbar Then
hbar.min = 0
hbar.max = got_wid - need_wid
hbar.SmallChange = got_wid / 3
hbar.LargeChange = _
(hbar.max - hbar.min) _
* need_wid / _
(got_wid - need_wid)
hbar.Visible = True
Else
hbar.Visible = False
End If
If need_vbar Then
vbar.min = 0
vbar.max = got_hgt - need_hgt
vbar.SmallChange = got_hgt / 3
vbar.LargeChange = _
(vbar.max - vbar.min) _
* need_hgt / _
(got_hgt - need_hgt)
vbar.Visible = True
Else
vbar.Visible = False
End If
End Sub
a pictureBox and a commondialog
Private Sub LoadFromFile_Click()
On Error Resume Next
With CommonDialog1
.CancelError = True
.Filter = "Pictures(*.bmp;*.ico;*.gif;*.jpg;*.wmf)|*.bmp;*.ico;*.gif;*.jpg;*.wmf|"
.Flags = cdlOFNHideReadOnly
.ShowOpen
If Err.Number = cdlCancel Then
Err.Clear
Exit Sub
End If
CurFoto = .FilterIndex - 1
FileName = .FileName
FileName.Visible = True
End With
ArrangeScrollbars
End Sub
Eric De Decker
vbg.be@vbgroup.nl
License And Copy Protection AxtiveX.
Download Demo version on my Site: