scrolling a picture within a picture
Hi All again.
We've tried just about everything to be able to create a form that has unlimited vertical scrolling.
Now I have a picturebox with a picture (.bmp) that's inside another picturebox. The .bmp's size is 44" x 22". Everything seems to load correctly, but I still can't scroll to the bottom of the .bmp.
Based on the numbers, it looks like I can scroll roughly 22", but no further.
I've set the Vscroll.max to 32767.
Any ideas?
Kevin
dartcoach
Re: scrolling a picture within a picture
can you upload a demo project so that we can reproduce the problem?
Re: scrolling a picture within a picture
Mouer,
Do I upload just the vbp file?
Kevin
Dartcoach
Re: scrolling a picture within a picture
Dartcoach, zip your Frm file also, if the project is not too big zip all files needed for this and upload, don't upload EXE files.
Re: scrolling a picture within a picture
Actually, i'm trying to do something very similar, but I'am using a Picturebox only, then I Load a picture and i'm trying to move that picture in the picturebox with 2 controls, HScroll and VScroll, seems to be working fine but i don't know if this is the best way to do it, scroll is a bit slow, If you read this Moeur, I know you know about this stuff ;), And this could be usefull for dartcoach's project too.
I know PaintPicture has many parameters, but maybe this could be done just using 2 of them? here is my code..
This code uses a picturebox a VScroll and a HScroll:
VB Code:
Private mX1 As Long, mY1 As Long
Private MyPic As Picture
Private Sub Form_Load()
Set MyPic = LoadPicture("c:\world0.bmp")
VScroll1.SmallChange = 10
VScroll1.LargeChange = 10
HScroll1.SmallChange = 10
HScroll1.LargeChange = 10
VScroll1.Max = ScaleY(MyPic.Height, vbHimetric, vbPixels)
HScroll1.Max = ScaleX(MyPic.Width, vbHimetric, vbPixels)
mX1 = 0
mY1 = 0
End Sub
Private Sub HScroll1_Change()
Picture1.Cls
mX1 = -HScroll1.Value
Picture1.PaintPicture MyPic, mX1, mY1
End Sub
Private Sub VScroll1_Change()
Picture1.Cls
mY1 = -VScroll1.Value
Picture1.PaintPicture MyPic, mX1, mY1
End Sub
SmallChange and LargeChange are = 10, but I think I should change this value depending on the picture size, just don't know how.
Re: scrolling a picture within a picture
yes,
it is much faster to do it with two pictureboxes.
There shouldn't be a problem scrolling as far as you want, but I want to see what is limiting the coach.
Re: scrolling a picture within a picture
Hi All,
Got it working to a point. I can now scroll through the whole picture regardless of how how many entries I put in.
Last problem, how do I check if the user is trying to move up or down the vertical scroll bar.
I can scroll down, but I can't scroll back up.
Thanks for all your help!
Kevin
Re: scrolling a picture within a picture
Quote:
how do I check if the user is trying to move up or down the vertical scroll bar.
The scroll Event?
Quote:
I can scroll down, but I can't scroll back up.
Why not? we still haven't seen what code you are using.
Re: scrolling a picture within a picture
Your picture has more twips than than Scroll max value would allow (32767)
Set both pictures in pixels...
picture1.scalemode = VbPixels
picture2.scalemode = VbPixels
then
VB Code:
if picture2.scaleheight>picture1.scaleheight then
vscroll1.visible=true
vscroll1.max= picture2.scaleheight-picture1.scaleheight
else
vscroll1.visible=false
end if
in your vscroll1_change event :
picture2.top=-vscroll1.value
and in your vscroll1_scroll event :
vscroll1_change
Same thing for an Hscroll bar (using scalewidth) if you want it.
Re: scrolling a picture within a picture
Mouer,
Sorry, here's the code on the VScroll_Change event:
Picture2.top = Picture2.top + -(VScroll.value)
The bar inside the scrollbar container moves up when I click the up arrow etc. but the picturebox stills moves down.
How do I determine if the user wants to go up or down based on where they click on the scrollbar?
Thanks again,
Kevin
Re: scrolling a picture within a picture
you have to link the picture2 top directly to the scroll value, something like this:
VB Code:
Picture2.top = VScroll.value
Re: scrolling a picture within a picture
Mouer,
Getting closer. Since I'm placing these combobox arrays on the form, based on twips, if I change the settings to pixels, what is the conversion so I can make sure all my comboboxes and lines are placed correctly?
Thanks again,
Kevin
Re: scrolling a picture within a picture
why do you need to convert to pixels?
Here is the conversion from pixels to twips
VB Code:
xTwips = ScaleX(Xpixels, vbPixels, vbTwips)
yTwips = ScaleY(Ypixels, vbPixels, vbTwips)