[Eureka] How to deal with many items in the DropObject Event

When you drop more than one item in your Window or Control (even in your Application Icon or Dock Icon), you are stuck because… “How do I get the other dropped items ?"

The answer is to use a loop with obj.NextItem.

In an old project, I never finished properly that part and sometimes I get an error. So I searched in vain in the doc (.DropObject entries) about that until I searched obj.NextItem.

I found the explanation and solution in DragItem (but it is now elsewhere too).

My old code was based on While … Wend and the code in DragItem uses Do … Loop and that was the solution that save my day (in fact, evening).

The relevant code is (between other places) DragItem just above the See Also paragraph (this one deals with Text, but that part is easy to change if you want to deal with images or something else).

It can be a good idea to replicate it in all .DropObject definition files (or better in its own page that is linked everywhere that is needed) since that is the place I searched for it first.

I hope this help.

Yes, I use this to process a set of dropped files.

I used (yesterday) DebugLog to check what is the FileType of the dropped items in order to exclude folders, text, etc. (in short: exclude unwanted files from the drop list).

Most of the time, I deal with a folder drop, so I do not use obj.NextItem often.

But yesterday, I had a rock in my shor: a folder was not filtered (thus I got a crash) and that was because of my code who was not… Rock Solid (he he :rofl:).

At last, this question arise here a number of times because people search the information where it belongs and failed to find it (as it was elsewhere). I was lucky to know the answer, so my search returned the valid answer (once I issued a Search…).