Sign in to follow this  
Followers 0
BigDaddyO

Drag & Drop Control to Control

1 post in this topic

I have a script that displays a group of random numbers to a user. The user must then put those numbers into the order that they want. I wanted to display the numbers on Lables or buttons and have them Drag & drop them onto other labels and I would then detect that movement, Delete the Dragged from control, and update the Dragged to control with the new info.

Here is what I have so far, but I can't find anything but Listboxes that will allow you to drag from.

Any ideas?

#include <GUIConstants.au3>

    Dim $labelA[7], $labelB[7], $AttribA[7], $AttribB[7]
    Dim $X = 800, $Y = 600
    Dim $Attribs[7] = [0, "A", "B", "C", "D", "E", "F"]

    $GUI = GUICreate("", $X, $Y, -1, -1, $WS_DLGFRAME, $WS_EX_ACCEPTFILES)
    
    $Step1 = GUICtrlCreateLabel("Using the numbers on the left, Drag and Drop them in the order you want on the Right", 20, 20, $Y - 20, 20)

    $iX = 280
    $iY = 180
    for $i = 1 to 6
        $labelA[$i] = GUICtrlCreateLabel("Random " & $i & ":", $iX, $iY + 3, 70, 20)
        $AttribA[$i] = GUICtrlCreateButton(Random(1, 60, 1), $iX + 75, $iY, 20, 20)
        GUICtrlSetState(-1, $GUI_DROPACCEPTED)
        $iY = $iY + 30
    Next
    $btnNextA = GUICtrlCreateButton("Next", $X - 100, $Y - 60, 80, 25)
    $btnExit = GUICtrlCreateButton("Exit", 20, $Y - 60, 80, 30)


    $iX = 480
    $iY = 180
    for $i = 1 to 6
        $labelB[$i] = GUICtrlCreateLabel($Attribs[$i], $iX, $iY + 3, 70, 20)
        GUICtrlSetFont(-1, 10)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $AttribB[$i] = GUICtrlCreateInput("", $iX - 35, $iY, 20, 20)
        GUICtrlSetState(-1, $GUI_DROPACCEPTED)
        GUICtrlSetFont(-1, 10)
        $iY = $iY + 30
    Next
    
    $btnBackB = GUICtrlCreateButton("Back", $X - 10, $Y - 60, 80, 25)
    GUICtrlSetState(-1, $GUI_HIDE)
    $btnNextB = GUICtrlCreateButton("Next", $X - 100, $Y - 60, 80, 25)
    GUICtrlSetState(-1, $GUI_HIDE)

    
    
    GUISetState(@SW_SHOW)
    While 1
        $msg = GUIGetMsg()
        Select 
            Case $msg = $GUI_EVENT_DROPPED
                MsgBox(0, "Dropped", "From = "& @GUI_DRAGID & @CRLF & "To = " & @GUI_DROPID)
            
            Case $msg = $btnExit
                if MsgBox(292,"Exit","Are you sure you want to exit?") = 6 Then Exit

            case Else
                ;;;;
        EndSelect
    WEnd

Thanks,

Mike


Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0