Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
Drag and Drop filesEdit
First, make sure to add ShellAPI to your uses clause, then use the DragAcceptFiles function in the OnCreate event for the form that will accept them. This will tell Windows to send WM_DROPFILES messages to the application that is registered to accept dropped files, for example:
procedure TForm1.FormCreate(Sender: TObject); begin DragAcceptFiles(Handle, True); end;
Then create a procedure that process the WM_DROPFILES message
procedure DropFiles(var msg: TMessage ); message WM_DROPFILES;
procedure TForm1.DropFiles(var msg: TMessage ); var i, count : integer; dropFileName : array [0..511] of Char; MAXFILENAME: integer; begin MAXFILENAME := 511; // we check the query for amount of files received count := DragQueryFile(msg.WParam, $FFFFFFFF, dropFileName, MAXFILENAME); // we process them all for i := 0 to count - 1 do begin DragQueryFile(msg.WParam, i, dropFileName, MAXFILENAME); // dropFileName now has the current filename of dropped object. // ** // do something :D // ** end; // release memory used DragFinish(msg.WParam); end;
|Databases • Files and I/O • Forms/Windows • Graphics • Networking • Math and Algorithms • Miscellaneous • Multimedia • System • VCL|