Jump to content

Drag and Drop - the other way around


Recommended Posts

Since I didn't get much help on my last thread (due to an ill explained problem, I guess) I will try to explain what I'm needing help with. Here goes...:

I'm making an app that will convert font files. Here's how it works:

1.) The user will drag in the file(s) that they want converted to a certain part (a group control) of my GUI window.

2.) The file will be converted.

3.) The user can then use the second part (a group control) of the GUI to "drag and drop" from their converted "file(s)" to the desktop, or the location they choose, and have the converted file copied there.

I'm really need help with number 3. 1 & 2 I've been able to do, but number 3 is proving to be difficult, because I'm not that advanced enough to accomplish it. I'm trying to have it so they (the user) can drag and drop from my GUI window to the desktop (from my GUI Window), and the files appear on their desktop. I've only been able to drag and drop from the desktop to my GUI window.

Any help with this guys? Threads, Ideas...etc? Thanks!

EDIT: I've found a C# code sample that shows exactly what I want to do:

http://www.codeproject.com/KB/cs/draginternetshortcut.aspx

Edited by motionman95
Link to comment
Share on other sites

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Bump :)

I'm sure there are a lot of people who would be happy to help you, as I would, but I don't know what you are dealing with. You haven't told us what there is in your gui that we are selecting and dragging. Is it an item in a list box, an icon in a list view, a line in an edit, a label, an icon or something else?

If you tell us what you want to drag it would help, and what might be even better would be to show us what you have so far if you can.

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

Thanks for the reply, Volly. If I did post my code, I don't think it would help. The code I have now has nothing to do with this problem, I simply have no idea how to go at this problem. I think this link will help you guys to understand what I'm trying to accomplish better than me trying to explain it.

http://www.codeproject.com/KB/cs/draginternetshortcut.aspx

Link to comment
Share on other sites

Thanks for the reply, Volly. If I did post my code, I don't think it would help. The code I have now has nothing to do with this problem, I simply have no idea how to go at this problem. I think this link will help you guys to understand what I'm trying to accomplish better than me trying to explain it.

http://www.codeproject.com/KB/cs/draginternetshortcut.aspx

If you have code that you can drag a font file into, and you have conversion code that can create a converted font file, why not post that so others can work on adding the ability to drag the converted files to the desktop. That way we can play with something and not have to create the initial part from scratch.

Bob

--------------------bobchernow, Bob ChernowWhat a long strange trip it's beenUDFs: [post="635594"]Multiple Monitor Screen Resolution Change[/post]

Link to comment
Share on other sites

Here's the code my app - I haven't worked in the font converting method yet, but I already know how I'm going to do it. Also, this code only has drag and drop to theGUI, and not drag and drop from the GUI to the desktop.

#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
            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

I don't know how this will help anyone help me with my problem, but I've posted it anyway...

Link to comment
Share on other sites

Here's the code my app - I haven't worked in the font converting method yet, but I already know how I'm going to do it. Also, this code only has drag and drop to theGUI, and not drag and drop from the GUI to the desktop.

#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
            If StringRegExp($file, "^.+\.(?i)((TTF)|(OTF)){:content:}quot;) Then
                MsgBox(0, "", $file & @CRLF & "Is a font file.")
            Else
                MsgBox(0, "", $file & @CRLF & "Is an invalid file type.")
            EndIf
    EndSwitch
WEnd

I don't know how this will help anyone help me with my problem, but I've posted it anyway...

Without the jpg I don't know what your gui looks like.

You could have a list box which you drop items into. Then the user can see the items he's dropped and which have to be converted.

The converted files can be put in a second list box and then the user could drag items from there.

It might be easier to simply select an item and have a button or menu to save the file to the desktop.

You could save the converted files in a special folder then show that folder so the user could drag and drop the files from there to wherever he wanted then you have no drag and drop code to worry abouit.

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

Well, since it isn't going to work that way, would it be possible (as far as dragging into an explorer window) to just use the handle on the explorer window, and look into whatever text input it is that holds the current directory?

post-44565-1235228678_thumb.jpg

You could have a list box which you drop items into. Then the user can see the items he's dropped and which have to be converted.

The converted files can be put in a second list box and then the user could drag items from there.

Is there a way to do that?

Without the jpg I don't know what your gui looks like.

Here's the image:

post-44565-1235228872_thumb.jpg

Edited by motionman95
Link to comment
Share on other sites

I have an idea - would it be possible to get the user's x and y of their drag and drop, and then simulate the exact same one?

DOn't understand that.

Also, would embedding a windows explorer into my a GUI allow me to drag and drop to the desktop?

Yes, but it might look a bit messy.

$gg = GUICreate("drag  from")
GUISetState()
$folder = "c:\temp"
shellexecute("explorer.exe",$folder)
sleep(1000)
$hExpl = wingethandle("C:\temp")
WinMove($hExpl,"",0,0,200,200)
$OrigParent = DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle("C:\temp"), "hwnd",$gg)
while 1
    sleep(90)
