Solved

Tricky drag&drop problem

Posted on 1999-01-05
17
156 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:DanishB
  • 7
  • 4
  • 3
  • +2
17 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1354746
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
 
LVL 3

Accepted Solution

by:
williams2 earned 200 total points
ID: 1354747
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
 
LVL 10

Expert Comment

by:ptmcomp
ID: 1354748
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
 
LVL 3

Expert Comment

by:williams2
ID: 1354749
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
 

Author Comment

by:DanishB
ID: 1354750
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
 
LVL 3

Expert Comment

by:williams2
ID: 1354751
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
 

Author Comment

by:DanishB
ID: 1354752
You are right :) Thanks alot.

DanishB

0
 

Author Comment

by:DanishB
ID: 1354753
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Expert Comment

by:williams2
ID: 1354754
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
 

Author Comment

by:DanishB
ID: 1354755
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
 
LVL 3

Expert Comment

by:williams2
ID: 1354756
I see.. I'll see what I can do about it..

Regards,
Williams
0
 

Expert Comment

by:anme
ID: 2218323
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
 
LVL 20

Expert Comment

by:Madshi
ID: 2219085
Hey, and another Delphi homepage / component creator!! Anders, welcome to the EE family...   :-)

Regards, Madshi.
0
 
LVL 3

Expert Comment

by:williams2
ID: 2219601
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
 

Expert Comment

by:anme
ID: 2222556
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
 
LVL 3

Expert Comment

by:williams2
ID: 2225218
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
 

Expert Comment

by:anme
ID: 2225355
No problem at all.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now