Forum > LCL

[Solved] How to transfer files with drag and drop.

(1/1)

loaded:
Hi Dear Friends,
With the help of the code below;
I get the file path into the listbox by drag and drop the file on the desktop.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String);var  i:integer;begin    ListBox1.Clear;    for i:=0 to Length(FileNames)-1 do    begin      listbox1.Items.Add(FileNames[i]);    end;end; procedure TForm1.FormCreate(Sender: TObject);begin  AllowDropFiles:=true;end;
Now I want to do the opposite. Well ;
From the file path information, how can I transfer the file to a folder with drag and drop.
I would be grateful if you help. Respects.

RayoGlauco:
Hello, Loaded,

You can check this link: https://wiki.lazarus.freepascal.org/Drag_and_Drop_sample

I found this code example, for a tEdit:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer);begin  if Button = mbLeft then   {check if left mouse button was pressed}    Edit1.BeginDrag(true);  {starting the drag operation}end;

loaded:
Hello RayoGlauco, thank you very much for your reply.
I tried but unfortunately it didn't work. Apparently there are other things I need to learn.

loaded:
As a result of my research;
https://www.swissdelphicenter.ch/en/showcode.php?id=2335
https://forum.lazarus.freepascal.org/index.php?topic=42233.0

I created an example that can work double-sided with small touches.
Thanks to the guys in the link.

Let's put it here, maybe it will be useful to others one day.

Navigation

[0] Message Index

Go to full version