Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#58: How can I accept the dropped files from Windows Explorer?

If you need accept the dropped files from the some external application (for example, from Windows Explorer), you must call the DragAcceptFiles for your form (in which you want to accept) and handle the WM_DROPFILES message.

I used this algoritm when I wrote the small editor.

I post the next code as simple example:

type 
  TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
  protected
    procedure WMDROPFILES (var Msg: TWMDropFiles); message WM_DROPFILES;
  private
  public
  end;

var
  Form1: TForm1;

implementation
uses ShellApi;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  DragAcceptFiles(Handle, True);
end;

procedure TForm1.WMDROPFILES(var Msg: TWMDropFiles);
var
  i, amount: Integer;
  FileName: array[0..MAX_PATH] of Char;
begin
  inherited;

  try
    Amount := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, MAX_PATH);
    for i := 0 to (Amount - 1) do
    begin
      DragQueryFile(Msg.Drop, i, FileName, MAX_PATH);
      listbox1.items.add(FileName);
    end;
  finally
    DragFinish(Msg.Drop);
  end;
end;


Published: January 11, 2000

See also
 
DBExport tools
SMImport suite
DBISAM Password Recovery
Mail parser (ActiveX)
Viewer for TNEF-files (winmail.dat)
Viewer for MS Outlook Messages
SMExport suite
SMReport
Excel Reader (dll)
dBase Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2025, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising