Context:
With the help of http://melander.dk/delphi/dragdrop/ i've created a little prototype to Save attachments in a AdsTable (the prototype is build so that the way the Stream is saved can be decided by the user).
Everything works fine so far with the exception of .ZIP files.
The TDropEmptyTarget.OnDrop event doesn't get the information... to be more precise not even the TDropEmptyTarget.OnEnter event triggers
I've found out that the problem lies within the different tagFORMATETC of the .ZIP file. Compared to an .EXE file they have the same formats except for one
.EXE = (49441, nil, 1, -1, 4) // ClipboardFormatname = 'FileContents'
.ZIP = (49159, nil, 1, -1, 1) // ClipboardFormatname = 'FileNameW'
I've managed that the components will accept the Format and i can Drop it... but it won't read the Data correctly.
Simply changing the extention from .ZIP to whatever allows me to drop the file in my control... save it and drag it out... changing it back to .ZIP and everything works fine... but that's the last thing i want.
[EDIT1]
Code To Enable the .ZIP drop (only allows the zip file to be dropped but Data can not be read
// ClipboardFormat for Zip
TFileContentsOnDemandZipFormat = class(TAnsiFileGroupDescriptorClipboardFormat)
public
function GetClipboardFormat: TClipFormat; override;
end;
function TFileContentsOnDemandZipFormat.GetClipboardFormat: TClipFormat;
begin
Result := RegisterClipboardFormat('DragContext'); // also tried 'FileNameW'
end;
...
// Enables to drop Zip-Format
aClipboardZipFormat := TFileContentsOnDemandZipFormat.CreateFormat(1 or 4);
// VirtualTargetFiles = TVirtualFileStreamDataFormat(fTargetData.DataFormat)
aIndex := VirtualTargetFiles.CompatibleFormats.Add(aClipboardZipFormat);
// fDropTarget = TDropEmptyTarget
fDropTarget.DataFormats.Formats[0].AcceptFormat(VirtualTargetFiles.CompatibleFormats[aIndex].FormatEtc);
All formats for an .EXE file EXE-File:
(49438, nil, 1, -1, 1)
(50098, nil, 1, -1, 1)
(50099, nil, 1, -1, 1)
(49454, nil, 1, -1, 4)
(50100, nil, 1, -1, 1)
(49453, nil, 1, -1, 1)
(15, nil, 1, -1, 1)
(49158, nil, 1, -1, 1)
(49441, nil, 1, -1, 4) = 'FileContents' // Used by the component
ZIP-File:
(49438, nil, 1, -1, 1)
(50098, nil, 1, -1, 1)
(50099, nil, 1, -1, 1)
(49454, nil, 1, -1, 4)
(50100, nil, 1, -1, 1)
(49453, nil, 1, -1, 1)
(15, nil, 1, -1, 1)
(49158, nil, 1, -1, 1)
(49159, nil, 1, -1, 1) = 'FileNameW'
Formats accepted by the component
(49441, nil, 1, -1, x)
(49442, nil, 1, -1, x)
(49443, nil, 1, -1, x)
[\EDIT1]
[EDIT2]
After enabeling the .ZIP file to onto the control, the component still can't read the data (apparently) and i've managed to follow the Code to the Funktion: (Well it looks like it can read the data but doesn't know the right thing to do with it)
Unit DragDropFormats
TCustomSimpleClipboardFormat.DoGetDataSized()
Which seems to be the important part... but at this depth it get's to complicated for me.
[\EDIT2]
Repeatable:
You can download the component here: http://melander.dk/delphi/dragdrop/
and run the demo VirtualFileStream this demo also doesn't allow the .ZIP file for all the same reasons.
You might want to remove the file cap in DropEmptyTarget1Drop by removing
if (BufferSize > MaxBufferSize) then
BufferSize := MaxBufferSize;
Question:
Has anyone a simple solution for this problem?