Skip over navigation

Drop Files Components

Components that handle drag and drop of files

Version 5.0.5
Released 11 Jan 2014
Platforms Win32 & Win64
Framework VCL
Compatibilty Delphi 7 and later


The Drop Files Components pack includes three components that support drag and drop from Windows Explorer along with subsidiary components that can filter dropped files.

The components are:

A container control that catches files dragged and dropped onto its client area or the client area of child controls.
A non-visual component that catches files dragged and dropped from Explorer onto the form that contains the component.
A non-visual component that catches files dragged and dropped from Explorer onto an associated control.
A file filter component that filters files according to their extension.
A file filter component that filters files according to a DOS-style wild card.
An abstract base class for file filter components. Developers should derive any new filter components from this class.

Some design time assistance is provided by component and property editors.

Key features of TPJDropFiles, TPJCtrlDropFiles and TPJFormDropFiles are:

  • An OnDropFiles event is triggered when files are dropped.
  • The names of dropped files are made available through the Files array property. For convenience, the name of the first such file is also stored in the FileName property.
  • The list of dropped files can be configured to include only files, only folders or all files and folders.
  • Dropped folders can be recursed so that all the files and sub-folders in each of the dropped folders are listed.
  • Filters can be applied to the dropped files and folders. This is done either by linking to a filter component (see above) or by handling the OnFileFilter event and deciding which files and folders to pass through the filter in the event handler.
  • The mouse co-ordinates where the files were dropped can be retrieved, as can a reference to any control under the mouse cursor at the time.
  • The OnBeforeDrop event can be used to perform pre-processing before the files are actually dropped.
  • The IsFolder array property tells if the equivalent item from Files array is a file or a folder.
  • The owning window can be brought to the front when files are dropped.
  • Some design time assistance is provided by component and property editors.

The source code for two demo programs is included:

  1. The main demo program exercises all three drop files components and the filter components.
  2. A program that demonstrates how to use TPJCtrlDropFiles with frames.

TPJDropFiles notifies Windows that it accepts file drop operations by using the DragAcceptFiles API call. It then responds to WM_DROPFILES messages sent by Windows whenever files are dropped on its window.

TPJFormDropFiles and TPJCtrlDropFiles act in a similar way to TPJDropFiles except that they subclass an associated window and respond to WM_DROPFILES messages on the window's behalf. TPJFormDropFiles subclasses its owner form while TPJCtrlDropFiles subclasses the window of an associated TWinControl. The last two components derive from a common abstract base class.

For further information about how to handle files dropped on an application from Explorer, please see my article "How to catch files dragged and dropped on an application from Explorer".

Get The Code

You can download the latest version of the Drop Files Components directly from SourceForge as

Download v5.0.5

Drop Files Components is a sub-project of the DDabLib project which is maintained in a Subversion repository. The code is developed in the trunk/projects/dropfiles branch.

Subversion users can check out the source code of the current release from the repository on SourceForge by doing:

svn checkout codedir

where codedir is the directory where you want to checkout code. To check out other versions, simply specify a different version number.

The latest development tree can be checked out using:

 svn checkout codedir

Check outs are read only, but you can easily contribute code: see Feedback & Queries below.


The Drop Files Components are supplied in a zip file. Before installing you need to extract all the files from the zip file, preserving the directory structure. The following files will be extracted:

  • PJDropFiles.pas – component source code.
  • PJDropFiles.dcr – component palette glyphs.
  • PJDropFilesDsgn.pas – property editors and component registration source code.
  • PJDropFilesDsgn.dfm – property editor form.
  • ReadMe.htm – read-me file.
  • ChangeLog.txt – component's change log.
  • MPL-2.txt – the Mozilla Public License v2.0.
  • Documentation.URL – short-cut to the component's online documentation.
  • PJDropFiles.hlp – component help file that integrates with the Delphi 3-7 OpenHelp system. Deprecated
  • PJDropFiles.als – a-link keyword file for integration with the Delphi 6 or 7 OpenHelp system. Deprecated

In addition to the above files you will find the source code of the two demo projects in the Demo\1 and Demo\2 sub-directories.

You may now install the components into the Delphi IDE. To do this, the files PJDropFiles.pas, PJDropFiles.dcr, PJDropFilesDsgn.pas and PJDropFilesDsgn.dfm should be added to a design time package. If you need help doing this see here.


The Drop Files Components are comprehensively documented online here

The project's change log can be viewed on SourceForge

A read-me file (ReadMe.htm) is included in the project download.

A legacy WinHelp help file is included in the download that can only be integrated with the IDE in Delphi 7 and earlier. This article explains how to do it.

This help file is deprecated and is no longer being updated. The last update was in the v5.0.3 release. The help file will be removed from any future release.

WinHelp is an optional download for Windows Vista through to Windows 8.1 and can't be installed at all on Windows 10.

There is also an FAQ.

Feedback & Queries

If you find any bugs or want to suggest a new feature please report them using the Issue Tracker.

Click the Create Ticket button to create a ticket then complete the form giving as much information as possible.

The issue tracker is shared among all the projects in the DelphiDabbler Code Library, so please make sure you enter dropfiles in the Project edit box to make it clear which project you are referring to. You should also choose Defect in the Type drop down list to report a bug or Enhancement to request a new feature.

If you have created a bug fix or have implemented a new feature please attach a zip file to your ticket that contains your source code.

Should you have any queries about using the components please read the documentation and/or FAQ. If you can't find an answer in the documentation then post a message in the discussion group.


The Drop Files Components are open source. They are copyright © 1998-2014 by Peter Johnson. The source code is made available under the terms of the Mozilla Public License v2.0. All relevant trademarks are acknowledged.