Avatar of kapot
kapot

asked on 

Drag and drop filenames

Hi,

Anyone can show some codes to receive drag and drop files to a TListBox ?

What I need is to drag and drop some files from Windows Explorer to a TListBox.
The TListBox will receive them and populate the filenames.

Thanks.
Delphi

Avatar of undefined
Last Comment
Lukasz Zielinski
Avatar of MerijnB
MerijnB
Flag of Netherlands image

Avatar of kapot
kapot

ASKER

Hi ziolko,

Your solution is interesting, but how do I know that THE TListBox receive the drop???

Because if I see, the WMDropfiles is a global procedure.

There could be several objects that could receive file drops.

procedure TForm1.WMDropfiles(var Msg: TWMDropFiles);
var Amount: Integer;
    filename: array[0..MAX_PATH] of Char;
    cnt: Integer;
begin
  inherited;
  try
    Amount := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, MAX_PATH);
    for cnt := 0 to Amount - 1 do
    begin
      DragQueryFile(Msg.Drop, cnt, FileName, MAX_PATH);
      Memo1.Lines.Add(FileName);
    end;
  finally
    DragFinish(Msg.Drop);
  end;
end;
give me a minute or two:)

ziolko.
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Delphi
Delphi

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.

60K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo