Tricky drag&drop problem

How do you get the path where the fileobject was dropped ?

The WinZip program does it. You can drag files from a ZIP file and drop them to the Windows Explorer. It can't do this with out knowing the destination path !

Maybe one could use :

DragQueryPoint -> WindowFromPoint -> GetWindowText

BUT

you can only get the directory name that way NOT the full path plus what if you drop the object on a directory not just inside a directory.


Thanks
DanishBAsked:
Who is Participating?
 
williams2Connect With a Mentor Commented:
I know exacly what you want. I have done severel studies into this, and I also know Graham Widemans example very well. Though he cooperates with Angus Johnson and Anders Melander on building some better tools with drag'n'drop.

I can tell you that you have ran into a blind way like I did some time ago. The API does NOT supply enough commands to implement full drag'n'drop functionality, you will therefore have to use the advanced OLE COM to do this.

The freeware + sources done so far can be downloaded at http://www.melander.dk/delphi/index.htm where you will find the drag'n'drop components needed to fully support your request, and they are very easy to use too.

Since you are danish, you may call me at 86401148 for more info on this.

Regards,
Williams
0
 
MadshiCommented:
Hmm. Perhaps this helps:

http://www.wideman-one.com/tech/Delphi/index.htm

There's an explanation about how to use Drag&Drop functions.

Regards, Madshi.
0
 
ptmcompCommented:
Unfortunally I coudn't find my code of it. I think you have to use the IDragDrop interface of the windows shell. There you can get even more information about the drag'n'drop operation.

regards ptm.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
williams2Commented:
ptm: This is exactly what the drag'n'drop components will do, but there's a lot of stuff to take care of when doing the implementation directly.

Cheers,
Williams
0
 
DanishBAuthor Commented:
Thanks. I have tried the drag&drop components BUT I still can't
get the destination drop path. With the components I can program
the same thing WinZip does but I can't do any postprocessing in
that path because I don't know where the files where dropped.

DanishB

0
 
williams2Commented:
I think you can. You can use the TDropSource1.OnDrop event procedure to get the files (with paths). It sure works for me.

I think you should do like i do for example like:

procedure TForm1.DropFileSource1Drop(Sender: TObject; DragType: TDragType;
  var ContinueDrop: Boolean);
begin
  ShowMessage(DropFileSource1.Files[0]);
end;

procedure TForm1.DropFileTarget1Drop(Sender: TObject; DragType: TDragType;
  X, Y: Integer);
begin
  ShowMessage(DropFileTarget1.Files[0]);
end;


remember to use the register(Self) methods on creation and  Unregister on desctruction (.OnDestroy) ..else nothing will work at all.

Regards,
Williams
0
 
DanishBAuthor Commented:
You are right :) Thanks alot.

DanishB

0
 
DanishBAuthor Commented:
To Williams2 :

I must have been sleeping when I wrote the above. It does not
work. If I drag a file from my program ex. "C:\backup\test.txt" to Windows Explorer in "e:\testdir\" I can only get the "C:\backup\test.txt" NOT the destination drop path "e:\testdir\" !

DropFileSource1.Files[0] gives me "C:\backup\test.txt".


DanishB

0
 
williams2Commented:
Wait, I'll have to do some more experiementing with this ..but anyway, you don't have to worry much about this, because, you will only need to do the handling of building the file, then release the drop and let the OLE COM do the rest.

BTW: What exxactly are you planning to do?
0
 
DanishBAuthor Commented:
I need it for a installation program. The "things" you can install are all represented by a little picture. So as an alternative to asking the user to enter a directory (browse)
he can just drag&drop the little picture to the path where
he wants it. A installation script has to be executed in the installation directory (postprocessing).




0
 
williams2Commented:
I see.. I'll see what I can do about it..

Regards,
Williams
0
 
anmeCommented:
Hej drenge...

I'm the author of the Drag and Drop Component Suite.

I assume that you found the Extract demo on my home page - the one that uses the same technique as WinZip.

Unfortunately, as you correctly concluded, this alone can not solve your problem. To my knowledge (and I know a lot <g>), it is not possible for the drop source to get any information at all about the drop destination.

The only solution I can think of is to install a temporary copy hook handler which monitors the file you have created in the temp directory (using the WinZip technique). When the file is dropped and the explorer moves the files to its new destination (the folder where the user dropped it), you will receive notification of the new path.

To learn about copy hook handlers, check out Delphi's ShellExt demo application (delphi\demos\ActiveX\ShellExt) and specifically the ICopyHook interface.
0
 
MadshiCommented:
Hey, and another Delphi homepage / component creator!! Anders, welcome to the EE family...   :-)

Regards, Madshi.
0
 
williams2Commented:
Velkommen Anders !

Oh yeah,

Quite an honor to see some real gurus around this place :-)

...I hope to see you around this area in the future as I can promise, that you will get lot's of challenges. This board is the very reason why I know as much as I know today about programming Delphi.. So say hello to my friends here, I'm sure they will make you feel comfortable ..and busy! ;-)

Regards,
Williams
0
 
anmeCommented:
Thanks.

I don't think I'll be here much. I just followed a link in the referrer log of my web server.

I use most of my spare (computer) time on my components and on the Delphi newsgroups.
0
 
williams2Commented:
I hope you got no problem with me posting the link to your site as I do not find it suitable to dumb them inside a mail. But else I could refer to your website instead.

Regdards,
Williams
0
 
anmeCommented:
No problem at all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.