Results 1 to 6 of 6

Thread: Pan an Image

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    19

    Pan an Image

    Hiya,

    I'm struggling with a function to pan/scroll an image, in this case, a map. I put the picturebox into a panel and want to pan with the help of the panel.autoscroll function but it doesen't work and I don't have a clue why.

    VB Code:
    1. Private clickPosn As Point
    2. Private scrollPosn As Point
    3.  
    4. Public Sub picBoxMap_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picBoxMap.MouseDown
    5.         clickPosn.X = e.X
    6.         clickPosn.Y = e.Y
    7. End Sub 'picBoxMap_MouseDown
    8.  
    9. Public Sub picBoxMap_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picBoxMap.MouseMove
    10. If e.Button = Windows.Forms.MouseButtons.Left Then
    11.             scrollPosn.X = clickPosn.X - e.X
    12.             scrollPosn.Y = clickPosn.X - e.Y
    13.             'übergabe der veränderten pos. an Scrollbar
    14.             'dadurch veränderung des bildausschnitts
    15.             pnlBoxMap.AutoScrollPosition = scrollPosn
    16.  
    17.         End If
    18. End Sub 'picBoxMap_MouseMove

    Does anyone here know what I'm doing wrong? I use visual studio 2005 and cf2.0

    Cheers
    Conny

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Pan an Image

    Hi,
    take a look here - there is code to pan and zoom

    Pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    19

    Re: Pan an Image

    Thank you very much for your reply.

    Unfortunately even with your code my picturebox is still resisting and doesn't want to scroll.

    Somehow it seems as the scrollbars don't know where they belong to. Or none of the controls now which size the map actually has. I put the scrollbars on top of the picturebox. But even if I scroll directly nothing happens.

    Is there any way to tell the scrollbars directly where they belong? Which sizemode should the pictureBox have? Are there any other property settings I should be aware of?

    Cheers
    Conny

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Pan an Image

    did you
    Put a large picture box and a horizontal and vertical scroll bar on your form
    If so the code should work. What device is this running on - is it qvga (320*240) of vga (640*480)

    Pete

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    19

    Re: Pan an Image

    It's a qvga device.

    Well, I can't make the picturebox, and the container panel respectively, to big, because I have to put some other controls under it. It's going to be a navigation application, so you have the map in the upper part and some labels like Speed in the lower part.

    I've got one form and put a panel on this form which fills the whole screen. In this panel I out a second panel which is maybe two third of the screen and is the container for the map.

  6. #6
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Pan an Image

    Hi,
    shouldn't be a problem - just put the scroll bars on the 'picture panel'

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