The-Drag-and-Drop-Component-Suite-for-Delphi icon indicating copy to clipboard operation
The-Drag-and-Drop-Component-Suite-for-Delphi copied to clipboard

Change in DragDropFormats.pas = aMedium.Stm:=Stream = problems

Open MicrotronX opened this issue 4 years ago • 17 comments

Hi,

before i was able to perform a DragDrop Operation fromtDropEmptySource (connected to VirtualDataformatAdapter) to tDropComboTarget (new form on same app), after changing lines 1297 and 1303 from iStream(aMedium.stm):=Stream to aMedium.Stm:=Stream it does not work any more.

Changing those lines back ... and everything is working again.

MicrotronX avatar Oct 27 '20 13:10 MicrotronX

do you have a sample application please?

i changed it, because it produces a memory leak

https://github.com/landrix/The-Drag-and-Drop-Component-Suite-for-Delphi/issues/41

landrix avatar Oct 27 '20 14:10 landrix

I use this in my big project so no small demo but changing it back solved problems on my side, don't know why but now it works

MicrotronX avatar Oct 27 '20 14:10 MicrotronX

i can't reproduce it without any informations about the code in the involved eventhandler. the best way is, you can provide a little demo.

landrix avatar Oct 27 '20 14:10 landrix

Here's some code:

onMouseDown of my cxGridView: `myFileDropSource.Files.Clear; // = tEmptyDropSource where a tvirtualdataformatadapter is connected TVirtualFileStreamDataFormat(myVirtualDataformatAdapter.DataFormat).FileNames.Clear; TVirtualFileStreamDataFormat(myVirtualDataformatAdapter.DataFormat).FileNames.add(vdatei); // add some virtual filenames // manage also a internal list with these filenames, which will be created at myEmptyDropSourceGetData..

// Start the drag operation. myEmptyDropSource.Execute();`

On the other side, at the form2 i have a tDropComboTarget where the onDrop event is never gets called after your change.

MicrotronX avatar Oct 27 '20 14:10 MicrotronX

can you check the new sources again please

landrix avatar Oct 31 '20 16:10 landrix

With your latest changes drag&drop within same app from two different forms is working again. So it seems that this bug is solved.

MicrotronX avatar Nov 02 '20 09:11 MicrotronX

Stop. Not solved. Crazy. Within same app it works without problems. If i start the same app twice and try to Drag&Drop from one to the other, sometimes it works, sometimes it does not.

MicrotronX avatar Nov 02 '20 09:11 MicrotronX

And it seems that the last started app can Drag&Drop TO the first started app but the first started can't Drag&drop files TO the last started app.

MicrotronX avatar Nov 02 '20 09:11 MicrotronX

ok, i will switch back to the origin code

landrix avatar Nov 02 '20 09:11 landrix

And both apps can drag&drop within the same app from different forms without any problems inkluding our own clipboardformat and dataformat. from one app to the other the own clipboard- and dataformat is not available

MicrotronX avatar Nov 02 '20 09:11 MicrotronX

and the origin code works as expected in both cases?

landrix avatar Nov 02 '20 10:11 landrix

Will try to do the same, two started exe files and drag&drop between them between different forms within the applications. I had not tested this before your update. After your change it started working within same app and different forms ... as i can remember i had no problems from different apps but will try it again.

MicrotronX avatar Nov 02 '20 10:11 MicrotronX

If i drag and drop to second app, than the debugger (second started app) shows that the on getStream of virtualdataadapter is called and it returns the stream without problems but this stream is never received on app where drop is made:

procedure TmxDateianlagen.VirtualDataAdapter_OnGetStream(Sender: TFileContentsStreamOnDemandClipboardFormat; Index: integer; out AStream: IStream);
var
    Stream:tStream;
    vMemStream: TMemoryStream;
    vFileStream: tFileStream;
vmindex:longint;
begin
    // This event handler is called by TFileContentsStreamOnDemandClipboardFormat
    // when the drop target requests data from the drop source (that's us).
    try
        try
            AStream := nil; vMemStream:=tdateianlagen.FastSave2Memorystream(vmindex); // get the stream of file
Stream:=vMemStream;
            if Stream.Position=0 then begin
                Stream.position:=Stream.size;
            end;

            // ...and return the stream back to the target as an IStream. Note that the
            // target is responsible for deleting the stream (via reference counting).
            AStream := TFixedStreamAdapter.Create(Stream, soOwned);
        finally
            setlength(vlist,0);
        end;
    except
        on e:Exception do begin
            bottompanel.caption:=bottompanel.caption+',Ex:'+e.message;
            if assigned(Stream) then Stream.Free;
            raise;
        end;
    end;
end;

MicrotronX avatar Nov 02 '20 11:11 MicrotronX

Can i send you a private demo, i have extracted a some functions into a demo but don't want that to be online. It is a demo with two cx-grids. You can drop a file from explorer into both + drag&drop links between them (internal clipboardformat, dataformat). If you start this app again and try to drag&drop from first app grid to second app grid it does not work.

MicrotronX avatar Nov 02 '20 13:11 MicrotronX

you find my email on my github profile

landrix avatar Nov 02 '20 13:11 landrix

thank you, i need to modify your demo, i must remove the components, that i don't have

landrix avatar Nov 03 '20 10:11 landrix