PDA

Click to See Complete Forum and Search --> : Pan an Image


Conny3
Dec 19th, 2006, 09:06 AM
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.


Private clickPosn As Point
Private scrollPosn As Point

Public Sub picBoxMap_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picBoxMap.MouseDown
clickPosn.X = e.X
clickPosn.Y = e.Y
End Sub 'picBoxMap_MouseDown

Public Sub picBoxMap_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picBoxMap.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
scrollPosn.X = clickPosn.X - e.X
scrollPosn.Y = clickPosn.X - e.Y
'übergabe der veränderten pos. an Scrollbar
'dadurch veränderung des bildausschnitts
pnlBoxMap.AutoScrollPosition = scrollPosn

End If
End Sub 'picBoxMap_MouseMove

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

Cheers
Conny

petevick
Dec 20th, 2006, 01:14 AM
Hi,
take a look here (http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=3372&SearchTerms=scroll) - there is code to pan and zoom

Pete

Conny3
Dec 20th, 2006, 08:13 AM
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

petevick
Dec 21st, 2006, 02:18 AM
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

Conny3
Dec 21st, 2006, 03:31 AM
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.

petevick
Dec 21st, 2006, 03:43 PM
Hi,
shouldn't be a problem - just put the scroll bars on the 'picture panel'