Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag from grid to Windows Explorer 1

Status
Not open for further replies.

__AAmmiiggoo__

Programmer
Apr 5, 2017
2
DE
Hi,

First of all, i'm new here.

My problem:
I have a grid with some filedata. I can drag and drop a file from windows explorer into the grid.
The filepaths are in my cursor/grid.

My Question:
How can I drag a file out of my grid to the (f. e.) Windows Desktop ? [ponder]
I hope there is a way.

I want to use this grid as fileexplorer.
The google search couldn't help me btw. [sad]

Thanks for help [upsidedown]
 
You can't program what happens when the drag operation ends in Windows Explorer. So your only chance is to put the file as Drag Object/Data at the start of the drag operation. I'm not sure that is possible at all.

Here's the documentation about the Drag object:

Especially the SetFormat and SeteData methods:

Where to use them? Well, in OLEStartDrag you get a parameter passed in called oDatraObject. That is the object having these SetFormat and SetData methods. You might only first SetFormat and then the drop target will come back to your code and raises the OleSetData event, asking for the data to drop. So you can decide which files the drag operation provides at start or end of the drag operation.

I haven't used that as much, so I can't tell you what you really can put there, I don't assume it's enough to set format to 15 (CF_FILES) and set the data to a file name, but that would be the first thing to try.

Actually that works, as I now tried:
Code:
LPARAMETERS oDataObject, nEffect
oDataObject.SetData('filename',15)

You also have to set the OleDragMode to Automatic. Then the file you specify will be dropped on the Desktop or in the Windows Explorer, whereever you drop. So the only further thing to do is determine the selected item and its file name.

Bye, Olaf.
 
Hi AAmmiiggoo,
why do you need to use the explorer at all?
As you already have a form that displays some files, why don't you offer an option (mayby right click context menue) where the user can select to create a link on the desktop?
Creating links with VFP can be done really easy with Windows Script Host:

Code:
LOCAL cFileName as String, cLinkName as String, oShell as Object, ;
      cDesktop as String, oLink as Object
cFileName        = GETFILE()
cLinkName        = INPUTBOX([Name: ],[Linkname],JUSTSTEM(cFileName))
cLinkName        = FORCEEXT(JUSTSTEM(cLinkName),[.lnk])
oShell           = CREATEOBJECT([WScript.Shell])
cDesktop         = oShell.SpecialFolders([Desktop])
oLink            = oShell.CreateShortcut(ADDBS(cDesktop) + cLinkName)
WITH oLink
    .WindowStyle        = 3
    .TargetPath         = cFileName
    .WorkingDirectory   = ADDBS(JUSTPATH(cFileName))
    .Hotkey             = [Ctrl+Alt+m]
    .Description        = [Link demonstration]
    .Save()
ENDWITH
RELEASE cFileName, cLinkName, oShell, cDesktop, oLink

-Tom
 
Wow that was fast [thumbsup2]

Okay, I want to handle the Grid like an Explorer and Drag and Drop from the Grid to anywhere I want (like the Windows Explorer).
I try.

@Tom Borgmann
Das ist eine super Idee, aber ich würde gerne die ganze Datei vom Server auf den Client über Drag&Drop aus dem Grid auf den Desktop o.Ä. kopieren.

Thanks ☺
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top