Delphi 拖放文件编程(覆盖WM_DROPFILES消息)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Delphi 拖放文件编程(覆盖WM_DROPFILES消息)相关的知识,希望对你有一定的参考价值。
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
以上是关于Delphi 拖放文件编程(覆盖WM_DROPFILES消息)的主要内容,如果未能解决你的问题,请参考以下文章