Jump to content

Recommended Posts

Posted (edited)

Hi - I am using $WS_EX_ACCEPTFILES and $GUI_DROPACCEPTED to have an Input control accept a filename. When a file is dragged into the input control and the keyboard caret is also focused in the input control - then the file name gets added at the location of the keyboard caret. What I would like is that whenever a file is dragged into the input control - that the file will replace the entire contents of the input control. Does anyone know how I can do this?

 

Steps to reproduce problem:

1. Drag a file into the input control. The filename will show in the input control.

2. The filename will be selected. Press <right arrow> to unselect the text and move the keyboard caret to the right of the text.

3. Drag a second file into the input control. PROBLEM: The input control will now have two filenames in it.

 

Screenshot showing problem after two files have been dragged:

filenamesgetaddedproble.gif

 

Test Code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
$GUI = GUICreate("Test GUI", 800, 100, -1, -1, BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX ), $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_DROPPED, "On_Drop_InFilename")
GUISetOnEvent($GUI_EVENT_CLOSE, '_exit')
GUICtrlCreateLabel('File:', 2, 2)
$inFilename = GUICtrlCreateInput('', 28, 0, 740, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)

Func On_Drop_InFilename()
    Local $filename = GUICtrlRead($inFilename)
    If $filename <> "" Then
        ConsoleWrite("Drag drop found filename in input control: " & $filename & @LF)
    EndIf
EndFunc

Func _exit()
    Exit
EndFunc

While 1
    Sleep(100)
WEnd
Edited by robertcollier4
  • Solution
Posted (edited)

Modify to this

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

GUICreate("Test GUI", 300, 100, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_DROPPED, "On_Drop_InFilename")
GUISetOnEvent($GUI_EVENT_CLOSE, '_exit')

GUICtrlCreateInput('', 28, 20, 240, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState(@SW_SHOW)

Func On_Drop_InFilename()
    GUICtrlSetData(@GUI_DropId, @GUI_DragFile)
EndFunc   ;==>On_Drop_InFilename

Func _exit()
    Exit 1
EndFunc   ;==>_exit

Do

    Sleep(10)

Until 0 

This won't work with multiple files.

Regards :)

Edited by PhoenixXL

My code:

  Reveal hidden contents
PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

If in the future you need multiple files, check out >this example.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

when you droped some thing.the  $GUI_EVENT_DROPPED Event is called.then  you can use the event-function to deal with what you  want to be. sorry for my bad English!





			
		

董小姐,你微笑的时候很美,就像安河桥下,清澈的水...

Posted

What have you tried?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)
  Quote
What have you tried?

He is probably helping OP solve the solved topic. 

Edited by PhoenixXL

My code:

  Reveal hidden contents
PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

Ah OK. But the topic is answered.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
×
×
  • Create New...