Well, well, only halfways working. I earlier had reduced the loop to go from 13 to 13 and that only set format 13. NOw that I have the loop from 1 to 15 I don't get format 13 requests, but I do get requests for 1 and 15 from different drop targets. I reversed the order from 15 to 1 first, and still got other than 1 requests, but as it is now, it's neither just the last setting nor fully cumulative.
Edit 1:
No, it still works for me, I forgot the request of Format 13 comes from things like Google search box, where Unicode text is wanted. I still get requests for 1 from many targets in VFP itself, 13 for boxes like Google search and 15 from Windows Explorer pointing to folders, for example. Without the loop no requests are triggered, no OleSetData event occurs. So setting all formats helps, still a problem is that these requests come in before the OleDrop event, just at any DragOver, it seems.
Edit 2:
It becomes clear, why this is the behavior about event triggering, in OleDragOver you're asked to request the format you want from the oDataObject and there you make a call of GetData with the format, that causes the OleSetData event in the source object. And as it is that way, I see no reason to wait for these events, then you can also set several formats at OLEDragStart and the drop target will pick out what it wants. The OleSetData only happens once per format, when you set the requested format. Next requests of the same format are then already fulfilled by the set value.
One reason to wait with filling in all data is, when one of the formats would transport something binary and large that may never be requested. But even 15 is just a list of file names, not the files or their content itself.
One other reason is, you want to be recent, you want to transfer the latest data about something. The mechanism doesn't really support this, though, as the first request of a target is when you put in data, when you don't drop there, you never get the same format request again, all targets requiring the same format later get what you put in initially. Of course the next drag/drop operation starts fresh, but within one drag you'd only get multiple requests of the same format, if you clear the dataobject. But at what time would that be applicable? In each OleGiveFeedback event?
And another thing, which now bugs me: When I drop into the Google search box that works, but then it seems the oDataObject becomes a zombie object, a dangling reference. The form does not close. Neither the debugger nor VFPs Program menu shows anything on the call stack, any running code, but the form only releases with CLEAR ALL.
So there is something about OLE drag&drop VFP has not caught up with, I guess. But I haven't used this in my projects I always could do either without drag&drop or with native VFP drag&drop, so I don't know whether some or all these quirks are new or known or even by design. Surely a dangling object reference should not occur. And just while I'm at discussing OLe drop to Google search box, you have to use STRCONV(ansitext,5) and convert to Unicode, not UTF-8, though browser encode text with UTF-8, this has nothing to do with the html encoding. What you also have to do is add a CHR(0) before Unicode conversion, otherwise Google writes one gibberish character after the text. It's not that exceeding to read past the end of the dropped Unicode text, what hinders the VFP form to close. Adding the CHR(0) the text is transferred correctly, but the VFP form still refuses to close after a drag&drop has occurred and is completed. OleCompleteDrag occurs and informs the source object Google did a COPY (nEffect=1), that's okay and should end the drag, the oDataObject should also be released, but you have no hands on that, the OleCompleteDrag only allows you to override the effect or cancel the drop, but you don't get the oDataObject reference to call ClearData() on it to enable easier release, if that would help. Anyway, it's also not clear whether to blame Google or the Browser. The OLE operation is done to the browser process, of course.
OK, last thing: I tested several browsers. Chrome lets the form hang, FireFox drops the text twice but the VFP form can release cleanly. In MS Edge the drop does not work always and the VFP form hangs again. Internet Explorer is unproblematic again. So in part this also depends on what other application you drag to.
Bye, Olaf.
Olaf Doschke Software Engineering