Formra fájl húzása

Top  Previous  Next

Egy Memo1 komponenst tegyél a formra

 

uses ShellApi

...

private

procedure WMDROPFILES(var Message: TWMDROPFILES);

message WM_DROPFILES;

{ Private declarations }

...

procedure TForm1.WMDROPFILES(var Message: TWMDROPFILES);

var

NumFiles : longint;

i : longint;

buffer : array[0..255] of char;

begin

{How many files are being dropped}

NumFiles := DragQueryFile(Message.Drop,

-1,

nil,

0);

{Accept the dropped files}

for i := 0 to (NumFiles - 1) do begin

DragQueryFile(Message.Drop,

i,

@buffer,

sizeof(buffer));

Form1.Memo1.Lines.Add(buffer);

end;

end;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

DragAcceptFiles(Form1.Handle, True);

end;