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消息)的更多相关文章
- 让自己的软件实现拖拽打开文件(使用WM_DROPFILES消息和DragQueryFile函数)
//声明 protected procedure WMDROPFILES(var Msg : TMessage); message WM_DROPFILES; //实现 procedure TForm ...
- 让自己的软件实现拖拽打开文件(覆盖WM_DROPFILES,使用DragQueryFile,DragFinish API函数)
作者: 帅宏军 //声明 protected procedure WMDROPFILES(var Msg : TMessage); message WM_DROPFILES; --------- ...
- 解决在 win10 下 vs2017 中创建 MFC 程序拖放文件接收不到 WM_DROPFILES 消息问题
解决方案 这个问题是由于 win10 的安全机制搞的鬼,即使以管理员权限运行也不行,因为它会把 WM_DROPFILES 消息过滤掉,那怎么办呢?只需在窗口初始化 OnInitDialog() 里添加 ...
- 深入delphi编程理解之消息(一)WINDOWS原生窗口编写及消息处理过程
通过以sdk方式编制windows窗口程序,对理解windows消息驱动机制和delphi消息编程有很大的帮助. sdk编制windows窗口程序的步骤: 1.对TWndClass对象进行赋值; 2. ...
- 解决Win7下UAC开启时无法响应WM_DROPFILES消息
//以管理员身份运行,程序窗口就可以接收到拖放文件消息[WM_DROPFILES]了. ChangeWndMessageFilterOk(WM_DROPFILES, MSGFLT_ADD); Chan ...
- win32使用拖放文件
于win32规划,使用拖放文件操作,非经常见(不否认有些人喜欢用button打开) 中使用拖拽,非常easy,仅仅须要在创建窗体的时候使用WS_EX_ACCEPTFILES标识符,然后使用一个消息函数 ...
- WPF + Winform 解决管理员权限下无法拖放文件的问题
wpf,winform混合解决管理员权限无法拖放文件的问题 学习自: https://zhuanlan.zhihu.com/p/343369663 https://zhuanlan.zhihu.com ...
- Delphi的文件操作
参考自:http://www.cnblogs.com/railgunman/articles/1800318.html Delphi 中默认有input 和 output 两个文件变量,使用可以不用定 ...
- delphi 资源文件详解
delphi资源文件详解 一.引子: 现在的Windows应用程序几乎都使用图标.图片.光标.声音等,我们称它们为资源(Resource).最简单的使用资源的办法是把这些资源的源文件打入软件包,以方便 ...
随机推荐
- PIGS(最大流)
PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18742 Accepted: 8511 Description ...
- windows 下一个mysql password忘记改变
到场mysql简介 my.ini 于[mysqld]以下被加入 skip-grant-tables win+R 热键 进cmd 然后输入命令net stop mysql 最后一点,使文件夹mysql ...
- Codeforces Round #246 (Div. 2)
题目链接:Codeforces Round #246 (Div. 2) A:直接找满足的人数,然后整除3就是答案 B:开一个vis数组记录每一个衣服的主场和客场出现次数.然后输出的时候主场数量加上反复 ...
- Python 中的list小结
list的下标和子list list的下表从零开始,和C语言挺类似的,但是增加了负下标的使用. -len-----第一个元素 ...... ...... -2 ------ 倒数第二个元素 ...
- MVC action返回partialView前台html 拼接
//后台 [HttpPost] public ActionResult GetNextLazyLoadProduct(int[] productIdList) { ...
- linq中的group by
现有如下需求,要求统计int数组中每个整数的个数: ,,,,,,,,,,,, }; var linq = from item in arrInt group item by item into g// ...
- django1.6读书笔记一
reporter是Article中的一个外键,我们可以有多篇文章指向同一个reporter,然后通过使用article_set.all()就可以返回其所有的headline了,也可以添加条件来筛选. ...
- Delphi启动/停止Windows服务,启动类型修改为"自动"
unit U_StartServices; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Contr ...
- redis(三)redis+Keepalived主从热备秒级切换
一 简介 安装使用centos 5.10 Master 192.168.235.135 Slave 192.168.235.152 Vip 192.168.235.200 编译环境 yum -y in ...
- 最简单也最难——如何获取到Android控件的高度
问题 如何获取一个控件的长和高,相信很多朋友第一眼看见这个问题都会觉得很简单,直接在onCreate里面调用getWidth.getMeasuredWidth不就可以获得了吗,但是,事实上是并没有简单 ...