Scalabium Software

SMExport advertising
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
 
ExcelFile Viewer
Word Web-stream
Paradox Viewer
Clarion to Text converter
DBExport tools
Paradox Password Recovery
SMReport
ABA Document Convert
Database Information Manager
Viewer for TNEF-files (winmail.dat)
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMExport advertising