Results 1 to 13 of 13

Thread: scrolling a picture within a picture

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    37

    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

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: scrolling a picture within a picture

    can you upload a demo project so that we can reproduce the problem?

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    37

    Re: scrolling a picture within a picture

    Mouer,

    Do I upload just the vbp file?

    Kevin
    Dartcoach

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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.

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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:
    1. Private mX1     As Long, mY1 As Long
    2. Private MyPic   As Picture
    3.  
    4. Private Sub Form_Load()
    5.  
    6.     Set MyPic = LoadPicture("c:\world0.bmp")
    7.            
    8.     VScroll1.SmallChange = 10
    9.     VScroll1.LargeChange = 10
    10.     HScroll1.SmallChange = 10
    11.     HScroll1.LargeChange = 10
    12.    
    13.     VScroll1.Max = ScaleY(MyPic.Height, vbHimetric, vbPixels)
    14.     HScroll1.Max = ScaleX(MyPic.Width, vbHimetric, vbPixels)
    15.    
    16.     mX1 = 0
    17.     mY1 = 0
    18. End Sub
    19.  
    20. Private Sub HScroll1_Change()
    21.     Picture1.Cls
    22.     mX1 = -HScroll1.Value
    23.     Picture1.PaintPicture MyPic, mX1, mY1
    24. End Sub
    25.  
    26. Private Sub VScroll1_Change()
    27.     Picture1.Cls
    28.     mY1 = -VScroll1.Value
    29.     Picture1.PaintPicture MyPic, mX1, mY1
    30. 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.

  6. #6
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    37

    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

  8. #8
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: scrolling a picture within a picture

    how do I check if the user is trying to move up or down the vertical scroll bar.
    The scroll Event?
    I can scroll down, but I can't scroll back up.
    Why not? we still haven't seen what code you are using.

  9. #9
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    557

    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:
    1. if picture2.scaleheight>picture1.scaleheight then
    2.      vscroll1.visible=true
    3.      vscroll1.max= picture2.scaleheight-picture1.scaleheight
    4. else
    5.      vscroll1.visible=false
    6. 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.
    Last edited by Navion; Jan 12th, 2006 at 12:12 PM.

  10. #10

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    37

    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

  11. #11
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: scrolling a picture within a picture

    you have to link the picture2 top directly to the scroll value, something like this:
    VB Code:
    1. Picture2.top = VScroll.value

  12. #12

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    37

    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

  13. #13
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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:
    1. xTwips = ScaleX(Xpixels, vbPixels, vbTwips)
    2. yTwips = ScaleY(Ypixels, vbPixels, vbTwips)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width