2

I'm using BitBlt to get screenshots of windows on a user's desktop. I've found that all works well for windows from most programs. However, BitBlt returns blank pixels for any Office 2013 windows (Word, Powerpoint, etc).

PrintWindow does work for these Office 2013 windows, but it has higher processor overhead. I'd rather use BitBlt if possible.

Any ideas why BitBlt would not work with Office 2013 windows?

Code snippet below.

Thanks

UPDATE: BitBlt(...) returns true. Changing code to capture entire desktop instead of appWin captures the Office 2013 window correctly, see this post. I can capture the whole desktop and extract the desired window. However, this loses one cool thing with the new DWM that allows the software to capture images from windows that are not in the foreground.

Is there a better way to do this that will allow the system to both capture Office 2013 type windows AND capture images from windows not in the foreground?

UPDATE 2: When doing the BitBlt on the appWin, it looks like the first BitBlt gives valid pixel data, but subsequent BitBlts give blank pixels. Not sure why but may be an important data point.

INT texUSize = 1024;
INT texVSize = 1024;

RECT rect;
GetClientRect(appWin, &rect);
INT appW = rect.right - rect.left;
INT appH = rect.bottom - rect.top;

// create BITMAP in memory, write to texture pixels from BITMAP
HDC hdc = GetDC(appWin);
HDC hdc_App = CreateCompatibleDC(hdc);
HDC hdc_Tex = CreateCompatibleDC(hdc);
HBITMAP hbmp_App = CreateCompatibleBitmap(hdc, appW, appH);
HBITMAP hbmp_Tex = CreateCompatibleBitmap(hdc, texUSize, texVSize);
HBITMAP hbmp_AppOld = (HBITMAP)SelectObject(hdc_App, hbmp_App);
HBITMAP hbmp_TexOld = (HBITMAP)SelectObject(hdc_Tex, hbmp_Tex);

// Due to the new Desktop Window Manager, Windows Vista and Windows 7 can simply BitBlt the app window
// Windows XP has issues with BitBlt if app window is covered by a different window
if (false)//bVista7 || (GetForegroundWindow() == appWin))
{
    appOutputDebugStringf(TEXT("-- bitblting"));
    BitBlt(hdc_App, 0, 0, appW, appH, hdc, 0, 0, SRCCOPY);
}
else
{
    appOutputDebugStringf(TEXT("-- printwindow"));
    PrintWindow(appWin, hdc_App, NULL);
}
Community
  • 1
  • 1
Daktor
  • 41
  • 2

0 Answers0