There is nothing wrong with your television set. Do not attempt to adjust the picture.
Status
Latest version: 5.1
Released: 29 jan 2010
Download
The Drag and Drop Component Suite is a freeware VCL component library that enables your Delphi and C++Builder applications to support COM based drag and drop and integrate with the Windows clipboard.
The drag and drop system that is built into the VCL, is limited in that it only supports drag and drop within the same application. If you need to drag data from your application to other applications (e.g. Word, Explorer or Outlook), or if you need to be able to accept data dropped from other application (e.g. the Explorer), you have to use COM based drag and drop. COM based drag and drop is an integral and very important part of the Windows user interface and the Drag and Drop Component Suite makes it very easy to leverage all the features of COM based drag and drop in your own Delphi and C++Builder applications.
Every drag and drop operation involves two objects: A drop source and a drop target. The drop source provides the data to be dragged, and the drop target accepts the dragged data.
Likewise there are basically two sets of components in the Drag and Drop Component Suite; Drop source components and drop target components. Most of the source and target components are specialized to handle just one type of data, but a few of the components supports a wider range of data types or are completely generic.
In addition to the drag and drop components, the Drag and Drop Component Suite also includes components that can be used to build Windows Shell Extensions. While these components aren’t all related to Drag and Drop, they benefit from the Drag and Drop Component Suite framework and allow you to write Windows Shell Extensions with very little code. But most important; I had a lot of fun writing them :-).
IDropSource, IDropTarget, IDataObject and IAsyncOperation interfaces.The Drag and Drop Component Suite contains the following components:
| Drop Sources | Drop Targets | |
|---|---|---|
|
|
| Shell Extensions | Additional |
|
|---|---|---|
|
|

