views:

323

answers:

1

hi there ,i m new here . stackoverflow is a good place to help others and being helped. so i post my problem here.i'va asked quite a few people and find no answers.

thanks

Use SelectObject() on your memory DC to select the bitmap into it.This makes me puzzled. i read the msdn but still don't konw how to fill the second parameter of SelectObject(). help

+5  A: 

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.

Adam Rosenfield