Results 1 to 7 of 7

Thread: [RESOLVED] Selecting and drag/drop multiple images and labels.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Resolved [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?

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Re: Selecting and drag/drop multiple images and labels.

    Any one have any input? Are there any APIs that I could use?

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Selecting and drag/drop multiple images and labels.

    Perhaps by putting those object in a control array and working with the Index parameter?

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    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.
    Attached Files Attached Files
    Last edited by Andrew G; Oct 29th, 2006 at 09:13 PM. Reason: Ooops forgot to attach

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    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:
    1. Private Sub Form_MouseMove(button As Integer, shift As Integer, x As Single, y As Single)
    2.     Static mousex As Single, mousey As Single
    3. Select Case button
    4.     Case 1
    5.    
    6.         For i = LBound(Selection()) To UBound(Selection())
    7.                 If Selection(i).SelectingState Then
    8.                     Selection(i).con.Left = Selection(i).con.Left + (x - mousex)
    9.                 Selection(i).con.Top = Selection(i).con.Top + (y - mousey)
    10.             End If
    11.         Next i
    12. '..........

    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.

  6. #6
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Selecting and drag/drop multiple images and labels.

    Try this
    VB Code:
    1. Private Sub Form_MouseMove(button As Integer, shift As Integer, x As Single, y As Single)
    2.     Static mousex As Single, mousey As Single
    3. Select Case button
    4. [B]    Case 0
    5.         mousex = x
    6.         mousey = y[/B]
    7.     Case 1
    8.    
    9.         For i = LBound(Selection()) To UBound(Selection())
    10.                 If Selection(i).SelectingState Then
    11.                     Selection(i).con.Left = Selection(i).con.Left + (x - mousex)
    12.                 Selection(i).con.Top = Selection(i).con.Top + (y - mousey)
    13.             End If
    14.         Next i
    15.        
    16. [B]            mousex = x
    17.             mousey = y[/B]
    18.    
    19.     Case 2
    20.         If SelectingState = True Then 'get some asprin ;)
    21.             Line1(0).Y1 = selbox(4).ly
    22.             Line1(0).X1 = selbox(4).lx
    23.             Line1(0).Y2 = y
    24.             Line1(0).X2 = selbox(4).lx
    25.             'upper left corner
    26.             selbox(0).lx = selbox(4).lx
    27.             selbox(0).ly = selbox(4).ly
    28.            
    29.             Line1(1).Y1 = y
    30.             Line1(1).X2 = selbox(4).lx
    31.             Line1(1).Y2 = y
    32.             Line1(1).X1 = x
    33.             'upper right corner
    34.             selbox(1).lx = x
    35.             selbox(1).ly = selbox(4).ly
    36.            
    37.             Line1(2).Y1 = y
    38.             Line1(2).X1 = x
    39.             Line1(2).Y2 = selbox(4).ly
    40.             Line1(2).X2 = x
    41.             'lower left corner
    42.             selbox(2).lx = selbox(4).lx
    43.             selbox(2).ly = y
    44.            
    45.             Line1(3).Y1 = selbox(4).ly
    46.             Line1(3).X1 = x
    47.             Line1(3).Y2 = selbox(4).ly
    48.             Line1(3).X2 = selbox(4).lx
    49.             'lower right corner
    50.             selbox(3).lx = x
    51.             selbox(3).ly = y
    52.        
    53.             For i = LBound(Selection()) To UBound(Selection())
    54.                 If (Selection(i).con.Left < selbox(0).lx And _
    55.                     Selection(i).con.Left > selbox(1).lx Or _
    56.                     Selection(i).con.Left > selbox(0).lx And _
    57.                     Selection(i).con.Left < selbox(1).lx) And _
    58.                     (Selection(i).con.Top > selbox(0).ly And _
    59.                     Selection(i).con.Top < selbox(3).ly Or _
    60.                     Selection(i).con.Top < selbox(0).ly And _
    61.                     Selection(i).con.Top > selbox(3).ly) _
    62.                 Then
    63.                 Selection(i).con.BorderStyle = 1
    64.                 Selection(i).SelectingState = True
    65.                     Else
    66.                     Selection(i).con.BorderStyle = 0
    67.                     Selection(i).SelectingState = False
    68.                 End If
    69.             Next
    70.         End If
    71.  
    72. End Select
    73.  
    74. End Sub

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    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.

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