Unit Unit1;
Interface
Uses
Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs,
Shellapi, Stdctrls;
Type
TForm1 = Class (Tform)
Memo1:tmemo;
Procedure Formcreate (Sender:tobject);
Private
{Private declarations}
Public
Procedure Wmdropfiles (var message:tmessage); message wm_dropfiles;
{Public declarations}
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Procedure Tform1. Wmdropfiles (var message:tmessage);
Respond to drag events, where the path to the file is placed in the memo control
Var
P:ARRAY[0..254] of Char;
I:word;
Begin
inherited;
Memo1.lines.clear;
I:=dragqueryfile (Message.wparam, $FFFFFFFF, nil,0);
Caption: =inttostr (i);
For i:=0 to I-1 do
Begin
Dragqueryfile (message.wparam,i,p,255);
Get file path
MEMO1.LINES.ADD (Strpas (p));
End
End
Procedure Tform1.formcreate (Sender:tobject);
Setting the drag handle
Begin
DragAcceptFiles (form1.handle,true);
End
End.
http://blog.csdn.net/diligentcatrich/article/details/6939654
Delphi drag-and-drop file programming (overwrite wm_dropfiles messages)