Jump to content

Drag and Drop help


erezlevi
 Share

Recommended Posts

I need help with implementing a Drag and Drop GUI.

I need a Drop basket so that if someone is draging a file intoit - I will have the file in a directory except from the directory of the Desktop.

this can't help me:

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "", 10,  5, 300, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlCreateInput ("", 10,  35, 300, 20); will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               exitloop
       EndSelect
Wend

MsgBox (4096, "drag drop file", GUICtrlRead($file))

from help file.

Link to comment
Share on other sites

Hi, hope I understood what you wanted.

If a user drops a file from the Desktop you don't want it added to the input box.

But drop a file from anywhere else then it should be added.

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES

GUICtrlCreateLabel("", 10,  5, 300, 20); Dummy label to catch the drop.
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlSetState(-1,$GUI_DISABLE)

$file = GUICtrlCreateInput ( "", 10,  5, 300, 20)
GUICtrlCreateInput ("", 10,  35, 300, 20); will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)

GUISetState ()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $btn
            Exit
        Case $GUI_EVENT_DROPPED
            Local $uDesk = StringLeft(@GUI_DragFile, StringLen(@DesktopDir))
            Local $cDesk = StringLeft(@GUI_DragFile, StringLen(@DesktopCommonDir))
            If $uDesk <> @DesktopDir And $cDesk <> @DesktopCommonDir Then  
                GUICtrlSetData($file, @GUI_DragFile)
            Else
                GUICtrlSetData($file, "")
            EndIf   
    EndSwitch
Wend

Cheers

Edited by smashly
Link to comment
Share on other sites

Hi, hope I understood what you wanted.

If a user drops a file from the Desktop you don't want it added to the input box.

But drop a file from anywhere else then it should be added.

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES

GUICtrlCreateLabel("", 10,  5, 300, 20); Dummy label to catch the drop.
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlSetState(-1,$GUI_DISABLE)

$file = GUICtrlCreateInput ( "", 10,  5, 300, 20)
GUICtrlCreateInput ("", 10,  35, 300, 20); will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)

GUISetState ()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $btn
            Exit
        Case $GUI_EVENT_DROPPED
            Local $uDesk = StringLeft(@GUI_DragFile, StringLen(@DesktopDir))
            Local $cDesk = StringLeft(@GUI_DragFile, StringLen(@DesktopCommonDir))
            If $uDesk <> @DesktopDir And $cDesk <> @DesktopCommonDir Then  
                GUICtrlSetData($file, @GUI_DragFile)
            Else
                GUICtrlSetData($file, "")
            EndIf   
    EndSwitch
Wend

Cheers

no. if someone drops a file into it, it will drop the file to another window that it is opened. like an oulook new mail message.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...