czardas Posted March 30, 2010 Share Posted March 30, 2010 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. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted April 1, 2010 Author Share Posted April 1, 2010 (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 April 1, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
martin Posted April 1, 2010 Share Posted April 1, 2010 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. Link to comment Share on other sites More sharing options...
czardas Posted April 1, 2010 Author Share Posted April 1, 2010 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. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now