if GUIGetMsg() = -3 then Exitloop

WEnd
DllCall("user32.dll", "int", "SetParent", "hwnd", $hExpl, "hwnd",$OrigParent[0])
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

Awesome! Is it possible to remove the tool bars and the right-click menu?

Edit: By "I have an idea - would it be possible to get the user's x and y of their drag and drop, and then simulate the exact same one?" I meant that could I get the x and y of the first press of the drag and drop, then the x and y of the release?

Edited by motionman95
Link to comment
Share on other sites

Awesome! Is it possible to remove the tool bars and the right-click menu?

Edit: By "I have an idea - would it be possible to get the user's x and y of their drag and drop, and then simulate the exact same one?" I meant that could I get the x and y of the first press of the drag and drop, then the x and y of the release?

I don't understand that again.

This is a way to do something like what you want.

You can drag a file to the left hand listr box. SDelect it the press the "process" button and it will be copied to th eright hand list box. From there you can drag it to the desktop.

#include <GUIConstants.au3>
#include <Misc.au3>
#include <guilistbox.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 = GUICtrlCreateList("", 10, 100, 160, 160);Label("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 = GUICtrlCreateList("", 240, 100, 180, 160);Label("2.)", 291, 160, 19, 17)
;GUICtrlSetState(-1, $GUI_DROPACCEPTED)
;GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
$process = GUICtrlCreateButton("process", 175, 150, 47, 20)
;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
            If StringRegExp($File, "^.+\.(?i)((TTF)|(OTF))$") Then
                MsgBox(0, "", $File & @CRLF & "Is a font file.")
                GUICtrlSetData($Label5, $File, 1)
            Else
                MsgBox(0, "", $File & @CRLF & "Is an invalid file type.")
            EndIf
        Case $process
            ConsoleWrite("button process" & @CRLF)
            GUICtrlSetData($Label6, GUICtrlRead($Label5), 1)

    EndSwitch
    $dg = GUICtrlRead($Label6)
    If $dg <> '' Then
        $cp = GUIGetCursorInfo()
        If IsArray($cp) Then
            If $cp[2] Then
                ConsoleWrite("left down" & @CRLF)
                If $cp[4] = $Label6 Then
                    ConsoleWrite("over rh lv" & @CRLF)

                    While _IsPressed(01)
                        Sleep(10)
                    WEnd
                    ConsoleWrite("left up" & @CRLF)
                    $point = MouseGetPos()
                    $ans = _WinInfoFromPoint($point[0],$point[1])
                    if StringInStr($ans,"Class: SysListView32;") and _
                         StringInStr($ans,"Owner: Progman;") Then
                         filecopy($dg,@DesktopDir)
                     EndIf
                     
                EndIf
            EndIf
        EndIf
    EndIf


WEnd


Func _WinInfoFromPoint($nX, $nY);by Saio
    Local $tStrBuff, $pStrBuff, $aRet, $hWnd, $hOwnerWnd, $sClassName, $sOwnerClass, $sWinText
    $tStrBuff = DllStructCreate("char[100]")
    $pStrBuff = DllStructGetPtr($tStrBuff)
    $aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", $nX, "uint", $nY)
    $hWnd = $aRet[0]
    $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100)
    $sClassName = DllStructGetData($tStrBuff, 1)
    DllStructSetData($tStrBuff, 1, "")
    DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100)
;~  DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "uint", $WM_GETTEXT, "uint", 100, "ptr", $pStrBuff)
    $sWinText = DllStructGetData($tStrBuff, 1)
    DllStructSetData($tStrBuff, 1, "") 
    $aRet = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hWnd, "uint", 2);$GA_ROOT = 2
    $hOwnerWnd = $aRet[0]
    $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hOwnerWnd, "ptr", $pStrBuff, "int", 100)
    $sOwnerClass = DllStructGetData($tStrBuff, 1)
    DllStructSetData($tStrBuff, 1, "")

    Return $sWinText & @CRLF & "[ Class: " & $sClassName & "; hWnd: " & $hWnd & " ]" & @CRLF & _
                        "( Owner: " & $sOwnerClass & "; " & $hOwnerWnd & " )"
EndFunc
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

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...