Recent

Author Topic: How to prevent onDropFiles "locks" Finder's Drag and Drop abilities  (Read 267 times)

Hansaplast

  • Hero Member
  • *****
  • Posts: 762
  • Tweaking4All.com
    • Tweaking4All
As mentioned in an earlier post, I'm experiencing difficulties when doing files drag and drop where the Finder looses its drag and drop abilities as long as the onDropFiles event is running.
Had never seen this under Windows or Linux, and was advised by much more experienced devs in Bugtracker, to ask in the forum how to deal with this.
The use of TThread was mentioned as an option.


Does anyone know how to handle this practically?


I basically just need the list of Filenames and, as far as I'm concerned, then onDropFiles event can then be closed.
These files need to be analyzed which can take some time.

cdbc

  • Hero Member
  • *****
  • Posts: 2600
    • http://www.cdbc.dk
Re: How to prevent onDropFiles "locks" Finder's Drag and Drop abilities
« Reply #1 on: January 14, 2026, 02:48:32 pm »
Hi
Well, here's what I'd do:
· create a queue of filenames ~ strings in your app, there's one HERE
· in the 'onDropFiles' event handler, you add all the filenames to the queue
  (this concludes the 'onDropFiles' eventhandler and thus frees up the 'Finder')
· You're now free to use as many threads as your cpu allows, to process your
  queue of filenames. (use max cpu/core-count - 1 threads, the 1 is for main)
· If you use one of my queues, that's it, because they're COM interfaces and
  get free'd when they go out of scope, easy peasy =^
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Hansaplast

  • Hero Member
  • *****
  • Posts: 762
  • Tweaking4All.com
    • Tweaking4All
Re: How to prevent onDropFiles "locks" Finder's Drag and Drop abilities
« Reply #2 on: January 14, 2026, 02:57:39 pm »
Thanks Benny!


Looks like a more advanced queue than I had in mind, so I'll definitely go look at your project! 😊

cdbc

  • Hero Member
  • *****
  • Posts: 2600
    • http://www.cdbc.dk
Re: How to prevent onDropFiles "locks" Finder's Drag and Drop abilities
« Reply #3 on: January 14, 2026, 03:09:19 pm »
Hi
Hahaha... The advanced bit is already done  :D Look at the API/Interfaće to the queue, pretty simple, huh?
If you need it, I could whip you up an IStringQueue... 8-)
About threading, I'd say, get the 'EnQueueing' up and running then turn to the multithreaded processing of said filenames...  ;D
Otherwise just 'holler' if you need assistance  ;)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Hansaplast

  • Hero Member
  • *****
  • Posts: 762
  • Tweaking4All.com
    • Tweaking4All
Re: How to prevent onDropFiles "locks" Finder's Drag and Drop abilities
« Reply #4 on: January 14, 2026, 04:51:23 pm »
😉 Always nice if the advanced work is already done haha. 👍🏻
Appreciate the offer to whip me up an IStringQueue.

As for threads: Well, I'd rather not use threads for this particular purpose - things could become messy real fast.

For now I've done it the "amateur" way:

1) Set TForm.AllowDropFiles to false,
2) Copy all the Filenames array to another (global) array
3) Enable a TTimer that calls the procedure that deals with the array after 100 ms (onTimer).
4) onDropFiles is now done and Finder will be left alone.
5) onTimer: Stop TTImer, and handle all files
6) After files have been handled, set TForm.AllDropFiles to true again.

Works well enough for now, though this is not really "the right way" to do it.

Will need to dig in a little more when I have the time and explore what I can do with your advanced work 😁
Your Containers library looks very interesting - so I will dig into that one for sure (have a different little hobby project that could really use this!).

 

TinyPortal © 2005-2018