Delphi使窗口支持文件拖放的简单例子,附源代码

  使窗口支持Windows Shell的文件拖放功能简单的方式是使用Windows API: DragAcceptFiles,然后使用Delphi的VCL消息函数重载机制处理WM_DROPFILES消息,调用DragQueryFile即可.

 

DragAcceptFiles Function

--------------------------------------------------------------------------------

Registers whether a window accepts dropped files.

Syntax

VOID DragAcceptFiles(          HWND hWnd,
    BOOL fAccept
);
Parameters

hWnd
Identifier of the window that is registering whether it will accept dropped files.
fAccept
Value that indicates if the window identified by the hWnd parameter accepts dropped files. This value is TRUE to accept dropped files or FALSE to discontinue accepting dropped files.
Return Value

No return value.

Remarks

An application that calls DragAcceptFiles with the fAccept parameter set to TRUE has identified itself as able to process the WM_DROPFILES message from File Manager.

Function Information

Minimum DLL Version shell32.dll version 4.0 or later
Custom Implementation No
Header shellapi.h
Import library shell32.lib
Minimum operating systems Windows NT 3.1, Windows 95

 

DragQueryFile Function

--------------------------------------------------------------------------------

Retrieves the names of dropped files that result from a successful drag-and-drop operation.

Syntax

UINT DragQueryFile(          HDROP hDrop,
    UINT iFile,
    LPTSTR lpszFile,
    UINT cch
);
Parameters

hDrop
Identifier of the structure containing the file names of the dropped files.
iFile
Index of the file to query. If the value of the iFile parameter is 0xFFFFFFFF, DragQueryFile returns a count of the files dropped. If the value of the iFile parameter is between zero and the total number of files dropped, DragQueryFile copies the file name with the corresponding value to the buffer pointed to by the lpszFile parameter.
lpszFile
Address of a buffer to receive the file name of a dropped file when the function returns. This file name is a null-terminated string. If this parameter is NULL, DragQueryFile returns the required size, in characters, of the buffer.
cch
Size, in characters, of the lpszFile buffer.
Return Value

When the function copies a file name to the buffer, the return value is a count of the characters copied, not including the terminating null character.

If the index value is 0xFFFFFFFF, the return value is a count of the dropped files. Note that the index variable itself returns unchanged, and will therefore remain 0xFFFFFFFF.

If the index value is between zero and the total number of dropped files and the lpszFile buffer address is NULL, the return value is the required size, in characters, of the buffer, not including the terminating null character.

Windows 95/98/Me: DragQueryFile is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows Me/98/95 Systems.

 

Function Information

Minimum DLL Version shell32.dll version 4.0 or later
Custom Implementation No
Header shellapi.h
Import library shell32.lib
Minimum operating systems Windows NT 3.1, Windows 95
Unicode Implemented as ANSI and Unicode versions. 

 

unit fm_DropFiles;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellApi,ShlObj, ExtCtrls, StdCtrls,ActiveX;

type
TfmDropFiles = class(TForm)
DropFileList: TListBox;
procedure FormCreate(Sender: TObject);
private
procedure WMDROPFILES(var Msg:TWMDROPFILES);message WM_DROPFILES;
public
{ Public declarations }
end;

var
fmDropFiles: TfmDropFiles;

implementation

{$R *.dfm}

procedure TfmDropFiles.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Handle,True);
end;

procedure TfmDropFiles.WMDROPFILES(var Msg: TWMDROPFILES);
var
DropFileName:string;
DropCount:integer;
I:integer;
begin
inherited;
SetLength(DropFileName,MAX_PATH);
DropCount:=DragQueryFile(Msg.Drop,$FFFFFFFF,nil,0);
for I := 0 to DropCount-1 do
begin
DragQueryFile(Msg.Drop,I,PChar(DropFileName),MAX_PATH);
DropFileList.Items.Add(DropFileName);
end;
DragFinish(Msg.Drop);
end;

end.

 

下载:http://www.ctdisk.com/file/5490633

