?
Solved

Tricky drag&drop problem

Posted on 1999-01-05
17
Medium Priority
?
165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

765 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