1 (edited by eyeman303 2022-01-09 11:44:10)

Topic: Drag file to Form field

Hello!
Is it possible to drag a file from Windows explorer, directly to a field in a form, which is of type StoreFile?
Regards,
Eyeman

Post's attachments

Attachment icon image_2022-01-09_171227.png 45.67 kb, 74 downloads since 2022-01-09 

Re: Drag file to Form field

Hi,
For one file.
The file is being written to database but I haven't tested it completely! (Wrong work if Type is LinkFolder. )
1.Create an OnDropFiles event for DBFile.
2.To the OnDropFiles event in the script:

procedure Form1_DBFile1_OnDropFiles (Sender: TObject; ArrayOfFiles: array of string; X, Y: Integer);
begin
        Form1.DBFile1.dbFileName := (ArrayOfFiles[0]);
        Form1.DBFile1.text := ExtractFileName((ArrayOfFiles[0]));
end;

Re: Drag file to Form field

Hi Sparrow,
Thank you. The solution works perfectly. Just want to know what does (ArrayOfFiles[0]) signify? What modification needs to be done if file type is LinkFile?
Regards,
Eyeman

4 (edited by sparrow 2022-01-10 18:42:37)

Re: Drag file to Form field

Hi Eyeman,
No additional modifications for LinkFile. Everything works, except LinkFolder.
Rather, LinkFolder works))) but with its own characteristics. Some inconveniences and additional code modifications.


(ArrayOfFiles[0]) - element "0" from the array of filenames that are passed to the OnDropFiles event. The array can contain N elements and the numbering of the elements starts from "0". "ArrayOfFiles" is just the name of an array for convenience.

Re: Drag file to Form field

Hi Sparrow,
Thanks for making the concept clear to me. I think the ability to drag a file into a document field will be a very useful option, in many of my projects.
Regards,
Eyeman