|
-
Jul 18th, 2002, 03:47 PM
#1
Thread Starter
Frenzied Member
pan option for my picture box
Hi,
I have added the ability to pan the image displayed in a picture box by clicking and dragging hte left mouse button on the picture box, similar to that of many graphics programs.
What I would really like to do is have a line drawn as the user clicks and drags, so they have a visual clue as to what they are doing.
So when the user clicks the mouse down, start the line, and then as the user moves around the form (while the mouse is down) the line moves according to the new position! I know how to draw the line as the mouse moves, but I can't get rid of the previous lines, so instead of just 1 line from start to finish, I get TONS of lines, which obviously isnt acceptable.
How would I get rid of the previously drawn line? Or am I going about this all wrong?
-
Jul 18th, 2002, 04:09 PM
#2
I'm using the form for this example but it would work just the same for a picture box.
VB Code:
Option Explicit
Dim oldX As Long
Dim oldY As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Me.Cls
oldX = X
oldY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Me.Cls
Me.Line (oldX, oldY)-(X, Y)
End If
End Sub
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
|