转存:常用正则表达式
2016-01-29 09:13
274 查看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
procedure AppOnMessage(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ShellAPI;
{$R *.dfm}
procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
var
WMD: TWMDropFiles;
begin
if Msg.message = WM_DROPFILES then
begin
WMD.Msg := Msg.message;
WMD.Drop := Msg.wParam;
WMD.Unused := Msg.lParam;
WMD.Result := 0;
WMDropFiles(WMD);
Handled := TRUE;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(listview1.Handle, True);
Application.OnMessage := AppOnMessage;
end;
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
var
N: Word;
buffer: array[0..180] of Char;
item: TListItem;
begin
with Msg do
begin
for N := 0 to DragQueryFile(Drop, $FFFFFFFF, buffer, 1) - 1 do
begin
DragQueryFile(Drop, N, Buffer, 80);
Item := ListView1.Items.Add;
item.Caption := StrPas(Buffer);
end;
DragFinish(Drop);
end;
end;
end.
1.引用 ShellAPI单元
2.定义AppOnMessage,拦截处理拖拽文件操作
3.设置接收拖拽文件的对象。DragAcceptFiles(listview1.Handle, True);
4.定义对拖拽文件的具体操作WMDropFiles(var Msg: TWMDropFiles);
示例下载见附件
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
procedure AppOnMessage(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ShellAPI;
{$R *.dfm}
procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
var
WMD: TWMDropFiles;
begin
if Msg.message = WM_DROPFILES then
begin
WMD.Msg := Msg.message;
WMD.Drop := Msg.wParam;
WMD.Unused := Msg.lParam;
WMD.Result := 0;
WMDropFiles(WMD);
Handled := TRUE;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(listview1.Handle, True);
Application.OnMessage := AppOnMessage;
end;
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
var
N: Word;
buffer: array[0..180] of Char;
item: TListItem;
begin
with Msg do
begin
for N := 0 to DragQueryFile(Drop, $FFFFFFFF, buffer, 1) - 1 do
begin
DragQueryFile(Drop, N, Buffer, 80);
Item := ListView1.Items.Add;
item.Caption := StrPas(Buffer);
end;
DragFinish(Drop);
end;
end;
end.
1.引用 ShellAPI单元
2.定义AppOnMessage,拦截处理拖拽文件操作
3.设置接收拖拽文件的对象。DragAcceptFiles(listview1.Handle, True);
4.定义对拖拽文件的具体操作WMDropFiles(var Msg: TWMDropFiles);
示例下载见附件
相关文章推荐
- java字符串与二进制的相互转化
- 我不知道的C++
- Android定位&地图&导航——基于百度地图移动获取位置和自动定位
- h5 动画页面
- hdoj2803The MAX
- 计算机是如何启动的?
- python读网页解析内容写入文件
- P1.2k160118
- 『转』『译』三种东西永远不要放到数据库里
- Android自动化测试之MonkeyRunner录制和回放脚本
- Chrome 35个开发者工具的小技巧
- 程序员会不会英语的差别
- Android营造雪花和雨滴浪漫效果
- NSUserDefaults
- 自动化测试 笔记
- angular
- git将已经同步的某类文件加入忽略列表并同步
- hdu 2155(dp)
- Swift "..."".."及"==""==="区别
- C++文件读写详解(ofstream,ifstream,fstream)