How To Retrieve DIBs from the Clipboard (106386)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0
This article was previously published under Q106386 SUMMARY
Retrieving a DIB (device-independent bitmap) from the clipboard can take
significantly more time than retrieving a bitmap from the clipboard. The
difference stems from the fact that a bitmap is a GDI object and a DIB is a
global memory object.
MORE INFORMATION
When SetClipBoardData() is passed a global memory handle, as it is when it
is passed a handle to a DIB, all the data gets copied into the Win32 server
and put into a sharable section of memory. When the DIB is retrieved with
GetClipBoardData(), the shared memory is mapped into the application's
virtual address space and the memory handle is cached. Any subsequent calls
to GetClipBoardData() return quickly, because the memory does not have to
be remapped.
In contrast, when retrieving a bitmap with GetClipBoardData(), only a
handle is created, because a bitmap is a GDI object.
When CloseClipboard() is called, all of the cached handles to shared memory
and GDI objects are deleted.
Rather than reopening the clipboard, it is a good idea to keep a local copy
of anything retrieved from the clipboard if the item will be used again
after the clipboard has been closed. In general, data should be retrieved
from the clipboard only when the application is doing a paste or if the
application is a clipboard viewer processing a WM_DRAWCLIPBOARD message.
The data for a GDI object exists on the server side. In other words,
bitmaps and DDBs (device-dependent bitmaps) exist in the Win32 subsystem
address space. Only the handles of GDI objects are private to an
application. Therefore, to make a bitmap or a DDB accessible to another
application, only a call to DuplicateHandle() is needed.
Note that even though it is faster to retrieve a DDB from the clipboard, it
is still recommended to put a DIB on the clipboard rather than a DDB.
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbClipboard kbhowto KB106386 |
---|
|