|
-
Aug 5th, 2002, 01:33 PM
#1
Thread Starter
Member
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.
-
Aug 5th, 2002, 02:52 PM
#2
Frenzied Member
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...
-
Aug 5th, 2002, 03:04 PM
#3
Software Eng.
The following code will drag a picturebox.
VB Code:
Dim OldX As Single
Dim OldY As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
OldX = X
OldY = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then Picture1.MOVE Picture1.Left + (X - OldX), Picture1.Top + (Y - OldY)
End Sub
-
Aug 5th, 2002, 03:46 PM
#4
Frenzied Member
Why not use
Picture1.Drag?????
-
Aug 5th, 2002, 06:40 PM
#5
Software Eng.
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.
-
Aug 6th, 2002, 09:16 AM
#6
Thread Starter
Member
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.
-
Aug 6th, 2002, 10:42 AM
#7
Software Eng.
Why not just use a control array?
-
Aug 6th, 2002, 10:47 AM
#8
Software Eng.
Here is a modified version of my example that will work for a control array.
VB Code:
Dim OldX As Single
Dim OldY As Single
Private Sub Picture1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
OldX = X
OldY = Y
End If
End Sub
Private Sub Picture1_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then Picture1(index).Move Picture1(index).Left + (X - OldX), Picture1(index).Top + (Y - OldY)
End Sub
-
Aug 6th, 2002, 11:24 AM
#9
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|