Version 5 has been released.
This version is obsolete.

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 :-).

Features

  • Freeware with full source code included.
  • Enables COM drag-and-drop of any kind of data between applications.
  • Copy, Move and Link operations.
  • Clipboard Copy, Cut and Paste support.
  • Support and implement advanced features such as Delete-on-paste and Optimized Move.
  • Drag image support.
  • Supports asynchronous transfer. Both on the source and target side.
  • Automatic scrolling of the target window during the drag operation.
  • Relatively simple to derive custom drag-and-drop components to support other data formats.
  • Extensive, context sensitive help file and detailed demo applications.
  • Implements the IDropSource, IDropTarget, IDataObject and IAsyncOperation interfaces.
  • Compatible with Delphi 5-2007.

Components

The Drag and Drop Component Suite contains the following components:

Drop Sources Drop Targets
  • TDropFileSource Enables you to drag files and shortcuts from your application to other applications.
  • TDropTextSource Enables you to drag text from your application to other applications.
  • TDropBMPSource Enables you to drag bitmaps from your application to other applications.
  • TDropURLSource Enables you to drag URLs from your application to other applications.
  • TDropPIDLSource Enables you to drag PIDLs (files, folders, shell objects) from your application to other applications.
  • TDropFileTarget Enables your application to accept files and shortcuts dropped on it from other applications.
  • TDropTextTarget Enables your application to accept text dropped on it from other applications.
  • TDropBMPTarget Enables your application to accept bitmaps dropped on it from other applications.
  • TDropURLTarget Enables your application to accept URLs dropped on it from other applications.
  • TDropPIDLTarget Enables your application to accept PIDLs (files, folder, shell objects) dropped on it from other applications.
  • TDropDummy Helper component used to display drag images.

Examples

The library includes 19 example applications that demonstrates implementations of the most common drag and drop tasks. Also included are four sample shell extensions.

New in version 4.2 are the following two examples:

    The Asynchronous Source with File Stream demo

  • The Asynchronous Source with File Stream example.
    Demonstrates asynchronous drag/drop and data transfer. The example is a small FTP client that performs the data transfer (i.e. FTP download) in a background thread.
  • The Drop Source Analyzer demo

  • The Drop Source Analyzer example.
    Demonstrates a drop target that can read and render any data you drop on it. Used to analyze the capabilities of drop sources. Very useful when you need to determine exactly what data formats an application supports.

License

Creative Commons License
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 Unported License.

Requirements

D1 D2 D3 D4 D5 D6 D7 D2005 D2006 D2007 D2009
Fail Fail Fail Fail Pass Unknown Pass Unknown Pass Pass Fail

Note: The Drag and Drop Component Suite should be compatible with Delphi 5 and later, but it has only been properly tested with Delphi 5, Delphi 7 and Delphi 2007.

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 2008-05-15] Added D2006 per user feedback.

C++ Builder

I have done absolutely no testing with C++ Builder so I don’t know if the code works with it or not. For the same reason I have removed the C++ versions of the examples from this release. If you need them, let me know and I will make them available as a separate download.

That said, according to feedback I have received, the current release should work with at least C++ Builder 5.

Download

download
Download: The Drag and Drop Component Suite v4.2 - Complete
Version: 4.2
Updated: 14 May, 2008
Size: 432.91 KB
Notes: Includes component source and demo applications.
Downloads: 22,356

download
Download: The Drag and Drop Component Suite v4.2 - Source
Version: 4.2
Updated: 14 May, 2008
Size: 119.51 KB
Notes: Includes component source only.
Downloads: 3,141

download
Download: The Drag and Drop Component Suite - Hotfix 4.2.20080604
Version: 4.2.20080604
Updated: 4 June, 2008
Size: 5.08 KB
Notes: Hotfix for the Drag and Drop Component Suite version 4.2
Fixes a memory overwrite bug in TDropFileSource, TDropFileTarget a.o.
Downloads: 4,267

You might also want to check out the development snapshot.

Installation

  1. If you are using a previous version of The Drag and Drop Component Suite, uninstall that version first.
  2. Unzip the package to a folder of your choice.
  3. In the Packages folder, find the design time package that matches your version of Delphi. Open it in Delphi, Compile and Install.
  4. Locate the Library sub-folder that matches your version of Delphi. Add it to the Delphi library search path.
  5. Optional: Add the Source folder to the Delphi browsing path.

Uninstallation

  1. Open Delphi and uninstall the Drag and Drop Component Suite design time package.
  2. Remove the Library folder from the Delphi library search path.
  3. Remove the Source folder from the Delphi browsing path.
  4. Locate the folder where you installed The Drag and Drop Component Suite and delete that folder.

Poll (closed)

I realize that some people might prefer a real installer to the zip-file-do-it-yourself method I have chosen here, while others might not trust an installer and just want the damned source code. Let me known what you think.

Which installation method do you favor?

  • Just give me the source in a ZIP file (72%, 115 Votes)
  • I prefer to have an installer do all the work for me (28%, 44 Votes)

Total Voters: 159

Loading ... Loading …

Change log

Changes since version 4.1

  • Version 4.2 (2008-05-14)
    • Backported to Delphi 5.
    • Added Delphi 5 and Delphi 7 design time packages.
    • Fixed demo project’s output and search path.
    • Added missing demo files.
  • Version 4.2.20080415 (2008-04-15)
    • DragDetectPlus rewritten.
      The old version incorrectly assumed the origin of the cursor position to be relative to the drop source control and not to the screen as it should be. The new version has some logic that should allow it to remain compatible with old code even though the coordinate origin has changed.
    • Wide string (Unicode) support:
      Added wide string support to TStrings with TWideStringsHelper class helper.
      Added TWideStrings and TWideStringList classes.
      Added wide string support to TPIDLClipboardFormat (CF_IDLIST), TFileClipboardFormat (CF_HDROP), TFilenameMapWClipboardFormat (CF_FILENAMEMAPW), TFileDataFormat and thus all the drag/drop components that use these.
    • Changed some String declarations to AnsiChar in preparation for Tiburón.
    • Moved all design-time component registration to the DragDropDesign unit.
    • Added Asynchronous Source with File Stream demo.
    • Added Drop Source Analyzer demo.
    • Removed Netscape demo.

FAQ - Frequently Asked Questions

  • Positive  Negative
    Rating: +6

    When dragging a file from my application to the Explorer, how can I determine the folder where the file is dropped?

    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.

  • Positive  Negative
    Rating: +2

    What is the difference between the drop source components’ 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.

  • Positive  Negative
    Rating: +5

    What is “Optimized Move”?

    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.