I am more interested in the "Pan" feature. I haven't seen much on this so far.
Thanks!
Printable View
I am more interested in the "Pan" feature. I haven't seen much on this so far.
Thanks!
Hope thisn attachment is enough to be useful.
Thank you, but I have acheived the same thing just using the "AutoScroll" setting in a "Panel". What I am really trying to do is....
I have the image loaded. The image is larger than the "Panel" therefore the scrollbars are activated. I can scroll up, down, left, and right.
What I want is to be able to hold down the left mouse button on the picture and drag (or Pan) the picture within the Panel. I am sure you have seen this in commericial apps.
Thanks!
Using the project I sent you before, delete the two command buttons and put this code into Form1.
You should be able to click and drag the picture.
VB Code:
Private blnMoving = False Private x As Long Private y As Long Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown PictureBox1.Cursor = Cursors.Hand blnMoving = True x = e.X y = e.Y End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If blnMoving Then With PictureBox1 If e.Button = MouseButtons.None Then .Cursor = Cursors.Arrow blnMoving = False End If .Left += e.X - x .Top += e.Y - y End With End If End Sub Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave PictureBox1.Cursor = Cursors.Arrow blnMoving = False End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp PictureBox1.Cursor = Cursors.Hand blnMoving = True End Sub
You are the man!
Thank you for your help!
This code worked for me.... in terms of panning with the mouse.
Does anyone have any ideas on how to prevent the picture from extending beyond the bounds of the PictureBox/Panel?
IOW: the picture should not pan such that there is whitespace at any border.