N
Neptune123
Guest
I am trying to get the bitmap and save it. I am using the following code. I am using WM_PRINT.
I don't want to use bitblt method to get the bitmap data.I am getting the blank window not the exact one. please see the actual graph and the final graph.Can anyone help? Thank you.
HDC hDCMem = CreateCompatibleDC(NULL);
RECT rect;
/ Get the rectangle of the Graph area.
::GetWindowRect(hWnd,&rect);
HBITMAP hBmp = NULL;
HDC hDC = ::GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC, rect.right - rect.left, rect.bottom - rect.top);
::ReleaseDC(hWnd, hDC);
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
::SendMessage(hWnd,WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SelectObject(hDCMem, hOld);
BITMAP bmpScreen;
// Get the BITMAP from the HBITMAP
GetObject(hBmp,sizeof(BITMAP),&bmpScreen);
::OpenClipboard(hWnd);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, HBITMAP(hBmp));
CloseClipboard();
Continue reading...
I don't want to use bitblt method to get the bitmap data.I am getting the blank window not the exact one. please see the actual graph and the final graph.Can anyone help? Thank you.
HDC hDCMem = CreateCompatibleDC(NULL);
RECT rect;
/ Get the rectangle of the Graph area.
::GetWindowRect(hWnd,&rect);
HBITMAP hBmp = NULL;
HDC hDC = ::GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC, rect.right - rect.left, rect.bottom - rect.top);
::ReleaseDC(hWnd, hDC);
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
::SendMessage(hWnd,WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SelectObject(hDCMem, hOld);
BITMAP bmpScreen;
// Get the BITMAP from the HBITMAP
GetObject(hBmp,sizeof(BITMAP),&bmpScreen);
::OpenClipboard(hWnd);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, HBITMAP(hBmp));
CloseClipboard();
Continue reading...