BUG: Retaining Clipboard IDataObject Causes Unexpected Result

Last reviewed: May 17, 1995
Article ID: Q109545
The information in this article applies to:
  • Microsoft OLE Libraries for Windows and Win32s, version 2.01
  • Microsoft OLE Libraries, included with:

        - Microsoft Windows NT, versions 3.5 and 3.51
        - Microsoft Windows 95
    

SYMPTOMS

An application holding on to a clipboard IDataObject pointer, and making repeated calls to IDataObject::EnumFormatEtc() through that pointer, may find that the set of formats returned by EnumFormatEtc() changes between calls.

RESOLUTION

As noted in the Object Linking and Embedding SDK version 2.01 documentation, an application that calls OleGetClipboard() to retrieve an IDataObject interface pointer should hold on to that IDataObject pointer only for a very short time.

STATUS

Microsoft has confirmed this to be a problem in the products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce

  1. Copy an object from an OLE 1.0 server to the clipboard.

  2. Call OleGetClipboard() to obtain an IDataObject pointer to the clipboard object.

  3. Call IDataObject::EnumFormatEtc() to enumerate the available formats.

  4. Without calling IDataObject::Release(), copy an object from an OLE 2.0 server to the clipboard.

  5. Call IDataObject::EnumFormatEtc() again. The formats enumerated have changed to the formats provided by the new OLE 2.0 object.

The OLE2UI library's implementation of the Paste Special dialog box (provided in the Object Linking and Embedding SDK version 2.01) works around this problem. The Paste Special dialog box is launched by calling OleUIPasteSpecial(). If the user changes the contents of the clipboard while this dialog is up, the OLE2UI code detects the change and responds by ending the dialog box. When this happens, OleUIPasteSpecial() returns OLEUI_PSERR_CLIPBOARDCHANGED.

The dialog box detects changes to the clipboard contents by calling SetClipboardViewer() to splice itself into the clipboard viewer chain.


Additional reference words: 2.01 3.50 4.00 toolkit
KBCategory: kbole kbbuglist
KBSubcategory: LeTwoDdc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.