[RESOLVED] Selecting and drag/drop multiple images and labels.
How would you go about selecting multiple images and labels for dragging and dropping?
I know how to drag and drop a single object, but I’m not shore how you would go about dragging and dropping multiple images and labels as you would with icons on your desktop with the selection box and highlighting.
Also, is there more than one way of doing this and which way is the best?
Re: Selecting and drag/drop multiple images and labels.
Any one have any input? Are there any APIs that I could use?
Re: Selecting and drag/drop multiple images and labels.
Perhaps by putting those object in a control array and working with the Index parameter?
1 Attachment(s)
Re: Selecting and drag/drop multiple images and labels.
Depending on how you have your controls etc, this might work.
Note: to select a control, you need to right click it. Selected controls have a "-1" in their caption.
Re: Selecting and drag/drop multiple images and labels.
Thank you, that jogged my mind and I was almost able to come up with what I needed.
I say almost because I have a major bug with my moving code (the formula to determine the controls new position) and I can't quite seem to figure out how to fix it/code it right.
Dose anyone have an idea how to fix it???
buggy movement code:
VB Code:
Private Sub Form_MouseMove(button As Integer, shift As Integer, x As Single, y As Single)
Static mousex As Single, mousey As Single
Select Case button
Case 1
For i = LBound(Selection()) To UBound(Selection())
If Selection(i).SelectingState Then
Selection(i).con.Left = Selection(i).con.Left + (x - mousex)
Selection(i).con.Top = Selection(i).con.Top + (y - mousey)
End If
Next i
'..........
I have attached the whole project (thus far) for people to play around with; right click and drag on the form to select, left click on the form and drag to move.
Re: Selecting and drag/drop multiple images and labels.
Try this
VB Code:
Private Sub Form_MouseMove(button As Integer, shift As Integer, x As Single, y As Single)
Static mousex As Single, mousey As Single
Select Case button
[B] Case 0
mousex = x
mousey = y[/B]
Case 1
For i = LBound(Selection()) To UBound(Selection())
If Selection(i).SelectingState Then
Selection(i).con.Left = Selection(i).con.Left + (x - mousex)
Selection(i).con.Top = Selection(i).con.Top + (y - mousey)
End If
Next i
[B] mousex = x
mousey = y[/B]
Case 2
If SelectingState = True Then 'get some asprin ;)
Line1(0).Y1 = selbox(4).ly
Line1(0).X1 = selbox(4).lx
Line1(0).Y2 = y
Line1(0).X2 = selbox(4).lx
'upper left corner
selbox(0).lx = selbox(4).lx
selbox(0).ly = selbox(4).ly
Line1(1).Y1 = y
Line1(1).X2 = selbox(4).lx
Line1(1).Y2 = y
Line1(1).X1 = x
'upper right corner
selbox(1).lx = x
selbox(1).ly = selbox(4).ly
Line1(2).Y1 = y
Line1(2).X1 = x
Line1(2).Y2 = selbox(4).ly
Line1(2).X2 = x
'lower left corner
selbox(2).lx = selbox(4).lx
selbox(2).ly = y
Line1(3).Y1 = selbox(4).ly
Line1(3).X1 = x
Line1(3).Y2 = selbox(4).ly
Line1(3).X2 = selbox(4).lx
'lower right corner
selbox(3).lx = x
selbox(3).ly = y
For i = LBound(Selection()) To UBound(Selection())
If (Selection(i).con.Left < selbox(0).lx And _
Selection(i).con.Left > selbox(1).lx Or _
Selection(i).con.Left > selbox(0).lx And _
Selection(i).con.Left < selbox(1).lx) And _
(Selection(i).con.Top > selbox(0).ly And _
Selection(i).con.Top < selbox(3).ly Or _
Selection(i).con.Top < selbox(0).ly And _
Selection(i).con.Top > selbox(3).ly) _
Then
Selection(i).con.BorderStyle = 1
Selection(i).SelectingState = True
Else
Selection(i).con.BorderStyle = 0
Selection(i).SelectingState = False
End If
Next
End If
End Select
End Sub
Re: Selecting and drag/drop multiple images and labels.
Thanks. Here is the completed program; I also added some old scroll bar code, that works farley well, that I got off of sorceforge.net some time ago.