[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Tricky drag&drop problem

Posted on 1999-01-05
17
Medium Priority
?
168 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 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