How to scan the dropped items ?

Hi all,

do you think the following explanation is enough to understand ?

DragItem.NextItem

I do not think so and I wasted an hour or two yesterday to finally write the “correct code” to deal with multiple (images) file drops in a window.

Two Events have to be added in the Canvas (my target Control): Open and DropObject.

To allow an item drop, in Canvas1.Open I put:

Me.AcceptFileDrop FT_imgs.All

Then, in the DropObject Event:

[code] Dim DropFI As FolderItem
Dim ScanCover As Picture

If Obj.FolderItemAvailable Then
// Use a local variable
DropFI = Obj.FolderItem

// Loads the dropped image into a larger Offscreen Picture
ScanCover = Picture.Open(DropFI)

// Deals with the dropped image file
Card_Pict.Graphics.DrawPicture ScanCover, CurrentX, CurrentY

// And update the window contents
Self.Refresh

End If[/code]

Then comes the time to add code to place the dropped images where I want to see them (skipped).

And after sometimes (I went tired to drop only one file at a time) went the time to “deals with a drop of many files”.

At this time, I started a quest to get information (without internet) on how to do that.
Contrary to a Newbie, I was fortunate enough to know it is possible to do that.
Unfortunately, my quest went to an end and I failed miserably :frowning:

In my quest, I saw (and read) many times the part concerning DragItem.NextItem, but the scarce explanation did not open a light in my mind (no bell was ringing there).

Better try that than stop in here. So I wrote:

[code] Dim CoverIdx As Integer

CurrentY = 32
CoverIdx = 1

// Display the first dropped image
Deal_With_Item(Obj.FolderItem)

// Display all subsequent dropped images
While Obj.NextItem
Deal_With_Item(Obj.FolderItem)
CoverIdx = CoverIdx + 1

// Avoid to draw a sixth line
If CoverIdx > 54 Then
  CoverIdx =  1
  Exit
End If

// To avoid 1, Infinite Loop…
If UserCancelled Then Exit

Wend[/code]

And it works. You already understand that i do not understand how checking a Boolean will fire hidded code; but at this stage (now) I do not care.

So, for future Xojo users that will not read this conversation, please, add a complete explanation with a simple example code or not.

A better approach is to add all obj items into an array and process the folderitems outside the dropevent,
This way your app does not lock while doing a dragndrop.

Thank you Christop for your kind answer.

Do you mean:

  1. fill a FolderItem array in the DropObject Event,
  2. in the DropObject Event, call the method who will process the Array contents ?

Not sure how to understand your answer (due to my bad english).