This unit provides two components that can handle files dragged and dropped from Windows Explorer:
TPJDropFiles provides a window which can accept files dragged and dropped from Windows Explorer. The window takes on the appearance of its parent window, although anything drawn on the parent's canvas is obliterated.
The control can contain child components (in a similar way to TPanel components). Files dropped over any such child component are accepted by the parent TPJDropFiles component. The TPJDropFiles component can be aligned with the form on which it is placed using the Align property.
When files are dropped over this component the OnBeforeDrop event is first triggered. The dropped files are then processed and dropped folders and optionally recursed. Once the files have been processed the OnDropFiles event is triggered. The names of the files are recorded in the Files property and the number of files is held in the Count property.
The point at which the files were dropped is given by the DropPoint property (in coordinates relative to the control). The DropControl property identifies any child control that was under the mouse cursor when the files were dropped.
The window containing the control can optionally be given the focus when files are dropped.
TPJFormDropFiles is a non-visual component that enables the form where it is dropped to accept files dragged and dropped from Explorer. Whenever files are dropped anywhere on the form's window, the OnDropFiles event is triggered.
As with TPJDropFiles the number and names of dropped files, the drop coordinates and any control under the mouse cursor can be found.
This component has been tested with Delphi 4, 6 and 7. It may work correctly in Delphi 2, 3 and 5 but this has not been tested.
Unlike version 1, this version does not work with 16 bit Delphi.
The help file provided with the components is not compatible with the Delphi 2 IDE but can be used separately.
Existing projects that use the earlier version of TPJDropFiles will need to use the PJDropFiles unit instead of DrpFiles in order to be recompiled.
In these instructions $(DELPHI)
is to be taken
to represent the path where the appropriate version of Delphi was installed.
For example, if you have Delphi 2 installed on the default installation path
then $(DELPHI)
is equivalent to
C:\Program Files\Borland\Delphi 2.0
.
Note that although the provided help file gives information about using the component it cannot be linked into the Delphi 2 environment.
pjdropfiles.zip
into a folder, preserving the
directory structure.PJDropFiles.pas
and PJDropFiles.dcr
to the folder from where you wish to install it into the Delphi Component
Palette. This will probably be an existing folder where you keep the library
components - say the default $(DELPHI)\lib
folder. PJDropFiles.pas
file in the folder where you placed it.
Click OK to recompile the components library.PJDropFiles.pas
from the place where you
copied it if you wish. The component will appear on a palette called DelphiDabbler
. You can move the component to a different palette as required..zip
into a folder of your choice, preserving
the directory structure. PJDropFiles.pas
and PJDropFiles.dcr
to where you wish to install into Delphi. This will probably be a sub-folder
of the $(DELPHI)\lib
folder. PJDropFiles.pas
from the file dialog and click
OK to return to the Install Component dialog box.PJDropFiles.pas
from the place where you
copied it if you wish (but ensure that the .dcu
file is not deleted).
The component will appear on a palette called DelphiDabbler. The
other code in the unit can be made available simply by use-ing
the unit in your projects. You can move the components to a different palette
as required.
PJDropFiles.hlp
to whichever folder you wish to
install it to.DelphiX.ohl
(in $(DELPHI)\Help
),
adding the line :Link PJDropFiles.hlp
to the end of
the section labelled "Third party help".DelphiX.ohi
(in $(DELPHI)\Help
),
adding the line :Index DelphiDabbler Drop Files=PJDropFiles.hlp
towards the end of the index section.DelphiX.cnt
(in $(DELPHI)\Help
),
ensuring that the lines :Include delphiX.ohi
and :Include
delphiX.ohl
appear somewhere in the file.D7.ohl
(in $(DELPHI)\Help
), adding
the line :Link PJDropFiles.hlp
to the end of the section
labelled "Third party help".D7.ohi
(in $(DELPHI)\Help
), adding
the line :Index DelphiDabbler Drop Files=PJDropFiles.hlp
towards the end of the index section.D7.cnt
(in $(DELPHI)\Help
), ensuring
that the lines :Include d7.ohi
and :Include d7.ohl
appear somewhere in the file.HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Help
and add a new string value named PJDropFiles.hlp
whose
value is the path where you copied the help file (probably
($DELPHI)\Help
).There was a bug in release 2.0 where length of strings containing names of dropped files was being set incorrectly. This was fixed from release 2.0.1.
Un-released
DrpFiles v1.0 of 15 May 1998
Un-released
DrpFiles v1.1 of 22 Oct 1998
Release 1.1.1 of 10 Jul 1999
DrpFiles v1.1.1 of 09 Jul 1999
Release 1.1.1a of 28 Nov 1999
DrpFiles v1.1.1 of 09 Apr 1999
Release 2.0 of 29 Apr 2001
PJDropFiles v2.0 of 29 Apr 2001
Release 2.0.1 of 13 May 2001
PJDropFiles v2.0.1 of 13 May 2001
Release 3.0 of 27 Oct 2002
PJDropFiles v3.0 of 27 Oct 2002
Release 3.1 of 29 Jul 2003
PJDropFiles v3.1 of 29 Jul 2003
This component is copyright © P.D.Johnson, 1998-2003.
The source code and help files can be freely distributed on a not-for-profit basis providing that:
By not-for-profit I mean that you may recover out of pocket expenses incurred in distributing the code, but should not make a profit from this.
If you discover any bugs in this implementation, or if you have any update suggestions, please contact me via my website.
Please do modify the code for you own use. I'd like to see any changes you make - I could incorporate them into future versions. Please notify me of changes on at the above e-mail address.
This software is provided as is - no warranty is given as to its suitability for any purposes to which you may wish to put it.
I'm Peter Johnson - a hobbyist programmer living in Ceredigion in West Wales, UK. I write mainly in Delphi. My programs are available for download on my web-site: http://www.delphidabbler.com/.
I can be contacted via the website.