Results 1 to 2 of 2

Thread: pan option for my picture box

  1. #1

    Thread Starter
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545

    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?

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    I'm using the form for this example but it would work just the same for a picture box.
    VB Code:
    1. Option Explicit
    2.  
    3. Dim oldX As Long
    4. Dim oldY As Long
    5.  
    6. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    7.     If Button = vbLeftButton Then
    8.         Me.Cls
    9.         oldX = X
    10.         oldY = Y
    11.     End If
    12. End Sub
    13.  
    14. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    15.     If Button = vbLeftButton Then
    16.         Me.Cls
    17.         Me.Line (oldX, oldY)-(X, Y)
    18.     End If
    19. 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
  •  



Click Here to Expand Forum to Full Width