码迷,mamicode.com
首页 > Windows程序 > 详细

Delphi 拖放文件编程(覆盖WM_DROPFILES消息)

时间:2016-02-25 19:39:51      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

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消息)

标签:

原文地址:http://www.cnblogs.com/findumars/p/5218033.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!