Results 1 to 2 of 2

Thread: Drag & Drop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Le Havre
    Posts
    66

    Drag & Drop

    How can i make a Drag & Drop in VB
    Vix
    VB6 SP4
    NT4 SP6 & W2K Server SP1
    SQL Server 7 & 2000
    )--( )--( )--(

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    That all depends on what you want to drag and drop in VB. If you want to drag a picture box, you can use this:

    VB Code:
    1. 'This goes in a module
    2. Private Declare Function SendMessage Lib "User32" _
    3. Alias "SendMessageA" (ByVal hWnd As Long, _
    4. ByVal wMsg As Long, _
    5. ByVal wParam As Long, _
    6. lParam As Any) As Long
    7. Private Declare Sub ReleaseCapture Lib "User32" ()
    8. Const WM_NCLBUTTONDOWN = &HA1
    9. Const HTCAPTION = 2
    10. Add this code To the form's MouseMove procedure:
    11. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12. Dim lngReturnValue As Long
    13. If Button = 1 Then
    14. Call ReleaseCapture
    15. lngReturnValue = SendMessage(Form1.hWnd, WM_NCLBUTTONDOWN, _
    16. HTCAPTION, 0&)
    17. End If
    18. End Sub
    19. Private Declare Function SendMessage Lib "User32" _
    20. Alias "SendMessageA" (ByVal hWnd As Long, _
    21. ByVal wMsg As Long, _
    22. ByVal wParam As Long, _
    23. lParam As Any) As Long
    24. Private Declare Sub ReleaseCapture Lib "User32" ()
    25. Const WM_NCLBUTTONDOWN = &HA1
    26. Const HTCAPTION = 2
    27.  
    28. 'Add this code To the form's MouseMove procedure:
    29.  
    30. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    31. Dim lngReturnValue As Long
    32. If Button = 1 Then
    33. Call ReleaseCapture
    34. lngReturnValue = SendMessage(Picture.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    35. End If
    36. End Sub

    Or you can set an object's dragmode to Automatic and in the form's dragdrop event, use source.left = x and source.top = y.
    <removed by admin>

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