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

解决方案 »

  1.   

    unit Unit1;interfaceuses
    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.
    上周沒事做,寫的。你參考下
      

  2.   

    晕呀,楼上的弄反了,我要的是WINDOWS的路径
      

  3.   

    拖拽是基于OLE方式的
    A拖入B, A告知B拖入的内容或信息,B只是接收方只回应是否能接收,不提供具体的路径什么的信息
      

  4.   


      procedure TForm1.DropFiles(var Message: TMessage);
      var
          i:   Integer;
          p:   array[0..254]   of   Char;
      begin
          i   :=   DragQueryFile(Message.wParam,   $FFFFFFFF,   nil,   0);
          for   i   :=   0   to   i   -   1   do   begin
              DragQueryFile(Message.wParam,   i,   p,   255);
              ShowMessage(StrPas(p));
          end;
      end;
      

  5.   

    SonicX       有现成的代码吗?