The docs say:
<quot url=http://tinyurl.com/3fclf" fromSite="msdn.microsoft.com">
After SetClipboardData is called, the system owns the object identified by
the hMem parameter. The application can read the data, but must not free the
handle or leave it locked until the CloseClipboard function is called. (The
application can access the data after calling CloseClipboard). If the hMem
parameter identifies a memory object, the object must have been allocated
using the function with the GMEM_MOVEABLE flag.
</quot>
Leaving aside the bit about GMEM_MOVEABLE, the fact that the clipboard now
owns the handle is exactly how I have always interpreted that. I don't
really know what it means about being able to "access the data after calling
CloseClipboard"-- I presumed it meant to be able to GetClipboardData() for a
paste.
The logic for this, of course, is that the app can terminate but the data
has still to be in the clipboard, so the clipboard must own it.
As an aside (I presume Alexander you know this but just for reference), if
you use OleSetClipboard with an object implementing IDataObject then you can
continue to "own" the data of course, and only access the underlying data
when called through that interface. This is what Excel does (I assume). At
the "Copy" point, only the reference to the data (held in excel) is given to
the clipboard (as an IDataObject), but when the app is closing, the data has
to be pasted (or not) onto the clipboard so that the reference can be freed
and the app close down, which is why asks whether you want to keep a large
amount of data on the clipboard when it closes down. Of course Excel is in a
world of it own when it comes to clipboard behavior, anyway.
S.
"Alexander Nickolov" <***@mvps.org> wrote in message news:***@TK2MSFTNGP12.phx.gbl...
In all the examples of standard formats I've seen in MSDN,
the object is lost to you once you place it on the clipboard.
I know that's not what the docs say...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: ***@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by JohnThat's exactly what I am doing but when I go to paste into paint I get an
"Error getting the clipboard data!"
Whats strange is that after the error message is displayed and I switch
back to my ATL control the bitmap
Post by Johnisn't drawn in my control anymore, it's as if it's been destroyed.