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); //响应拖动事件,讲文件的路径放置到Memo控件中 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); //取得文件路径 memo1.lines.Add(strpas(p)); end; end;
procedure TForm1.FormCreate(Sender: TObject); //设定拖动句柄 begin dragacceptfiles(form1.handle,true); end;
end.
http://blog.csdn.net/diligentcatrich/article/details/6939654
|
请发表评论