Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File drag & drop to a Delphi application

1,443 views
Skip to first unread message

Fedon Kadifeli

unread,
Aug 13, 2002, 3:32:34 AM8/13/02
to
What is the easiest way to drag and drop a file name from Windows
Explorer (=File Manager) into a Delphi 6 application? I have a
Notepad-like application developed in Delphi 6 and I want to open a file
by dragging that file from Windows Explorer and dropping it into my
application, just like you drag and drop a file into a running Notepad
instance to open that file in Notepad.

Nordine Benbachir

unread,
Aug 13, 2002, 3:50:10 AM8/13/02
to
o First you have to add this code in the create of your form ( if you use a
listview for example )
DragAcceptFiles( Listview1.Handle , true);

o Then add this new funtion to your form :
private
...
procedure DropMsg(var msg: TWMDropFiles); message WM_DROPFILES;
...
end;

procedure TForm1.DropMsg(var msg: TWMDropFiles);
var
FileNbr, i: Integer;
Files: array[0..255] of Char;
FileName : String;
begin
FileNbr:= DragQueryFile(Msg.Drop, $FFFFFFFF, Files, SizeOf(FileName));

for i:=0 to FileNbr-1 do
begin
FileName :=copy(Files, 0, DragQueryFile(Msg.Drop, i, Files, 255));
// Do something
end;

Msg.Result:=0;
DragFinish(msg.Drop);
end;


--
Nordine

"Fedon Kadifeli" <kadifeli@deletethis_yahoo.com> wrote in message
news:3D58B612.7080506@deletethis_yahoo.com...

Fedon Kadifeli

unread,
Aug 13, 2002, 4:21:51 AM8/13/02
to

Nordine Benbachir wrote:

> Hi,
>
>...
>
> --
> Nordine


Thank you very much...


Teo

unread,
Aug 13, 2002, 3:37:36 PM8/13/02
to
There are components available which do just that, written by Angus Johnson
and Anders Melander.

They are freeware with source, and you can find them at
http://www.melander.dk


"Fedon Kadifeli" <kadifeli@deletethis_yahoo.com> schreef in bericht
news:3D58B612.7080506@deletethis_yahoo.com...

NARS (no mail)

unread,
Aug 13, 2002, 6:03:11 PM8/13/02
to
How can I know on witch control the file was droped if I have multiple
controls acepting drag&drop?
Thanks


"Nordine Benbachir" <nordine....@cognit.no> escreveu na mensagem
news:3d58ba32$1@dnews...
> Hi,

Nordine Benbachir

unread,
Aug 14, 2002, 5:47:43 AM8/14/02
to
The file is droped on the control that launches this event

procedure DropMsg(var msg: TWMDropFiles); message WM_DROPFILES

--
Nordine.

"NARS (no mail)" <na...@nospam.pt> wrote in message news:3d59a9cc@dnews...

Bruce Christensen

unread,
Aug 14, 2002, 7:59:35 AM8/14/02
to
Thanx Nording, I found your example helpful as well!

Bruce

"Nordine Benbachir" <nordine....@cognit.no> wrote in message
news:3d5a273f$1@dnews...

0 new messages