Results 1 to 2 of 2

Thread: Moving Images With The Mouse

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999


    To move a picture with the mouse I used the Code: Image1.Left = X But while going right it is really choppy, but going left it is fine. What's wrong, should I use a different method?


  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Red Wing, MN, USA


    Use a Picturebox it'll yield better results, eg.
    Private oX As Integer
    Private oY As Integer
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            oX = ScaleX(X, ScaleMode, vbPixels)
            oY = ScaleY(Y, ScaleMode, vbPixels)
        End If
    End Sub
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Static lX As Single
        Static lY As Single
        If lX = X And lY = Y Then Exit Sub
        lX = X
        lY = Y
        If Button = vbLeftButton Then
            X = X - ScaleX(oX, vbPixels, ScaleMode)
            Y = Y - ScaleY(oY, vbPixels, ScaleMode)
            Picture1.Move X + Picture1.Left, Y + Picture1.Top
        End If
    End Sub
    Just Click on the Picture and Drag...

    Aaron Young
    Analyst Programmer

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