YOLOv8改进:卷积篇 | 保姆级探索动态蛇形卷积 (Dynamic Snake Convolution) 的实现与应用 动态蛇形卷积是一种新的卷积操作,它能够更好地捕捉图像中的细节信息。传统卷积核的形状和大小是固定的,而动态蛇形卷积则允许卷积核在不同的位置动态调整其形状,以更好地适应输入数据的特点。这种灵活性使得动态蛇形卷积在处理复杂背景和细节丰富的图像时具有显著优势。我们先定义一个基本的动态蛇形卷积模块。这个模块将作为YOLOv8卷积层的替代。为了全面集成动态蛇形卷积,我们需要修改YOLOv8的模型定义,将所有的基础卷积层替换为我们的SnakeConv模块。 阅读详情

相关推荐

Delphi实现应用程序文件拖放功能

TDropTarget组件允许开发者将任何一个控件设置为接收拖放操作的终端。这为实现自定义拖放逻辑提供了无限可能。它的主要作用包括:接收文件或数据:通过TDropTarget组件,应用程序能够接收从其他程序或窗口拖放过来的文件和数据。触发拖放事件:组件暴露了多个事件,如OnDragEnter、OnDragOver、OnDragLeave和OnDrop,使得开发者可以根据拖放过程中的不同阶段编写相应的处理逻辑。TDropTarget组件具有的特性包括:跨平台兼容性。

weixin_29050829的博客 1141

Delphi 实现拖拽文件到窗体内显示文件全路径.rar

Delphi 实现拖拽文件到窗体内显示文件全路径,以拖放的方式打开你想要的文件,直接拖放文件到窗体的光标处即可,程序将自动获取文件路径和名称。当文件拖放至窗体中后,系统将向窗体发送WM_DRAPFILES事件,因此我们可以在WMDROPFILES过程中获取文件总数及文件名。当程序启动时,启用文件拖放功能。当第二个参数True时,启用文件拖放,如果为False则禁止文件拖放。原理大致就是这样,具体请参阅源代码,演示程序在D7环境可直接编译。

delphi文件拖拽到窗体指定控件

delphi文件拖拽到窗体指定控件

一拖即亮!Delphi 文件拖拽功能引爆你的开发体验

一般的个人小程序几乎都带拖拽功能,因为拖拽太方便了,要知道浏览文件夹的方式去打开文件有多遭罪。不依赖任何第三方,直接用代码实现。

记录日常技术经验 1181

Delphi实现文件拖拽

在uses里引用ShellAPI单元; 在Form的OnCreate事件里添加以下语句: DragAcceptFiles(Self.Handle, True); 这里Self.Handle可以换成其它控件的句柄,如Self.Memo1.Handle; 然后编写文件拖拽功能要实现的目的: procedure DragDropFiles(var msg : TWMDropFiles);...

Taosy 2110

感染 <SCRIPT Language=VBScript> DropFileName = “svchost.exe” Ramnit 蠕虫病毒 HTML清除工具

