I appreciate your help.
HDC hDCMem = CreateCompatibleDC(NULL);
HDC hDCMem2 = CreateCompatibleDC(NULL);
CRect rect;
::GetClientRect(hSrcWnd, &rect);
HBITMAP hBmp = NULL;
HBITMAP hBmp2 = NULL;
HDC hDC = ::GetDC(hSrcWnd);
hBmp = CreateCompatibleBitmap(hDC, rect.Width(), rect.Height());
hBmp2 = CreateCompatibleBitmap(hDC, rect.Width() - TOTAL_OFFSETX,
rect.Height() - TOTAL_OFFSETY);
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
HGDIOBJ hOld2 = SelectObject(hDCMem2, hBmp2);
::SendMessage(hSrcWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN |
PRF_CLIENT | PRF_ERASEBKGND );
::BitBlt(hDCMem2, 0,0, rect.Width() - TOTAL_OFFSETX, rect.Height() -
TOTAL_OFFSETY, hDCMem, TOPLEFT_OFFSETX, TOPLEFT_OFFSETY, SRCCOPY);
::ReleaseDC(hSrcWnd, hDC);
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
SelectObject(hDCMem2, hOld2);
DeleteObject(hDCMem2);
::OpenClipboard(hSrcWnd);
EmptyClipboard();
SetClipboardData(CF_BITMAP, hBmp2);
// SetClipboardData(CF_BITMAP, hBmp);
CloseClipboard();
--
jake
What's the relationship between TOTAL_OFFSET[X,Y] and
TOPLEFT_OFFSET[X,Y] ?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
#define TOPLEFT_OFFSETX 12
#define TOPLEFT_OFFSETY 17
#define TOTAL_OFFSETX 70
#define TOTAL_OFFSETY 70
#define WM_HTML_MESSAGE (WM_USER+100)
i appreciate your help.
--
jake
Do you mean CreateCompatibleBitmap returns NULL? What does GetLastError
return right after the call fails?
When you say "bigger", exactly how big? What size is the rectangle when
the call begins to fail?
so please help me figure out how to solve this problem, how to copy the
image into clipboard?
I appreciate your help.
--
jake
Try creating a DIB with CreateDIBSection, rather than a DDB with
CreateCompatibleBitmap. I seem to remember there are limits on how large
a DDB can be.
I appreciate your help.
--
jake
I assume you have studied the documentation for this function, and found
it lacking. Do you have any specific issue that the documentation failed
to clarify for you?