首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

listview中的文件拖到资源管理器,怎么获取当前资源管理器中文件夹的路径

2012-09-27 
listview中的文件拖到资源管理器,如何获取当前资源管理器中文件夹的路径?listview中的文件拖到资源管理器,

listview中的文件拖到资源管理器,如何获取当前资源管理器中文件夹的路径?
listview中的文件拖到资源管理器,如何获取当前资源管理器中文件夹的路径?

[解决办法]

Delphi(Pascal) code
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls,shellapi;typeTForm1 = 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;varForm1: TForm1;implementation{$R *.dfm}procedure TForm1.DragFile(var Msg: TMessage);varvFileCount : integer;i : integer;vFileName : string;vWidth : integer;beginvFileCount := DragQueryFile(Msg.WParam,$FFFFFFFF,nil,0);for i := 0 to vFileCount -1 dobegin    SetLength(vfilename,80);    DragQueryFile(Msg.WParam,i,pchar(vFileName),80);    ListBox1.Items.Append(vFileName);end;vWidth := 0;for i := 0 to ListBox1.Count -1 dobegin    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);beginListBox1.ItemIndex := 0;DragAcceptFiles(ListBox1.Handle,true);end;end. 

热点排行