Screen capture of specific window c++
问题 I want to take a screenshot of some specific window (e.g calculator). Here is the code I have written according to this discussion: // Get the window handle of calculator application. HWND hWnd = ::FindWindow(0, _T("Calculator")); RECT r; GetWindowRect(hWnd, &r); int x[2]; int y[2]; x[0] = r.top; x[1] = r.bottom; y[0] = r.left; y[1] = r.right; HDC hScreen = GetWindowDC(hWnd); HDC hDC = CreateCompatibleDC(hScreen); HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, y[1] - y[0], x[1] - x[0]);