Как перетащить файл на форму (Delphi)

Вот как перетащить файл на форму:

uses ShellApi;

...

  public
procedure wmdropfiles(var message: tmessage); message wm_dropfiles;
end;
...

procedure TForm1.FormCreate(Sender: TObject);
begin
// Разрешаем перетаскивание
DragAcceptFiles(Handle, true);
end;
...

procedure TForm1.wmdropfiles(var message: tmessage);
var
hdrop:thandle;
i,c:longword;
s:string;
begin
hdrop:=message.wparam;
c:=dragqueryfile(hdrop,longword(-1),pchar(nil),0);
for i:=0 to c-1 do
begin
setlength(s,dragqueryfile(hdrop,i,pchar(nil),0));
dragqueryfile(hdrop,i,pchar(s),length(s)+1);
ShowMessage(s);
end;
dragfinish(hdrop);
end;

google.com bobrdobr.ru del.icio.us technorati.com linkstore.ru news2.ru rumarkz.ru memori.ru moemesto.ru

Leave a Reply