Newsgroups : Alt : alt.internet.search-engines : 2006 Sep : Drag and drop from Explorer to ListView

www.cryer.info
Managed Newsgroup Archive

Drag and drop from Explorer to ListView

Subject:Drag and drop from Explorer to ListView
Posted by:"Brad Blanchard" (11..@1122noexiste.net)
Date:Sun, 24 Sep 2006 12:08:32

I've tried about a dozen variations on the procedure below and can't
get it to work. I have the ListView (vsList) set to dkDrag and dmManual
and it seems to be working since the drag icons appear and change as
they should do. If in FormCreate I put:

DragAcceptFiles(ListView1.Handle , true);

I never see the Showmessage text, but with:

DragAcceptFiles(Handle , true);

I see the Showmessage text, but nothing is added to the ListView. What
am I missing?

procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
Var
  fname : string;
  I :Integer;
  LI : TListItem;
begin
  I := DragQueryFile( Msg.Drop, 0, PChar(fname), Length(fname) );
  SetLength( fname, I );
  try
    DragQueryFile(Msg.Drop, I, PCHAR(FName), MAX_PATH);
    LI := TListItem.Create(ListView1.Items);
    showmessage('DropFiles1'); //test
    with LI do
    begin
      LI.Caption := FName;
      ListView1.Items.Add;
      showmessage('DropFiles2');//test
    end;
  finally
    DragFinish(Msg.Drop);
  end;
end;

--
Brad Blanchard
Website http://www.braser.com/

Replies:

www.cryer.info
Managed Newsgroup Archive