Sign in to follow this  
Followers 0
erezlevi

Drag and Drop help

4 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

BUMP. Help me please....

I need to be able to drag a file from a "basket" GUI to an Outlook new message that is allready opened.

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