Sign in to follow this  
Followers 0
trung0407

Drag/Drop question.

4 posts in this topic

How can u drag then drop an image in a windows?

Share this post


Link to post
Share on other sites



Like take an image on the desktop , drag it to your GUI and display it or drag a picture thats already inside a GUI already?

Share this post


Link to post
Share on other sites

Drag a picture which is inside a GUI...

Generally, how can u make a control dragable? <_<

Share this post


Link to post
Share on other sites

Like... moving them inside a GUI?

#include <array.au3>

#include<GuiConstants.au3>
#include<_ControlHover.au3>
Opt("MouseCoordMode", 2)
$Main_GUI = GuiCreate("DanGui", 400, 250)

$MoveMe = GuiCtrlCreateLabel("Move Me (Test)", 150, 70, 80, 20)
$OK_BUT = GuiCtrlCreateButton("OK", 70, 160, 80, 20)
$CANCEL_BUT = GuiCtrlCreateButton("CANCEL", 220, 160, 90, 20)
$Move_But = GUICtrlCreateButton("Unlock Controls", 150, 220)
$Allow_Move = 0
_ControlHover(2, "", $MoveMe)
_ControlHover(2, "", $OK_BUT)
_ControlHover(2, "", $CANCEL_BUT)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $OK_BUT
            If $Allow_Move = 0 Then
                MsgBox(0, "Title", "This button still works!")
            EndIf
        Case $msg = $CANCEL_BUT
            If $Allow_Move = 0 Then
                MsgBox(0, "Title", "This button still works!")
            EndIf
        Case $msg = $Move_But
            If $Allow_Move = 0 Then
                GUICtrlSetData(6, "Lock Controls")
                $Allow_Move = 1
            ElseIf $Allow_Move = 1 Then
                GUICtrlSetData(6, "Unlock Controls")
                $Allow_Move = 0
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    
    ;If moving is enabled
    
    If $Allow_Move = 1 Then
        
        ;Check for a Hover
        
        $Over = _ControlHover(0, $Main_GUI)
        If $Over = 1 Then
            If @extended = $MoveMe Then
                GUICtrlSetBkColor(3, 0xFF0000)
            Else
                GUICtrlSetBkColor(3, 0xECE9D8)
            EndIf
            If @extended = $OK_BUT Then
                GUICtrlSetColor(4, 0xFF0000)
            Else
                GUICtrlSetColor(4, 0xECE9D8)
            EndIf
        EndIf
        
        ;Check for a Click
        
        $Click = _ControlHover(1, $Main_GUI)
        If $Click = 1 Then
            Select
                Case @extended = $MoveMe
                    MoveControl(3)
                Case @extended = $OK_BUT
                    MoveControl(4)
                Case @extended = $CANCEL_BUT
                    MoveControl(5)
            EndSelect
        EndIf
        $Check_Click = GUIGetCursorInfo()
        Select
            Case $Check_Click[4] = 3 And $Check_Click[3] = 1
                Text_Change(3)
            Case $Check_Click[4] = 4 And $Check_Click[3] = 1
                Text_Change(4)
            Case $Check_Click[4] = 5 And $Check_Click[3] = 1
                Text_Change(5)
        EndSelect
    EndIf
WEnd

;Text_Change ==> To rename a control in "Unlocked" mode when it is right-clicked on.

Func Text_Change($IDtoRename)
    $New_Name = InputBox("Label Change", "Input new text for this label:")
    If $New_Name = "" Then
        MsgBox(0, "ERROR!", "The entered text was invalid.  No changes have been made.")
    Else
        GUICtrlSetData($IDtoRename, $New_Name)
    EndIf
EndFunc

;MoveControl ==> When a control is clicked on in "Unlocked" mode.

Func MoveControl($IDtoMove)
    Do
        $Check_Click = GUIGetCursorInfo()
        $mousepos = MouseGetPos()
        GUICtrlSetPos($IDtoMove, $mousepos[0] - 40, $mousepos[1] - 10)
        Sleep(20)
    Until $Check_Click[2] = 0
EndFunc

Search the forums for _ControlHover.au3 You'll need it for this example.

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