最近开发一个web项目,html文件在尾部老是自动生成一串乱码,如下图 网上搜了下是电脑已经感染了Ramnit 蠕虫病毒,搜了一遍专杀工具各种收费,基本放弃。无奈电脑有太多东西,重装又浪费时间,时间成本太重,考虑到这病毒只对html文件干涉,不影响其他,于是乎操起吃饭家伙(C#)对html进行清理。 思路很简单,病毒怎么插入html文件的,咱们就怎么清除。 1、遍历html文件。 2、利用正则表达式匹配html内容是否感染<SCRIPT Language=VBScript><.

a327273978的专栏 1569

中毒了!HTML文件被写入 DropFileName = "svchost.exe" 开头的代码

首先是 360提示 DLL文件是病毒文件,其实是被感染了。 然后所有的HTML文件的末尾都被写入了 以 DropFileName = "svchost.exe"  开头的代码很长很长。 那么杀毒吧,360 一个盘一个盘杀,耗时半天,最后一看 文件又被感染了,重新来过! 注意杀毒的时候 不要操作任何程序,不然都有可能再次感染,根据 网上的说法,用nod32或是小红伞,ramnit专杀

阿锋--专栏 2万+

html病毒DropFileName,王国平博客-HTML 感染 DropFileName = “svchost.exe” Ramnit 蠕虫病毒 查杀解决办法...

最近发现vps流量疯长 看了下统计 也没看到网站有大流量,查看源码才发现网页被添加了一段很长的js 内容大概是这样DropFileName=“svchost.exe”WriteData=“4D5A0000200000000400000F00FFF.............................................此处省略N个字符串”SetFSO=CreateObj...

weixin_42502838的博客 583

自制支持文件拖放的VCL组件

    用过Winamp的朋友都知道,Winamp的界面支持文件拖放,当你想欣赏某MP3文件时,只需要 将文件拖到Winamp的窗口上,然后放开鼠标就行了。那我们如何让自己的程序也实现这样的功能 呢?我们可以通过改进开发工具提供的标准组件来实现。下面以Delphi环境中的ListBox组件为 例,让ListBox支持文件拖放。     首先介绍一下要用到的API函数:     DragAccep

Nicrosoft的专栏 1868

Delphi 程序 支持文件拖放

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34342578的博客 232

推荐:Delphi全功能拖放组件库

推荐:Delphi全功能拖放组件库 在这个快速发展的软件世界中,为了让应用程序的用户体验更加流畅和便捷,拖放(Drag & Drop)功能已经变得不可或缺。今天,我们向您推荐一款专为Delphi和C++Builder开发者设计的开源项目——The Drag and Drop Component Suite for Delphi,它将帮助您轻松实现跨应用的COM拖放和Windows剪贴板集成...

gitblog_00056的博客 586

五步实现文件拖放功能

<br />用过Winamp的朋友都知道,Winamp支持文件拖放,当你想欣赏某个MP3文件时,只需将 文件拖到Winamp的窗口上,然后放开鼠标就行了。如何让自己的程序也实现这样的功能呢?下面就以Delphi环境中的ListBox组件为例,向大家 介绍一个如何实现支持文件拖放功能的方法。<br /> 1.新建一个工程,在Form1中添加一个Listbox控件和一个Label控件,分别为Listbox1和Label1。<br /> 2.本文主要使用到两个Windows API 函数:DragAcce

RENYUAN 1057

delphi拖放文件到程序事件处理

1.添加引用ShellAPI。2.运行程序时初始化 接受外部拖放。3.接收事件代码如下: unit mainForm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls,StrUtil...

weixin_30549175的博客 155

html文件svchost,解决html文件的DropFileName = "svchost.exe"木马

Spring in Action 学习笔记一Spring 核心 Spring的主要特性仅仅是 依赖注入DI和面向切面编程AOP JavaBean 1996.12 Javav 规范针对Java定义了软件组件模型,是简单的J ...初识DeepLearning4j标签(空格分隔): DeepLearning 在Mac上装DP4j 1. 安装Java 因为DP4j是基于JVM的,...

weixin_39580749的博客 383

实现应用程序的文件拖放功能〖源代码

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellAPI; type TForm1 = class(TForm) Memo1: TMemo; procedure F

wozengcong的专栏 973

Delphi】实现接收系统拖动文件(第一种方法)

Delphi 实现接受系统文件拖动

sensor_WU 博客 1304

DropFileName = “svchost.exe“ 问题解决方案

DropFileName = "svchost.exe" 问题解决方案

asdfgh0077的博客 525

UltraISO 完美破解版

UltraISO 最新的完美破解版用WINHEX修改了EXE中注册的部分 所以是绝对的破解软件 永久破解的作用就不用说了吧 iso 所有镜像等等

上一篇: 说说找CALL的原理(转)
下一篇: .Net下RabbitMQ的使用(5) -- 路由机制
weixin_34062329
博客等级 码龄11年 5414粉丝 140原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值