DOCERR: Avoid GDI Object Private Clipboard Formats

Last reviewed: July 23, 1997
Article ID: Q89119
3.10 WINDOWS kbtoolkbtoolg kbdocerr

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1

SUMMARY

In the Microsoft Windows Software Development Kit (SDK) version 3.1 "Programmer's Reference Volume 2: Functions," page 828 of the documentation for the SetClipboardData function states:

  Private data formats in the range CF_GDIOBJFIRST through CF_GDIOBJLAST
  will be automatically removed by a call to the DeleteObject function
  when the data is removed from the clipboard.

This statement is incorrect under Windows 3.1. Private data formats with types in this range are treated like global memory handles by Windows. As such, this range of private data formats should be avoided.

MORE INFORMATION

Under the debugging version of Windows, if an application calls the SetClipboardData function with a handle to a GDI object, and a format identifier in the range CF_GDIOBJFIRST through CF_GDIOBJLAST, Windows will output the following message on the debugging terminal:

  err APPNAMEHERE->USER GLOBALREALLOC+15: Invalid global handle: 0x1234

This is due to a problem in Windows version 3.1. Windows treats the GDI object's handle as a global memory handle, when it should treat it as a GDI handle (for example, a handle to a brush, palette, font, and so on.)

In addition, the object will not be deleted properly when the EmptyClipboard function is called. This leads to a loss of memory in GDI's heap. When GDI's heap is exhausted, either Windows crashes or output is corrupted.


Additional reference words: 3.10 docerr
KBCategory: kbprg kbdocerr
KBSubcategory: UsrClp
Keywords : kb16bitonly


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: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.