dmanglik
May 20th, 1999, 06:38 AM
I try to capture the client window of an application using the following code sequence :
BOOL TakeSnapShot(HWND hWnd, long wid, long ht)
//hWnd is the window handle of the application window whose client area is to be captured
//'wid' and 'ht' are the width and height of the client area of the applicaiotn window.
{
CWnd *pWnd = new CWnd;
if (!pWnd->Attach(hWnd))
return FALSE;
CDC *dc = pWnd->GetDC(); //Get the DC of the client window of application
CDC memDC;
memDC.CreateCompatibleDC(dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(dc, wid, ht);
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
memDC.BitBlt(0, 0, wid, ht, &memDC, 0, 0, SRCCOPY);
pWnd->Detach();
delete pWnd;
memDC.SelectObject(pOldBitmap);
//Rest of the code to get the bitmap
}
The problem I am getting is that if there is any other window (such as Task Manager) sitting on top of the client area of the application window (whose snapshot is to be taken), the final snapshot bitmap shows these other windows as well.
Does this problem occur because of some limitaion of 'BitBlt' ??
How can I prevent these other windows from coming into the way ??
Any help would be highly appreciated.
Thanks,
Deep
BOOL TakeSnapShot(HWND hWnd, long wid, long ht)
//hWnd is the window handle of the application window whose client area is to be captured
//'wid' and 'ht' are the width and height of the client area of the applicaiotn window.
{
CWnd *pWnd = new CWnd;
if (!pWnd->Attach(hWnd))
return FALSE;
CDC *dc = pWnd->GetDC(); //Get the DC of the client window of application
CDC memDC;
memDC.CreateCompatibleDC(dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(dc, wid, ht);
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
memDC.BitBlt(0, 0, wid, ht, &memDC, 0, 0, SRCCOPY);
pWnd->Detach();
delete pWnd;
memDC.SelectObject(pOldBitmap);
//Rest of the code to get the bitmap
}
The problem I am getting is that if there is any other window (such as Task Manager) sitting on top of the client area of the application window (whose snapshot is to be taken), the final snapshot bitmap shows these other windows as well.
Does this problem occur because of some limitaion of 'BitBlt' ??
How can I prevent these other windows from coming into the way ??
Any help would be highly appreciated.
Thanks,
Deep