This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 Unported License.
The library has been tested with the following versions of Delphi:
| D1 | D2 | D3 | D4 | D5 | D6 | D7 | D2005 | D2006 | D2007 | D2009 | D2010 |
If you can confirm compatibility with any of the untested versions of Delphi (or C++ Builder for that matter), please let me know and I will update the table.
[Updated 2010-01-31] Added D2006 per user feedback.
I have done absolutely no testing with C++ Builder so I don’t know if the code works with it or not. That said, according to feedback I have received, the current release should work with C++ Builder.
| Download: | The Drag and Drop Component Suite v5.1 - Complete |
|---|---|
| Version: | 5.1 |
| Updated: | 29 January, 2010 |
| Size: | 518.29 KB |
| Notes: | Includes component source and demo applications. |
| Downloads: | 478 |
| Download: | The Drag and Drop Component Suite v5.1 - Source |
|---|---|
| Version: | 5.1 |
| Updated: | 29 January, 2010 |
| Size: | 134.09 KB |
| Notes: | Includes component source only. |
| Downloads: | 119 |
Old versions can be found on the downloads page.
Packages folder, find the design time package that matches your version of Delphi. Open it in Delphi, Compile and Install.Library sub-folder that matches your version of Delphi. Add it to the Delphi library search path.Source folder to the Delphi browsing path.Drag and Drop Component Suite design time package.Library folder from the Delphi library search path.Source folder from the Delphi browsing path.Changes since version 4.2:
MakeRTF function in the DragDropText unit failed to compile with some versions of Delphi.DragDetectPlus no longer eats right-click mouse messages.OnGetData event) instead of when the data is dropped (OnDrop event). This change was made to handle application that require the files to be physically present when ever they query the drop source for the file names.TListView’s internal mouse message handling makes it impossible to handle right-click correctly.TCustomDropTarget.Enabled property.TMessages class (used for Outlook drag/drop) now support sessions. This can be (and is) used to work around the various quirks in Outlook’s interface reference counting mechanism.TAnsiStringClipboardFormat.GetClipboardFormat has been implemented.TCustomDropTarget.PasteFromClipboard no longer clears the data after the OnDrop event has fired.TClipboardFormat.GetData that caused drop targets to reject data after first drop.TTextDataFormat that mainly affected TDropTextTarget.TDropComboTarget.OptimizedMove and TDropFileTarget.OptimizedMove is now declared correctly.TStrings but is Assign/AssignTo compatible with it.TWideStringList for Unicode support, now use the new TUnicodeStringList instead.DragDetectPlus function now leave mouse click messages (WM_xBUTTONDOWN, WM_xBUTTONUP, etc) in the message queue.MakeRTF utility function now support Unicode strings and generate proper RTF formatted text.TRichTextClipboardFormat class).TCustomDropSource.OnGetDragImage event added.TFileGroupDescriptor*ClipboardFormat, TFileContents*ClipboardFormat and TVirtualFileStreamDataFormat classes has been moved to the DragDropFile unit.T*TextClipboardFormat classes has been moved to the DragDropText unit.CreateIStreamFromIStorage and CreateIStorageOnHGlobal which primarily affected drag/drop from Outlook.TFileGroupDescriptorCustomClipboardFormat.TFilenameClipboardFormat has been renamed TAnsiFilenameClipboardFormat.TFilenameWClipboardFormat has been renamed TUnicodeFilenameClipboardFormat.TFilenameClipboardFormat is now an alias for the native (ansi or unicode) format.TFilenameMapClipboardFormat has been renamed TAnsiFilenameMapClipboardFormat.TFilenameMapWClipboardFormat has been renamed TUnicodeFilenameMapClipboardFormat.TFilenameMapClipboardFormat is now an alias for the native (ansi or unicode) format.TFileGroupDescriptorClipboardFormat has been renamed TAnsiFileGroupDescriptorClipboardFormat.TFileGroupDescriptorWClipboardFormat has been renamed TUnicodeFileGroupDescriptorClipboardFormat.TFileGroupDescriptorClipboardFormat is now an alias for the native (ansi or unicode) format.TTextClipboardFormat has been renamed TAnsiTextClipboardFormatTCustomTextClipboardFormat has been renamed TCustomAnsiTextClipboardFormatTCustomWideTextClipboardFormat has been renamed TCustomUnicodeTextClipboardFormatTTextClipboardFormat is now an alias for the native (ansi or unicode) format.TDropTextTarget, TDropTextSource and TTextDataFormat now keeps string data data in the source format and only converts between unicode and ansi on demand.Text property of TDropTextTarget, TDropTextSource and TTextDataFormat is now named AnsiText.Text property of TDropTextTarget, TDropTextSource and TTextDataFormat now returns the native string format.RichText, OEMText, CSVText and HTML properties of the TDropTextTarget, TDropTextSource and TTextDataFormat classes are no longer supported and have been removed.TDropContextMenu component.TDropContextMenu.OnPrepareMenu event.TDropContextMenu.FolderPIDL and TDropContextMenu.Folder properties.TDragDropHandler.GetFolderPIDL function has been replaced with the FolderPIDL property.TURLClipboardFormat has been renamed TAnsiURLClipboardFormatTURLWClipboardFormat has been renamed TUnicodeURLClipboardFormatTURLClipboardFormat is now an alias for the native (ansi or unicode) format.Title property of TDropURLTarget, TDropURLSource and TURLDataFormat is now a Unicode string.const directive to interface parameters.TFileGroupDescriptorCustomClipboardFormat as common ancestor for TFileGroupDescriptorClipboardFormat and TFileGroupDescriptorWClipboardFormat.In short, you can’t.
You must understand that the drag/drop API works the same for all applications that uses it, and the Explorer is just like any other application. The drag/drop API provides a framework that facilitates the interaction between a drop source and the target, but since the drop target can do anything it wants with the data it receives, there is no way to communicate the destiny of the data back to the drop source in a uniform way.
One target may chose to display the dropped data (e.g. notepad), another one to upload it to a web server (e.g. a FTP client), a third to move and rename the file (e.g. the Recycle Bin) and a fourth may chose to copy or move the file (e.g. Explorer).
In my experience there is never any real need to know the destination of a drop to the Explorer. If you find that you do need this, you should rethink your solution. - and feel free to ask for help.
AllowAsyncTransfer property and the Execute methods’ Asynchronous parameter?The Execute methods Asynchronous parameter specifies if the source should perform the transfer in a thread.
The AllowAsyncTransfer property specifies if the drop target is allowed to perform an asynchronous transfer.
The two are completely independent. One does not have priority over the other.
Asynchronous transfer on the source side is an “invention” of mine. It can be done even if the drop target doesn’t support, and thus doesn’t take an active part in, asynchronous transfer.
Asynchronous transfer on the target side is a COM drag/drop feature (see IAsyncOperation in MSDN). It requires that both the source and the target support asynchronous transfer. All the Drag and Drop Component Suite components support asynchronous transfer, but apart from Windows Explorer few applications has implemented the feature.
An optimized move is simply a move operation where the drop target moves the data from the source to the destination location.
In a conventional move operation, the source and the target must cooperate in order to complete the operation. First the target makes a copy of the data at the desired location. Then, when the target has completed copying the data, it hands control back to the source who then deletes the original data. This procedure can be very inefficient because it requires two simultaneous copies of the data.
With an optimized move, the target handles the entire move operation and signals the source that an optimized move took place upon completion.
The Drag and Drop Component Suite supports Optimized Move on both the source and target side.
When migrating from pre-5.0 releases, are there any guidelines? Code that needs to be changed, "gotchas" to look out for, etc.
Thanks.
It depends…
If you are using custom drop target or drop source classes, or using the data- and clipboard format classes directly, then things have changed quite a lot. Many classes have been renamed and reimplemented.
If you are just using the standard components then you should be good to go. I have made a great effort to maintain high level backward compatibility.
One thing to look out for is that
TDropFileTarget.FilesandTDropFileSource.Filesis now a custom string list which doesn't descend fromTStrings. This will not be a problem in most cases and the compiler will catch it for you if it is. I.e. if it compiles, then it works.When attempting to compile/install the D-and-D Component Suite 5 in D5 I get two errors:
"Cannot find the resource file …DragDropD5.res. Recreated" (which is a minor problem…)
and a fatal error: "Could not create output file …\DropSource.dcu".
The package fails to install.
Is there a problem somewhere?
The missing
.resfile is normal. Since the.resfile will be recreated by Delphi when you open the package, I decided not to include it in the zip file this time. The same goes for the.projand.group_projfiles used by D2005 and later.The "Cannot create out file…" error is likely caused by a missing folder. The zip file contains a number of empty folders under the
DragDrop\Libraryfolder. When you unzipped the file these folders should have been recreated even though they are empty. I known that WinZip, 7-zip and WinRar supports this - did you use something else?The Delphi 5 package outputs the binary files (
.dcu,.bpl,.dcp) in theDragDrop\Library\Delphi 5folder. Try creating that folder and recompile the package.Yes, as you said. Now it installs OK. Many thanks!
great work! would you consider about creating an online svn/cvs repository?
The source currently lives in a StarTeam repository on a SAN hosted by a cluster situated in a nuclear proof bunker. The only downside is that I can only access it through VPN.
It would be nice if I could give the public access to the source, or move the source to a public repository, but I'm afraid there's nothing "in it for me" - only more work.
Excelent component! I'll be using it from now on..
P.S. A lot of demo apps are raising weird exceptions at startup. Please, have a look. I'm using Delphi 7 on Windows 2003 Server R2..
The DropTarget component is working easy and nice as it's supposed to.
Congratulations for your great work!
That is because the forms has been opened (by me) with a newer version of Delphi than the one you are using. It's a quite common problem when working with multiple versions of Delphi.
To resolve the problem just open the forms and save them and then recompile.
Just downloaded and tested some of your demos. In the file source demo I can drag files FROM my application into any Windows Explorer window, except on the desktop. Why? Isn't the windows desktop just another instance of explorer.exe?
What am I missing?
It's a bug.
One of the classes that converts between filenames and PIDLs has a problem that prevents the "Link" drop kind from working.
I have already fixed it internally and will post a new version ASAP.
Regarding the SourceDemo
Can the following two kinds of drag'n'drop co-exisit:
1. Drag the ListView items to other applications, eg Explorer (this is a behavior of the SourceDemo)
2. If the user drag'n'drop the ListView items within the ListView, I want the items to be re-sorted.
Please advise. Thank you.
That's actually quite easy:
TDropFileTargetcomponent to turn the listview into a drop target.TListView.OnMouseDownhandler). Clear the flag whenTDropFileSource.Executereturns.TDropFileTarget.OnEnterhandler reject the drop unless the flag has been set.TDropFileTarget.OnDrophandler move the currently selected listview items to the drop location. You can useTListView.GetItemAtto find the drop location.See also: Rearrange Multiple TListView Items using Drag and Drop.
Thanks for your components it is a wonderful gift To the community but..
it fails to compile so does not install.
[DCC Error] DragDropText.pas(325): E2011 Low bound exceeds high boundI hope you can fix it soon .
Merry Christmas - Peace
Philippe Watel
Which version of Delphi are you using?
Hello. I trying to make drag&drop images from browser to my program.
using DropComboTarget.
With Firefox it works fine. I get Bitmap and working with it, but with IE and Chrome i got only Text and Url when drop image. I tried to look at Source Analyzer Demo: when i drop image from
)
Chrome i got "filecontents" and this is content of dropped image, but in DropComboTarget i got only Text & Url … (sorry if my English was bad, hope u understand me
As far as I can tell this is caused by a bug in IE8 (as far as I remember it used to work in previous versions of IE): IE does offer the FileContents clipboard format, but fails to actually fill it with any data. The Drop Source Analyzer indicates this by drawing the medium (GlobalMem) in red.
If you are seeing something different please state your version of IE and mail me the data format list (select Save list… from the toolbar) from the Source Analyzer.
Further tests show that IE8 can drag images, but only if the image isn't wrapped in an A tag (i.e. a link). I'm afraid there's nothing I can do about this strange behavior.
hi
delphi 2010 but i tried with 2009 and it was the same
bye
PW
I'm afraid I can't reproduce your problem with either D2009 or D2010 but try rewriting the case statement like this:
We have same error happened as
[DCC Error] DragDropText.pas(325): E2011 Low bound exceeds high bound. But It's OK now after modify those code from you.Thanks for the feedback.
Although I still cannot reproduce the error I have now applied the change to my source so the problem doesn't reappear.
Hello!
Delphi 2009, component
TDropFileSource.In popup menu:
It's a known problem.
I will see if I can find time to upload a new version this week.
This works beautifully in Delphi 6 but …
I had a lot of trouble getting this to install. I am now having to reinstall my system after a crash and so far have not been able to pesuade Delphi to compile D & D again (yes the folder does exist per above comment by David).
Thank you for this package. I appreciate the work put into its creation as I was part way through trying to work this out myself when I found your components.
What error are you getting from the compiler?
Thank you for the reply. The error message is
Could not create output file …\DropSource.dcu
On a hunch I tried adding the contents of the source folder to
Delphi6\Liband placingDragDropD6.dpkin the same folder, double clicked onDragDropD6.dpkand it installed.Hope this helps Paul
I just checked the Delphi 6 package files and it appears that they were not configured correctly.
With the files back in their original locations try editing the package source files in notepad:
DragDropD6.dofchange the[Directories]section:DragDropD6.dpkupdate the path to the source files:The
DragDropD2006.dpkandDragDropD2007.dpkfiles also needs to have their{$R}directives adjusted.Thank you for the help.
Hello,
I have an application which will get all the email addresses in the server, and put them in the listview. Now I want this email addresses could be dragged from my listview to contacts in Outlook 2007.
could this be possible?
thanks and best regards
Yes it is possible.
There are two ways to do it:
Use the
TDropFileSourcecomponent to drag a vCard file. See the VirtualFile demo for an example of how to drag an in-memory vCard.See the Outlook source demo for an example of how to drag Outlook items back into Outlook. The hard part with this solution is the construction of the Outlook contact COM object and I'm afraid I cannot provide any help beyond what the demo provides.
The vCard approach is by far the easiest and I recommend that you use it if possible. You can easily test it with the VirtualFile demo.
WRT messing with Outlook Contact objects I just remembered this old comment.
Hello. My program is using Version 4 of the toolkit, and, based on ExtractDemo, I've been working on having it allow the user to drag a .WAV file within the program onto a target location, including other apps that accept .WAV files dropped onto them.
My program renders the file at the time the file dropped to the target location, when
DropFileSource1Dropis executed by my program. This works fine for some apps, however, in testing, there are reports that it doesn't work for some apps. One target app that I tested appears to require a fully-formed valid file to be present on disk at the time the mouse cursor is moved over it, otherwise the mouse cursor stays at "no drop allowed" cursor. Windows Media Player had a similar problem, in that it required a file with the target name to be present on disk, but I was able to get my program to drop into WMP by creating a small dummy file with the target file name, beforeDropFileSource1.Files.AddandDropFileSource1.Executeare called. Then, when theDropFileSource1Dropmethod is executed to do the actual drop, my program just erases the dummy file and re-creates it and WMP received it.The problem: Unlike Windows Media Player, this other program requires the dummy .WAV file to be a VALID .WAV in order for the mouse cursor to indicate the program will accept the file, but if I try erase the file and then recreate it during
DropFileSource1Drop, or if I have my program attempt to open the existing file and add to it, then it won't work because the other program (or windows) has taken control of the file and blocked my app from accessing it or erasing it.Wondering if there is any solution to this problem? How can I prevent the target app from taking control of the file before the
DropFileSource1Dropis executed? Also I am curious how the target app even knows the name of the file when the mouse cursor is hovering over the app, but beforeDropFileSource1Dropis executed?Thanks,
Jeff
The drop target can query the drop target about the data being dragged at any time during the drag operation. It does so using the
IDataObjectthat is passed to it whenIDropTarget.DragEnteris called.The solution to your problem is to create the source files if, and when, the target reads the file names from the drop source source's data object. Fortunately this is very easy: All you have to do is move the creation of the files from the
OnDrophandler to theOnGetDataevent handler.There are a few things you need to be aware of though:
OnGetDataevent is fired each time the drop target callsIDataObject.GetData.IDataObject.GetDatamany times during a drag operation. Each call will fire theOnGetDataevent.IDataObject.GetDatadoes not mean that it will eventually accept the drop.The following changes implement the above in the ExtractDemo application:
I hope this makes sense.
Makes sense. Thanks.
Hi! I've found your components tonight and am amazed. Thanks for the massive amount of work. However, I have to issues trying to simulate file-Drag&Drop from my application to a foreign target application that does not accept data from remote otherwise:
1. Is it possible at all to programatically drag and drop files to the target without moving the mouse cursor to the target "in real-time" with SetCursorPos?
2. The target seems to accept drops from Windows Explorer only. What is so special about Explorer that it can be identified by the target? How can I mimic Explorer's behaviour? Tomorrow, I will use your Source and Target analyzers to find out differences between my DataObjects and those of Explorer. Anyway, if you have an idea, any help is appreciated.
During a drag from Explorer it will most often be the active process. It is however possible to change the active process during a drag with Alt+Tab or by hovering over the task bar.
The target components does supply the InShellDragLoop format automatically but not the Shell Object Offsets format.
Hello, i just tried this one with D2005, using the include path to the source. I took that TargetDemo of the Demos, and modified it, since i can't include packages to my Delphi IDE because of the Delphi version.This one works fine with D5000 ! You should add something like the following, if you can't add packages like me:
I have released version 5.1.
All known bugs and problems fixed.
I have confirmed that these components ARE compatible with Delphi 2006.
By the way… nice job!!!! And much appreciated.
Thanks. I have updated the list.
Is there a way to know the source application?
I mean whether there is a way to know from which application, say WORD, EXCEL, Internet Explorer or FireFox, the data is dragged?
Thanks in advance.
No - not really.
You can examine the data formats offered by the source application and from that you can make an educated guess, but it's only a guess and you will have to have analyzed the different drop sources beforehand to learn of their "fingerprint".
Downloaded the DragDrop components, awesome. Ran the Outlook demo with Delphi 6, everything worked great. Ran the Outlook demo with Delphi 2010, the opening of attachements isn't working (ActionAttachmentOpenExecute). Saving the attachment appears to be failing, yet I'm not getting any errors. I have rights to the directory, not an expert with streams….any ideas?
I have reproduced and fixed the problem.
The function used to create the attachment file,
OpenStreamOnFile(), was declared wrong. The filename parameter must be aPAnsiChareven when Unicode is used.To correct the problem you can cast the filename to a
AnsiStringand then to aPAnsiCharinActionAttachmentOpenExecute:Great suite.
I am trying to make some simple copy/paste but I would like to copy a stream into the clipboard to be paste onto Explorer as a file. Is there any specific example in which this capability can be visualized ?
I am also thinking about how to create a shell handler to transfer this files directly by drag'n'drop (my application actually has the files centralized in a server and each time I need to open or copy them it is a remote operation, so they need to be downloaded first). Will appreciate any help… Thanks !
The VirtualFileStream example does what you need; It demonstrates how to drag data as a file stream or copy it onto the clipboard.
Wrt your second scenarion, check out the AsyncFTPClient example. It drags files from a remote FTP server. The files are transferred from the server on-demand as the drop source requests them.
I cannot help you with the Shell Namespace Extension as I have no experience with that. There are 3rd party solutions that can help with that if you do not wish to get your hands dirty.