Results 1 to 9 of 9

Thread: Mouse Drop & Drop

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36

    Unhappy Mouse Drop & Drop

    I posted this message previously and I thought the suggestion I recieved solved my problem. Although after using the API function to drag a control with a handle, I realize now that this API function (Capture/Release) isn't suited to do what I want.

    I plan on creating up to 300 bitmap images on a form and will be attempting to provide drag & drop functionality for each bitmap image. Can the mouse detect it's on a bitmap image and drag it? Does it have to reside in a picture box because of its handle and its mouse-click detection. This which would not be practical in this case as I'm builting many bitmaps. Can I make it a clickable "bitmap" object, somehow. I appreciate the initial response, but I've discovered it wouldn't do the trick. Thanks in advance.

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    you are creating bitmaps on the fly???
    Why don't you use Image Control's array??? Actually I couldn't see any limitations that you can't use them......
    Use Image control and use its Drag and Drop feature...

  3. #3
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    The following code will drag a picturebox.
    VB Code:
    1. Dim OldX As Single
    2. Dim OldY As Single
    3.  
    4. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     If Button = 1 Then
    6.         OldX = X
    7.         OldY = Y
    8.     End If
    9. End Sub
    10.  
    11. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     If Button = vbLeftButton Then Picture1.MOVE Picture1.Left + (X - OldX), Picture1.Top + (Y - OldY)
    13. End Sub

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Why not use
    Picture1.Drag?????

  5. #5
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    You could, but there are 2 differences.

    1) It doesn't work in real-time
    2) You'd have to take into account the possibility that it could be dropped on another picturebox, thus write additional code.

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36

    Mouse Drag & Drop

    Does that mean I need to define a picture box per bitmap image? If so, wouldn't I be adding a lot of overhead to my program as I need to manipulate several bitmaps using picture box handles?

    Ideally, the picture box would a excellent method as I can utilize its properties.

    Thanks for your suggestions.

  7. #7
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Why not just use a control array?

  8. #8
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Here is a modified version of my example that will work for a control array.
    VB Code:
    1. Dim OldX As Single
    2. Dim OldY As Single
    3.  
    4. Private Sub Picture1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     If Button = 1 Then
    6.         OldX = X
    7.         OldY = Y
    8.     End If
    9. End Sub
    10.  
    11. Private Sub Picture1_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     If Button = vbLeftButton Then Picture1(index).Move Picture1(index).Left + (X - OldX), Picture1(index).Top + (Y - OldY)
    13. End Sub

  9. #9

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36

    Mouse Drag & Drop

    Ok, that should do the job. Thanks for all of your help.

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