The Study

home |  about

Programming

Introduction

Delphi

Java

Projects

Graphics

Introduction

POV-Ray

Terragen

Music

Introduction

Work in Progress

Oddments

Library

Miscellaneous

How to accept dragged and dropped files from Windows Explorer

Back to How to index

{ WMDropFiles declaration: }
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;

{ WMDropFiles code: }
procedure TMainFrm.WMDropFiles(var Msg: TWMDropFiles);
var
  i, Count: integer;
  FileName: array [0..MAX_PATH] of char;
begin
  { How many files? }
  Count := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, MAX_PATH);
  { For each file, retrieve the filename }
  for i := 0 to Count - 1 do
  begin
    DragQueryFile(Msg.Drop, i, FileName, MAX_PATH );
    { Do something with FileName }
    { ... }
  end;
  { Let Windows know that we're finished }
  DragFinish( Msg.Drop );
end;