1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
//hWnd is handle to main window, rcWnd is a RECT containing the dimensions of the main window's client area
ShowWindow(hWnd, SW_HIDE);
HDC hDC = GetDC(hWnd);
FillRect(hDC, &rcWnd, (HBRUSH)(COLOR_WINDOW + 1));
HDC hScreenDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
int nWidth = GetDeviceCaps(hScreenDC, HORZRES);
int nHeight = GetDeviceCaps(hScreenDC, VERTRES);
HDC hCompatible = CreateCompatibleDC(hScreenDC);
HBITMAP hScreenBitmap = CreateCompatibleBitmap(hScreenDC, nWidth, nHeight);
HANDLE hOld = SelectObject(hCompatible, hScreenBitmap);
BitBlt(hCompatible, 0, 0, nWidth, nHeight, hScreenDC, 0, 0, SRCCOPY);
SetStretchBltMode(hDC, HALFTONE);
SelectObject(hCompatible, hOld);
DeleteDC(hCompatible);
DeleteDC(hScreenDC);
//later...
HDC hMemDC = CreateCompatibleDC(hDC);
HANDLE hOld2 = SelectObject(hMemDC, hScreenBitmap);
ShowWindow(hWnd, SW_SHOW);
StretchBlt(hDC, 0, 0, rcWnd.right, rcWnd.bottom, hMemDC, 0, 0, nWidth, nHeight, SRCCOPY);
SelectObject(hMemDC, hOld2);
DeleteDC(hMemDC);
DeleteObject(hScreenDC);
ReleaseDC(hWnd, hScreenDC);
| |