Recent

Author Topic: [Solved] How to transfer files with drag and drop.  (Read 1620 times)

loaded

  • Sr. Member
  • ****
  • Posts: 382
[Solved] How to transfer files with drag and drop.
« on: October 26, 2021, 01:20:32 pm »
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  [Select][+][-]
  1. procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String);
  2. var
  3.   i:integer;
  4. begin
  5.     ListBox1.Clear;
  6.     for i:=0 to Length(FileNames)-1 do
  7.     begin
  8.       listbox1.Items.Add(FileNames[i]);
  9.     end;
  10. end;
  11.  
  12. procedure TForm1.FormCreate(Sender: TObject);
  13. begin
  14.   AllowDropFiles:=true;
  15. 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.
« Last Edit: October 27, 2021, 06:08:47 pm by loaded »
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

RayoGlauco

  • Full Member
  • ***
  • Posts: 114
  • Beers: 1567
Re: How to transfer files with drag and drop.
« Reply #1 on: October 26, 2021, 01:26:57 pm »
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  [Select][+][-]
  1. procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   if Button = mbLeft then   {check if left mouse button was pressed}
  5.     Edit1.BeginDrag(true);  {starting the drag operation}
  6. end;
To err is human, but to really mess things up, you need a computer.

loaded

  • Sr. Member
  • ****
  • Posts: 382
Re: How to transfer files with drag and drop.
« Reply #2 on: October 26, 2021, 03:31:31 pm »
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.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

loaded

  • Sr. Member
  • ****
  • Posts: 382
Re: How to transfer files with drag and drop.
« Reply #3 on: October 27, 2021, 06:08:33 pm »
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.
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

 

TinyPortal © 2005-2018