Results 1 to 4 of 4

Thread: [RESOLVED] dragging Controls at runtime

  1. #1

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Resolved [RESOLVED] dragging Controls at runtime

    how do i drag a control, particularly, a picturebox at runtime??
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: dragging Controls at runtime

    Try this basic sample and let me know if works for you:
    Code:
    Option Explicit
    
    Dim intY As Integer
    Dim intX As Integer
    
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        intX = X
        intY = Y
        Picture1.Drag vbBeginDrag
    End Sub
    
    Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
        Source.Move X - intX, Y - intY
        Source.Drag vbEndDrag
    End Sub

  3. #3

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: dragging Controls at runtime

    Thanks Rhino, it sometimes work and sometimes not but anyway, i can modify it myself.

    Thanx for the Help
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] dragging Controls at runtime

    Oh, that's because you need to detect actual position of mouse pointer - if it is over picturebox's original position then using sample I posted dragdrop won't occur so you need a bit more coding (left that part for you ).

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