Board index » delphi » ClipBoard + TMemoryStream?

ClipBoard + TMemoryStream?

I came up with what I thought was a clever scheme for my program. I
created a custom component that has Read and Write methods to a stream.
This way I can read and write my components to a TFileStream for my file
I/O. This part works fine but I also had in mind that I could Read and
Write these items to a TMemoryStream and then copy the MemoryStream to
the clipboard for a neat and easy multiple item Cut, Copy and Paste
routine. The catch is that writing custom data to the clipboard requires
a memory handle and TMemoryStream only provides a pointer. Is there any
way to get a handle from this pointer? Does a TMemoryStream not use
gloabl memory?

I know I could allocate some global memory and then copy the stream
there but it seems kind of kludgy. Any other solutions?

Mitch Wolberg,
RockWare, Inc.

 

Re:ClipBoard + TMemoryStream?


In article <3744775B.C6CD1...@dnvr.uswest.net>, Mitch Wolberg

Quote
<rk...@dnvr.uswest.net> writes:
>I know I could allocate some global memory and then copy the stream
>there but it seems kind of kludgy. Any other solutions?

>Mitch Wolberg,
>RockWare, Inc.

Search DeJaNews for Chris Fairall and/or Saving Object to Clipboard

hth

Gordon.

http://members.aol.com/mgcsoft/
http://members.aol.com/delphistuf/delphstf.htm   (bits and bobs and a few
links)

MGCSoft

Re:ClipBoard + TMemoryStream?


Thanks for the lead. I actually came to the same solution last night. My
problem with it is that it still requires 2 times the size of the data
in memory. Its probably what I'll end up doing unless someone has a
better idea.

Mitch Wolberg,
RockWare, Inc.

Quote
GWhit41980 wrote:

> In article <3744775B.C6CD1...@dnvr.uswest.net>, Mitch Wolberg
> <rk...@dnvr.uswest.net> writes:

> >I know I could allocate some global memory and then copy the stream
> >there but it seems kind of kludgy. Any other solutions?

> >Mitch Wolberg,
> >RockWare, Inc.

> Search DeJaNews for Chris Fairall and/or Saving Object to Clipboard

> hth

> Gordon.

> http://members.aol.com/mgcsoft/
> http://members.aol.com/delphistuf/delphstf.htm   (bits and bobs and a
> few
> links)

> MGCSoft

Re:ClipBoard + TMemoryStream?


In article <3744775B.C6CD1...@dnvr.uswest.net>, Mitch Wolberg

Quote
<rk...@dnvr.uswest.net> writes:
>I came up with what I thought was a clever scheme for my program. I
>created a custom component that has Read and Write methods to a stream.
>This way I can read and write my components to a TFileStream for my file
>I/O. This part works fine but I also had in mind that I could Read and
>Write these items to a TMemoryStream and then copy the MemoryStream to
>the clipboard for a neat and easy multiple item Cut, Copy and Paste
>routine. The catch is that writing custom data to the clipboard requires
>a memory handle and TMemoryStream only provides a pointer. Is there any
>way to get a handle from this pointer? Does a TMemoryStream not use
>gloabl memory?

Have you looked at the code for the SetComponent and GetComponent methods of
TClipBoard in Clipbrd.pas. It might give you some ideas.

Alan Lloyd
alangll...@aol.com

Other Threads