May 31st, 2006, 09:44 PM
#1
Thread Starter
Member
Alternative to scrolling in a picturebox...
I came up with this to examine "up close" HiRes images from my Maps database. You can move the image around to see every part of it without going "out of bounds"
Attached Files
Last edited by Promocom; Jun 1st, 2006 at 07:21 PM .
Reason: Better title description
May 31st, 2006, 10:19 PM
#2
Re: Large images in small picturebox...
you might want consider placing the second picture box within the first & then doing something like:
VB Code:
Private sX As Single, sY As Single
Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
sX = X
sY = Y
Screen.MousePointer = vbSizePointer
End If
End Sub
Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lLeft As Long, lTop As Long
If Button = vbLeftButton Then
' Restrict Left
lLeft = Picture2.Left + (X - sX)
If lLeft > 0 Then lLeft = 0
If lLeft < Picture1.ScaleWidth - Picture2.Width Then lLeft = Picture1.ScaleWidth - Picture2.Width
Picture2.Left = lLeft
' Restrict Top
lTop = Picture2.Top + (Y - sY)
If lTop > 0 Then lTop = 0
If lTop < Picture1.ScaleHeight - Picture2.Height Then lTop = Picture1.ScaleHeight - Picture2.Height
Picture2.Top = lTop
End If
End Sub
Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Screen.MousePointer = vbNormal
End Sub
Private Sub Form_Load()
With Picture2
.Appearance = 0
.BorderStyle = 0
.AutoRedraw = True
.AutoSize = True
.Picture = LoadPicture(App.Path & "\map.jpg")
.Move (Picture1.ScaleWidth - .Width) \ 2, (Picture1.ScaleHeight - .Height) \ 2
End With
End Sub
It avoids the need for constant PaintPicturing.
You'll probably want to get a mod to move this to the CodeBank.
May 31st, 2006, 11:22 PM
#3
Thread Starter
Member
Re: Large images in small picturebox...
I tried your code bushmobile and I'm getting some weird "multiple image" effects while moving the image. Are there any property changes I should make to the controls?
Jun 1st, 2006, 12:57 AM
#4
Re: Large images in small picturebox...
I made a PictureView control two years ago. I got bored of people asking for picture scrolling so I made this control
Jun 1st, 2006, 06:37 AM
#5
Re: Large images in small picturebox...
I've attached an example.
(i didn't bother including the picture in the attachment)
Attached Files
Jun 1st, 2006, 06:53 AM
#6
Jun 1st, 2006, 07:23 PM
#7
Thread Starter
Member
Re: Alternative to scrolling in a picturebox...
Yes it works quite nicely bushmobile...
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width