View Single Post
Old 18th February 2005, 02:06   #14  |  Link
esby
Registered User
 
esby's Avatar
 
Join Date: Oct 2001
Location: france
Posts: 521
no need for a component for drag & drop in delphi
Code:
uses 
// snip
shellApi; // [edit] shell api might not be necessary, but you might want to check out the shellExec() and shellExecEx() functions...

type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
  private
// snip
  public
// snip
     procedure WMDROPFILES(var Message: TWMDROPFILES);  message WM_DROPFILES;
  end;


implementation

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

procedure TForm1.WMDROPFILES(var Message: TWMDROPFILES);
var
  NumFiles : longint;
  i : longint;
  buffer : array[0..255] of char;
begin
 {How many files are being dropped}
  NumFiles := DragQueryFile(Message.Drop,
                            $FFFFFFFF,
                            nil,
                            0);
 {Accept the dropped files}
//  OpenDialog1.Files.Clear; // optional
  for i := 0 to (NumFiles-1 ) do begin
    DragQueryFile(Message.Drop,
                  i,
                  @buffer,
                  sizeof(buffer));
                  OpenDialog1.Files.Add(buffer);
  end;
esby
__________________
http://esby.free.fr/

Last edited by esby; 18th February 2005 at 02:28.
esby is offline   Reply With Quote