Scalabium Software

SMReport Autogenerated
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
 
dBase Viewer
SMExport suite
ABA Spreadsheet Convert
Database Information Manager
ABA Picture Convert
Fast Document Viewer
ABA Document Convert
Protected Storage Viewer
SMMsg suite
Excel Reader (dll)
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMExport advertising