views:

108

answers:

2

I hope to to drag a text string and its hyperlink from an HTML page to a TEdit. For example

displays aaa

actual string is <a href=somewhere.html>aaa</a>

I try to use drag&drop vcl, but found that it only can catch aaa itself rather than the string and its hyperlink.

Welcome any comment

Thanks interdev

+4  A: 

Go download Anders Melander's free Drag and Drop Component Suite. In it you'll find TDropURLTarget to put on your form. Set its Target property to refer to your TEdit control, and when a URL is dropped there, the component's URL and Title properties will be updated so you can inspect them during the OnDrop event handler. The suite comes with several examples; TargetDemo has the basics.

Rob Kennedy
But the browser doesn't send them one at a time, and you can't receive something that isn't sent. In your case, what's being dragged is a block of *text*, so it looks like you need to use a plain `TDropTarget` component and look for things that match either `THTMLClipboardFormat` or `TTextClipboardFormat`. Then parse the HTML in that text to find the hyperlinks. How to parse HTML may be covered in other questions here on Stack Overflow.
Rob Kennedy
A: 

Another good library is Raize DropMaster.

Anyway, I believe that it IS possible to do what you want, but maybe it'll turn out to be HTML or RTF drag/drop? Hard to say. I can, for example, drag/drop the list of hyperlinks on this page (over there to the right, under "RELATED") into Word, and they all show up, with hyperlinks on board. So it IS possible. But I suspect that WinWord is dropping as HTML.

Anyway, Rob's suggestion of looking at examples is a good one - between that library and Raize, you should find something that you can use as a prototype.

Chris Thornton
Thanks. Raize Dropmaster also can do what I want.