Sign in to follow this  
Followers 0
czardas

Drag Drop Overwrite

4 posts in this topic

I have a single line edit control that accepts dropped files. However when I drop a second file into the same edit control, the second path becomes concatenated with the first. :) I simply want the original path to be overwritten. So I have added the following code to select all the data in the control before the drop occurs.

If $msg = $hFile Then _GUICtrlEdit_SetSel($hFile, 0, -1)

Now when the drop occurs, it overwrites the previous path; as expected. However I am curious to know if there are any better ways to do this. :(

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Oh well, I guess nobody knows. It seems kinda strange to me, because I thought it would have been a standard thing to do. So standard, in fact, that I am surprized that it is not already a feature. Which, of course, is the reason I asked - in case I was missing something. etc... :(

Edited by czardas

Share this post


Link to post
Share on other sites

Oh well, I guess nobody knows. It seems kinda strange to me, because I thought it would have been a standard thing to do. So standard, in fact, that I am surprized that it is not already a feature. Which, of course, is the reason I asked - in case I was missing something. etc... :(

Since you didn't show us how you did it when it was a problem you are not making it easy for us to know what was wrong. I would expect that this would work-

GuiCtrlSetData($Edit1,$FileName); will replace any previous text.

If you wanted to add a new line then you simply need to add @CRLF first and add a third non-zero parameter to GuiCtrlSetData.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Since you didn't show us how you did it when it was a problem you are not making it easy for us to know what was wrong.

Thanks for your response Martin. You are absolutely right! I should have posted an example. I am using the control style $WS_EX_ACCEPTFILES and $GUI_DROPACCEPTED with an input control (single line). After dragging a file into the control, I was under the impression that subsequent file drops would overwrite any previous data in the control by default. Hopefully the code below will make things a bit clearer.

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>

$parent = GUICreate(" Drag Drop Overwrite", 320,170, @DesktopWidth/7, @DesktopHeight/7, -1, 0x00000018); $WS_EX_ACCEPTFILES
$sFile = GUICtrlCreateInput ( "", 10, 10, 300, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlSetTip ( $sFile, " Drag your file into the white input box " )
GUISetState ()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $sFile
            _GUICtrlEdit_SetSel($sFile, 0, -1) ; Comment out this line to see the difference.
        Case Else
    EndSelect
Wend
GUIDelete()

When I came up with this solution, I had no idea if it would work or not. I sometimes wonder if I am doing the right thing.

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