Recent

Author Topic: multiple drag and drop  (Read 766 times)

Paolo

  • Hero Member
  • *****
  • Posts: 718
multiple drag and drop
« on: April 24, 2026, 12:07:32 pm »
Hello, (here: win-64/Laz 4.6/fpc 3.2.4.RC1)

Just to understand if I am working in the right way.

I have a TFileListBox and a TtreeView.

I can drag and drop form TFileListBox a selected item to TreeView in the destination Item.
The sequence is simply:
1.   the user press the mouse left button on the item, adn kep it presses
2.   drag with the mouse from TFilelist on an Treeview Node

Now, I would like to drag and drop more than 1 element at time (they will be drop on the Ttrewview in sequence).
So first I activated Multiselect in the TFileListBox. The simple path used for one selected items does not apply.

To maintain all the items selected, I have two options:
a)   to copy continuous range of items
1-   press shift
2-   click on the first item
3-   click on the last
4-   drag keeping shift pressed

b)   to copy discontinuous range of items
1-   press control
2-   click all items you want select
3-   then press also shift
4-   drag keeping control+shift pressed

Is This the right way to accomplish this task ?
 
Regards.


jamie

  • Hero Member
  • *****
  • Posts: 7765
Re: multiple drag and drop
« Reply #1 on: April 24, 2026, 12:28:17 pm »
On windows the drop target receives a string that is delimited via a single Null character and double null when it reaches the end.

for each single #0 is the end of each item

Jamie
The only true wisdom is knowing you know nothing

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1594
    • Lebeau Software
Re: multiple drag and drop
« Reply #2 on: April 24, 2026, 08:06:00 pm »
On windows the drop target receives a string that is delimited via a single Null character and double null when it reaches the end.

That format is used when dragging actual files from Windows Explorer onto your app's window. And even then, that format is long outdated, there are better ways to handle dragged files. But in any case, the OP is simply dragging data items from one UI control to another UI control within the same app. That doesn't involve any OS drag formats at all.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Paolo

  • Hero Member
  • *****
  • Posts: 718
Re: multiple drag and drop
« Reply #3 on: April 25, 2026, 11:40:42 am »
Sorry for late answer.

thanks both,

yes my question was more on the way the user has to interact with keyboard and mouse to perform such multiple drag and drop,

Grazie.

jamie

  • Hero Member
  • *****
  • Posts: 7765
Re: multiple drag and drop
« Reply #4 on: April 25, 2026, 03:53:49 pm »
Using the standard Ctrl-C would work which of course would place it in the clipboard, however, you can register a custom clipboard format which can capture the Ctrl-C operations in the File List and then post a clipboard format of that type with whatever info needed.

 From there, the TreeView can act on the Ctrl-V via the capture of the keyboard strokes and determine if that format is sitting in the clipboard, if so, then process it.

 That is what the custom clipboard formats are used for, to transfer information only related to controls that know how to read it.

Jamie
The only true wisdom is knowing you know nothing

Boleeman

  • Hero Member
  • *****
  • Posts: 1158
Re: multiple drag and drop
« Reply #5 on: April 28, 2026, 01:46:06 am »
I also had a need to do multiple drag and drop for "Png Drop" but could not work out how to do it.

The program works well when one file dragged at a time, but how to do "multiple drag and drop of files" without the program choking up?

I attached that Png Drop Lazarus code just in case someone on the forum can figure it out?

Paolo

  • Hero Member
  • *****
  • Posts: 718
Re: multiple drag and drop
« Reply #6 on: April 29, 2026, 10:35:13 pm »
Hello,

just doing that for me Drag-and-Drop works on more than one file

Code: Pascal  [Select][+][-]
  1. procedure TMainForm.FormDropFiles(Sender: TObject; const FileNames: array of string);
  2. var
  3.   i : integer;
  4. begin
  5.   for i:=0 to Length(FileNames)-1 do
  6.     ReduceColorWrapper(FileNames[i]);
  7. end;
  8.  
« Last Edit: May 07, 2026, 04:16:22 pm by Paolo »

Boleeman

  • Hero Member
  • *****
  • Posts: 1158
Re: multiple drag and drop
« Reply #7 on: May 01, 2026, 12:16:48 pm »
Hi Paolo,

Sorry about not replying earlier as I had problems logging onto the Lazarus forum.

I tried your DragNDrop code and it works well.
(I thought something else was needed like multi-threading, but as it turned out your string array code was all that was needed).


Thanks for that Paolo.

 

TinyPortal © 2005-2018