Jan 25th, 2004, 11:52 PM
#1
Thread Starter
Fanatic Member
Pan and Zoom Image? Any code examples??[RESOLVED]
I am more interested in the "Pan" feature. I haven't seen much on this so far.
Thanks!
Last edited by birthjay; Jan 26th, 2004 at 11:07 AM .
Jan 26th, 2004, 09:32 AM
#2
Hope thisn attachment is enough to be useful.
Attached Files
This world is not my home. I'm just passing through.
Jan 26th, 2004, 09:59 AM
#3
Thread Starter
Fanatic Member
Thanks!
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!
Jan 26th, 2004, 10:42 AM
#4
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
This world is not my home. I'm just passing through.
Jan 26th, 2004, 11:07 AM
#5
Thread Starter
Fanatic Member
Thanks!
You are the man!
Thank you for your help!
May 27th, 2009, 02:25 PM
#6
Addicted Member
Re: Pan and Zoom Image? Any code examples??[RESOLVED]
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.
Last edited by JugglingReferee; May 27th, 2009 at 02:29 PM .
PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
Help Files: HelpMaker · Dr. Explain · Create Icons: IcoFX
"Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width