<div dir="ltr"><div class="gmail_quote">On Wed, Sep 22, 2010 at 1:31 PM, Graeme Geldenhuys <span dir="ltr"><<a href="mailto:graemeg.lists@gmail.com">graemeg.lists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
While implementing drag-n-drop support in fpGUI, I created a<br>
TfpgMimeData class. This class will hold various data items, and a<br>
mime-type describing each of the data items. Obviously the<br>
TfpgMimeData class should be able to handle any data type. So my<br>
question is, what is a good universal type to store all kinds of data<br>
(strings, images (binary data), sound etc)?<br>
<br>
The possible ideas I can think of is the following:<br>
<br>
TByteArray<br>
Variants<br>
TMemoryStream<br>
<br>
So which one would be more fitting for any mime types, or is there<br>
another option I didn't think of? Here is a simple usage example of<br>
the TfpgMimeData class - to help put this in perspective:<br>
<br>
<br>
var<br>
m: TfpgMimeData;<br>
d: TfpgDrag;<br>
a: TfpgDropAction;<br>
begin<br>
m := TfpgMimeData.Create;<br>
m.SetData('text/plain', 'My name is Earl');<br>
m.SetData('text/html', 'My name is <b>Earl</b>'); // text/plain<br>
can actually be created from this automatically<br>
m.SetData('image/png', MyPNGImage);<br>
<br>
d := TfpgDrag.Create(self);<br>
d.MimeData := m;<br>
d.StartDrag([daCopy]);<br>
<br>
// d manages the lifespan of m<br>
// d will be freed automatically when drag action is complete or cancelled<br>
end;<br>
<br></blockquote><div> <br>Just initial idea.<br></div><div><br>TfpgMimeData class(TfpgDragData);<br>Picture:TPic ...<br>end;<br><br>var<br>
m: TfpgDragData;<br>
d: TfpgDrag;<br>
a: TfpgDropAction;<br>
begin<br>
m := TfpgMimeData.Create;<br>
m.SetData('text/plain', 'My name is Earl');<br>
m.SetData('text/html', 'My name is <b>Earl</b>'); // text/plain<br>
can actually be created from this automatically<br><br> m.SetData('image/png'); <br>
(m as TfpgMimeData).Picture.Assign(MyPNGImage);<br>
<br>
d := TfpgDrag.Create(self);<br>
d.DragData := m;<br>
d.StartDrag([daCopy]);<br>
<br>
// d manages the lifespan of m<br>
// d will be freed automatically when drag action is complete or cancelled<br>
end;<br><br></div></div>-- <br>Zaher Dirkey<br>
</div>