listview中的文件拖到资源管理器,怎么获取当前资源管理器中文件夹的路径
listview中的文件拖到资源管理器,如何获取当前资源管理器中文件夹的路径?
listview中的文件拖到资源管理器,如何获取当前资源管理器中文件夹的路径?
------解决方案--------------------
listview中的文件拖到资源管理器,如何获取当前资源管理器中文件夹的路径?
------解决方案--------------------
- Delphi(Pascal) code
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,shellapi; type TForm1 = class(TForm) ListBox1: TListBox; ListBox2: TListBox; Button1: TButton; procedure FormCreate(Sender: TObject); private { Private declarations } public procedure DragFile(Var Msg : TMessage); Message WM_DropFILES; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.DragFile(var Msg: TMessage); var vFileCount : integer; i : integer; vFileName : string; vWidth : integer; begin vFileCount := DragQueryFile(Msg.WParam,$FFFFFFFF,nil,0); for i := 0 to vFileCount -1 do begin SetLength(vfilename,80); DragQueryFile(Msg.WParam,i,pchar(vFileName),80); ListBox1.Items.Append(vFileName); end; vWidth := 0; for i := 0 to ListBox1.Count -1 do begin if vWidth < ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i]) then vWidth := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i]); end; SendMessage(ListBox1.Handle,LB_SETHORIZONTALEXTENT,vWidth+50,0); DragFinish(Msg.WParam); end; procedure TForm1.FormCreate(Sender: TObject); begin ListBox1.ItemIndex := 0; DragAcceptFiles(ListBox1.Handle,true); end; end.