delphi 我想实现一个功能,谁给个思路

来源:百度知道 编辑:UC知道 时间:2024/05/12 01:01:46
我想使用鼠标拖曳一个文件,到LISTVIEW中,在listview中显示它的文件名和路径,该怎么实现?

这可是为你定制开发,多给点分
//////////////////////////////////
首先,给你的Project加一个Unit,代码如下:
unit untDrag;

interface

//用来告诉Windows你的Form可以接受文件拖放
{$EXTERNALSYM DragAcceptFiles}procedure DragAcceptFiles(hWnd: Cardinal; fAccept: Boolean); stdcall;
//得到拖放文件名和文件个数的API
{$EXTERNALSYM DragQueryFile}
function DragQueryFile(hDrop: Cardinal; iFile: Cardinal; lpszFile: PChar; cch: Integer): Integer; stdcall;
//释放Windows分配给拖放操作的内存
{$EXTERNALSYM DragFinish}
procedure DragFinish(hDrop: Cardinal); stdcall;
//得到拖放的文件个数
function GetDragFileCount(hDrop: Cardinal): Integer;
//得到拖放的文件名,通过FileIndex来指定文件编号,默认为第一个文件
function GetDragFileName(hDrop: Cardinal; FileIndex: Integer = 1): string;

implementation

procedure DragAcceptFiles; external 'Shell32';

function DragQueryFile; external 'Shell32';
procedure DragFinish; external 'Shell32';

functio