Call OpenClipbard()
to open the clipboard and call GetClipboardData()
with a type of CF_BITMAP
to get the handle to the image data stored on the clipboard. If there's no image on the clipboard, the NULL handle will be returned.
Then, inside your window's WM_PAINT
handler, use BeginPaint()
to get a device context for drawing into your window, and use CreateCompatibleDC()
to create a memory device context for the bitmap. Use SelectObject()
on your memory DC to select the bitmap into it, and finally use BitBlt()
to blit the bitmap from the memory DC onto the window's DC. Don't forget to clean up -- call DeleteDC()
to delete the memory DC, and call EndPaint()
to end drawing.
Lastly, call CloseClipboard()
when you're done. Note that the clipboard owns the bitmap handle, and as soon as you call CloseClipboard()
, the bitmap will be destroyed. So, if you want to hang onto the bitmap after you've closed the clipboard, you'll need to make a copy of it.