I am new to working with MFC and bitmaps. I have a HWND
, which I want to print onto a bitmap using WM_PRINTCLIENT
. This is what I have thus far:
EDIT:
CRect rcWindow;
GetClientRect(hWnd, &rcWindow);
HDC hDC = GetDC(hWnd);
HDC hBitmapDC = CreateCompatibleDC(hDC);
HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rcWindow.Width(), rcWindow.Height());
SelectObject(hBitmapDC, hBitmap);
SendMessage(hWnd, WM_PRINTCLIENT, (WPARAM)hBitmapDC, PRF_CHILDREN | PRF_CLIENT | PRF_NONCLIENT);
CImage image;
image.Attach(hBitmap);
image.Save(_T("C:\\Test.bmp"), Gdiplus::ImageFormatBMP);
This however results in a bitmap that is all black. Can anyone see what I am doing wrong?