Hi,
While implementing drag-n-drop support in fpGUI, I created a TfpgMimeData class. This class will hold various data items, and a mime-type describing each of the data items. Obviously the TfpgMimeData class should be able to handle any data type. So my question is, what is a good universal type to store all kinds of data (strings, images (binary data), sound etc)?
The possible ideas I can think of is the following:
TByteArray
Variants
TMemoryStream
So which one would be more fitting for any mime types, or is there another option I didn't think of? Here is a simple usage example of the TfpgMimeData class - to help put this in perspective:
var
m: TfpgMimeData;
d: TfpgDrag;
a: TfpgDropAction;
begin
m := TfpgMimeData.Create;
m.SetData('text/plain', 'My name is Earl');
m.SetData('text/html', 'My name is <b>Earl</b>'); // text/plain
can actually be created from this automatically
m.SetData('image/png', MyPNGImage);
d := TfpgDrag.Create(self);
d.MimeData := m;
d.StartDrag([daCopy]);
// d manages the lifespan of m
// d will be freed automatically when drag action is complete or cancelled
end;