Как перетащить на форму несколько файлов.

13:37
unit Unit1;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi;
 
type
TForm1 = class(TForm)
ListBox1: TListBox;
private
{ Private declarations }
procedure CreateParams(var Params: TCreateParams);override;
procedure WMDropFiles(Var Msg: TWMDropFiles); Message WM_DropFiles;
public
{ Public declarations }
end;
 
var
Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
{ TForm1 }
 
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.EXStyle or WS_EX_ACCEPTFILES;
end;
 
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
Var
FileName: Array[0..MAX_PATH] of Char;
i, Count: integer;
Begin
ListBox1.Items.clear;
Count := DragQueryFile(Msg.Drop, DWord(-1), FileName, SizeOf(FileName));
for i := 0 to count - 1 do
begin
DragQueryFile(Msg.Drop, i, FileName, SizeOf(FileName));
ListBox1.items.add(String(FileName));
end;
DragFinish(Msg.Drop);
end;
 
end.