Sign in to follow this  
Followers 0
sandman

Changing the action of dropping a file into an Edit control

3 posts in this topic

I have an Edit control that I would like to add this feature to: When someone drags and drops a file into the editbox, it will read it and display the contents. Everything is working fine, but the default is to display the file's location in the Edit control. How can I just disable it from being shown in the control? I could just remove the string from the control, but there could be a wild case where someone has typed in that path, and it will delete that too. :)

Phew. If you don't understand, please ask me to explain more. I know, I talk fast and type fast. But anyway, does anyone know how this can be done?


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

Hi , you could create a disabled control eg: a label to catch the drop.

example..:

#include <GUIConstants.au3>

$Gui = GUICreate("Drop Edit", 400, 300, -1, -1, -1, $WS_EX_ACCEPTFILES + $WS_EX_TOPMOST)
$CatchDrop = GUICtrlCreateLabel("", 10, 10, 380, 280)
GUICtrlSetState(-1, $GUI_DISABLE + $GUI_DROPACCEPTED)
$Edit = GUICtrlCreateEdit("", 10, 10, 380, 280)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_EVENT_DROPPED
            If StringRight(@GUI_DRAGFILE, 4) = ExtFilter(StringRight(@GUI_DRAGFILE, 4)) Then
                $fo = FileOpen(@GUI_DRAGFILE, 0)
                $fr = FileRead($fo)
                GUICtrlSetData($Edit, $fr)
                FileClose($fo)
            EndIf
    EndSelect
WEnd

Func ExtFilter($iExt)
    $SSEXT = StringSplit(".bat|.cmd|.ini|.txt", "|")
    For $i = 1 To $SSEXT[0]
        If $SSEXT[$i] = $iExt Then Return $iExt
    Next
    Return 0
EndFunc

Cheers

Share this post


Link to post
Share on other sites

Thanks, that works fine.


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

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