Results 1 to 3 of 3

Thread: Drag and drop

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    42

    Drag and drop

    Hi i want to learn about doing drag and drop of objects.
    Basicly what i wanna do is: having 3 buttons (A,B,C)on a form......i wanna drag and drop button C on top of button A and display something. If i drag and drop it on the C buton i want another message. I really have no idea how to go about it. Any suggestions or tutorials would be appreciated

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Create a form.
    Add 3 buttons. Call then btnA, btnB and btnC.

    On btnA, modify the DragMode to 1 (Automatic).
    Then add the following code:
    VB Code:
    1. Private Sub btnB_DragDrop(Source As Control, X As Single, Y As Single)
    2.     MsgBox "Dropped on B at " & X & " : " & Y
    3. End Sub
    4.  
    5. Private Sub btnC_DragDrop(Source As Control, X As Single, Y As Single)
    6.     MsgBox "Dropped on C at " & X & " : " & Y
    7. End Sub
    Run the program, and drag button A to B or C.

    Then extend the program a bit by:
    Add two image controls. Add different Pictures to them (from the \Graphics\Icons\DragDrop folder). Add this code:
    VB Code:
    1. Private Sub btnB_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    2.     btnA.DragIcon = Image1.Picture
    3. End Sub
    4.  
    5. Private Sub btnC_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    6.     btnA.DragIcon = Image1.Picture
    7. End Sub
    8.  
    9. Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    10.     btnA.DragIcon = Image2.Picture
    11. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    42

    Wink

    thanx for replying ... i will try this

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