Solutia: Se poate rezolva simplu adaugand flag-ul CAPTUREBLT la apelul functiei BitBlt.
Exemplu:
Code: Select all
BOOL CaptureScreen(HBITMAP& hBitmap)
{
HDC hDCScreen = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
const int cx = ::GetDeviceCaps(hDCScreen, HORZRES);
const int cy = ::GetDeviceCaps(hDCScreen, VERTRES);
HDC hDCMem = ::CreateCompatibleDC(hDCScreen);
hBitmap = ::CreateCompatibleBitmap(hDCScreen, cx, cy);
HBITMAP hBmpOld = (HBITMAP)::SelectObject(hDCMem, hBitmap);
// Note: CAPTUREBLT flag is required to capture layered windows
DWORD dwRop = SRCCOPY | CAPTUREBLT;
BOOL bRet = ::BitBlt(hDCMem, 0, 0, cx, cy, hDCScreen, 0, 0, dwRop);
::SelectObject(hDCMem, hBmpOld);
::DeleteDC(hDCMem);
::DeleteDC(hDCScreen);
return bRet;
}
<< Back to Windows API Index