Scalabium Software |
|
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;
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |