老问题:独占模式下到底有没有办法拷屏?
不是让用户通过设定取消独占模式,而是就是在独占模式下用程序拷屏。
下面这样的代码显然是不行的,我看到N年前就有人问这个,现在有没有人解决这个问题啊?
// create a DC for the screen and create
// a memory DC compatible to screen DC
hScrDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
hMemDC = CreateCompatibleDC(hScrDC);
// create a bitmap compatible with the screen DC
hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight);
// select new bitmap into memory DC
hOldBitmap = (HBITMAP) SelectObject(hMemDC, hBitmap);
// bitblt screen DC to memory DC
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
// draw mouse
POINT pt;
GetCursorPos(&pt);
DrawIconEx(hMemDC, pt.x-10, pt.y-10, hCursor, 0, 0, 0, NULL, DI_NORMAL);
// select old bitmap back into memory DC and get handle to
// bitmap of the screen
hBitmap = (HBITMAP) SelectObject(hMemDC, hOldBitmap);
// Copy the bitmap data into the provided BYTE buffer
GetDIBits(hScrDC, hBitmap, 0, nHeight, pData, pHeader, DIB_RGB_COLORS);
// clean up
DeleteDC(hScrDC);
DeleteDC(hMemDC);
// return handle to the bitmap
return hBitmap;