Results 1 to 3 of 3

Thread: I need a workaround!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    I'm having a problem with the following code and I need a tip or workaround:

    Dim OldX As Single
    Dim OldY As Single
    Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    Source.Left = X - OldX
    Source.Top = Y - OldY
    End Sub

    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
    OldX = X
    OldY = Y
    Picture1.Drag
    End If

    The problem is the x,y of the form is not realized unless the cursor leaves the original plane of the picturebox. In other words if you put the cursor in the middle of a picbox that is 1000 whatevers wide by 1000 whatevers high you can't move the picture box 499 or less whatevers. Any help?

    Thanks,
    Joey O

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Try:
    Code:
    Dim OldX As Single
    Dim OldY As Single
    
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            OldX = X
            OldY = Y
        End If
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then Picture1.Move Picture1.Left + (X - OldX), Picture1.Top + (Y - OldY)
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Aeron

    Aaron,
    As always, you amaze me. Thanks again.
    JoeyO


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