Results 1 to 2 of 2

Thread: dragging

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2007
    Posts
    259

    dragging

    ok, I know what picture.drag 1 and picture.drag 2 is, but how do I conbine them to make a drag and drop thing? all I want to be able to do is drag a picturebox around the place, but how?

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: dragging

    The following should work fine

    Code:
    Option Explicit
    
    Public bPressed As Boolean
    Public iX As Long
    Public iY As Long
    
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            bPressed = True
            iX = X
            iY = Y
        End If
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If bPressed = True Then
            Picture1.Left = Picture1.Left + X - iX
            Picture1.Top = Picture1.Top + Y - iY
        End If
    End Sub
    
    Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        bPressed = False
    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