Jump to content

Drag&drop


 Share

Recommended Posts

Hello to all,

try to understand how AI drag&drop works, but have no luck searching in forum.

I try to obtain filename when take a file and leave on my GUI.

Find this example, modify but not works:

#include <GUIConstants.au3>
#include <Misc.au3>

_Singleton("RBC")
$WS_EX_ACCEPTFILES = 16

#Region ### START Koda GUI section ### Form=C:\Program Files\Koda 1.7.01\Forms\QuickFTP\FNTConvert.kxf
$Form1 = GUICreate("Rockbox FNT Converter", 441, 323, 293, 202, -1, $WS_EX_ACCEPTFILES)
$Tab1 = GUICtrlCreateTab(6, 7, 428, 308)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Convert")
$Label1 = GUICtrlCreateLabel("Drop the font(s) onto the left (1st) pane,", 71, 50, 189, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel("then drag the converted font(s) from the right (2nd) pane.", 71, 70, 271, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Owner\My Documents\Autoit Applications\DropBox.jpg", 71, 101, 130, 130)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Label3 = GUICtrlCreateLabel("Status: Waiting...", 71, 248, 85, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Progress1 = GUICtrlCreateProgress(71, 271, 297, 17)
$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\Owner\My Documents\Autoit Applications\DropBox.jpg", 234, 101, 130, 130)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Label5 = GUICtrlCreateLabel("1.)", 127, 160, 19, 17)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label6 = GUICtrlCreateLabel("2.)", 291, 160, 19, 17)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$TabSheet2 = GUICtrlCreateTabItem("About")
$Label4 = GUICtrlCreateLabel("Developed by motionman95, 2009, All Rights Reserved.", 15, 286, 274, 17)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            $File = @GUI_DragFile
            msgbox(0,"",$File)
;~             If StringRegExp($file, "^.+\.(?i)((TTF)|(OTF))$") Then
;~                 MsgBox(0, "", $file & @CRLF & "Is a font file.")
;~             Else
;~                 MsgBox(0, "", $file & @CRLF & "Is an invalid file type.")
;~             EndIf
    EndSwitch
WEnd

Anyone can teach me ?

Thank you,

m.

Link to comment
Share on other sites

Hello to all,

try to understand how AI drag&drop works, but have no luck searching in forum.

I try to obtain filename when take a file and leave on my GUI.

Find this example, modify but not works:

Anyone can teach me ?

Thank you,

m.

Your example has too many extraneous stuff going on. Reduce your scripts down to just what you want to figure out. This demo just accepts drag-n-drop files to an input and also to a picture control. It then responds differently depending on which received the file:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $sPic = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
$sPic &= "\Examples\GUI\logo4.gif"

Global $Form1 = GUICreate("Rockbox FNT Converter", 400, 300, Default, Default, Default, $WS_EX_ACCEPTFILES)
Global $Label1 = GUICtrlCreateLabel("Drop a file onto the input or pic controls...", 20, 20, 360, 20)
Global $Input1 = GUICtrlCreateInput("", 20, 100, 360, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
Global $Pic1 = GUICtrlCreatePic($sPic, 20, 140, 360, 100)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            $File = @GUI_DragFile
            Switch @GUI_DropId
                Case $Input1
                    MsgBox(64, "Input Control", $File)
                Case $Pic1
                    MsgBox(64, "Picture Control", $File)
            EndSwitch
    EndSwitch
WEnd

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...