Results 1 to 3 of 3

Thread: Dragging Help

  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
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Check out the help file
    lotsa info and sample code

    DocZaf
    {;->

  3. #3

    Talking here try this

    [CODE]
    Option Explicit

    Dim MouseX As Single
    Dim MouseY As Single


    Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    Source.Left = X - MouseX
    Source.Top = Y - MouseY
    End Sub

    Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
    Source.Left = Picture1.Left + X - MouseX
    Source.Top = Picture1.Top + Y - MouseY
    End Sub

    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseX = X
    MouseY = Y
    Picture1.Drag
    End Sub
    [CODE]
    it seems to work fine for me every time

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