Jump to content
pyscripter

OleSetClipboardData and delayed rendering

Recommended Posts

The OleSetClipboardData documentation claims that the Clipboard implements delayed rendering, meaning that it renders a given format of the IDataObject implementation, only when the format is actually requested.

 

My DataObject implements CF_UNICODETEXT and CF_HTML formats.  As soon as I call OleSetClipboardData both formats are rendered.   Any idea why is that?  How can one implement delayed (lazy) rendering of clipboard formats?

Share this post


Link to post

Works for me.

Here's what I'm seeing when I copy to the clipboard using the Drop Target Analyzer from the D&D Component Suite:

image.thumb.png.6395cf4f9258317d2e44b3568933611c.png

I copied to the clipboard (blue bullets) and after a while (3.6 seconds) I pasted from the clipboard. The red bullets indicates the calls made from the drop target to the drop source. The list on the right are the data formats requested by the drop target.
As you can see there are no calls made on the IDataObject until I paste from the clipboard.

 

Here's the corresponding view from the drop target (the Drop Source Analyzer):

image.thumb.png.3398acb6c82e32d64a95cb5778515886.png

 

Maybe you have an application running which monitors and reads from the clipboard?

  • Thanks 1

Share this post


Link to post

Thanks @Anders Melander.  It could be the Windows 10 multi-device clipboard that results in this, or else some formats like CF_UNICODETEXT are translated automatically say to CF_TEXT for compatibility with the OLE 1.0 Clipboard.

Share this post


Link to post
16 hours ago, pyscripter said:

or else some formats like CF_UNICODETEXT are translated automatically say to CF_TEXT for compatibility with the OLE 1.0 Clipboard.

The clipboard will synthesize some formats from others (e.g. CF_TEXT from CF_UNICODETEXT) but only if the target asks for that format and only if the source hasn't already provided it. See Synthesized Clipboard Formats.

 

Did you remember to specify zero for the hMem parameter of SetClipboardData? - and do you handle the WM_RENDERFORMAT and WM_RENDERALLFORMATS messages?

Share this post


Link to post
3 minutes ago, Anders Melander said:

Did you remember to specify zero for the hMem parameter of SetClipboardData? - and do you handle the WM_RENDERFORMAT and WM_RENDERALLFORMATS messages?

I am using OleSetClipboardData with a IDataObject.  This does not have any other arguments.  And I am not handling WM_RENDERFORMAT or WM_RENDERALLFORMATS.  These messages are handled by the OLE clipboard.

Share this post


Link to post
1 minute ago, pyscripter said:

I am using OleSetClipboardData with a IDataObject. 

Yes, forget what I wrote. I got things confused.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×