Click to See Complete Forum and Search --> : Screen Capture into Clipboard?


April 16th, 1999, 01:19 PM
Hi,
I can't seem to capture my desktop screen and copy it into the clipboard.
When I look at the clipboard the image is totally garbled (black & blue stripes).
Can someone please point out to me what I'm doing wrong or show me
a better way of doing this? I did the following:

<ccode>
HBITMAP hBitmap;
OpenClipboard(hwin); // hwin is my window handle
HDC hDCSrc = GetDC(NULL); // get entire window device context
hBitmap = CreateCompatibleBitmap((HDC) hDCSrc, 640, 480);
SetClipboardData(CF_BITMAP, hBitmap);
ReleaseDC(NULL, hDCSrc);
CloseClipboard();
</ccode>

April 16th, 1999, 02:29 PM
It appears you may have a type conversion problem.
Check ---> hBitmap = CreateCompatibleBitmap((HDC) hDCSrc, 640, 480);
(what type does this function return?)

April 16th, 1999, 04:32 PM
> Check ---> hBitmap = CreateCompatibleBitmap((HDC) hDCSrc, 640, 480);
> (what type does this function return?)
It returns an HBITMAP which is what hBitmap is. But the next line:
SetClipboardData(CF_BITMAP, hBitmap) --> the 2nd param is expected to be of HANDLE type.
I pass in an HBITMAP type but if I understand the documentation correctly, this should be ok...