Recent

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

loaded

  • Hero Member
  • *****
  • Posts: 824
[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 »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

RayoGlauco

  • Full Member
  • ***
  • Posts: 176
  • 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

  • Hero Member
  • *****
  • Posts: 824
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.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

loaded

  • Hero Member
  • *****
  • Posts: 824
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.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

TRon

  • Hero Member
  • *****
  • Posts: 2432
Re: How to transfer files with drag and drop.
« Reply #4 on: June 28, 2023, 09:53:05 pm »
The "Bidirectional Drag Drop File.rar" file is damaged.
No, it is not. Try to download again (the crc32 is $00d132a4) and/or updating your unrar or 7zip unpacker.

han

  • Jr. Member
  • **
  • Posts: 96
Re: [Solved] How to transfer files with drag and drop.
« Reply #5 on: June 28, 2023, 09:57:31 pm »
I got is fixed. My older Winrar could not handle it, but I managed to get it converted online to zip.

 

TinyPortal © 2005-2018