| Index: chrome/browser/ui/window_snapshot/window_snapshot_win.cc
|
| ===================================================================
|
| --- chrome/browser/ui/window_snapshot/window_snapshot_win.cc (revision 121842)
|
| +++ chrome/browser/ui/window_snapshot/window_snapshot_win.cc (working copy)
|
| @@ -43,29 +43,36 @@
|
| &hdr);
|
| unsigned char *bit_ptr = NULL;
|
| base::win::ScopedBitmap bitmap(
|
| - CreateDIBSection(mem_hdc.get(),
|
| + CreateDIBSection(mem_hdc,
|
| reinterpret_cast<BITMAPINFO*>(&hdr),
|
| DIB_RGB_COLORS,
|
| reinterpret_cast<void **>(&bit_ptr),
|
| NULL, 0));
|
|
|
| - base::win::ScopedSelectObject select_bitmap(mem_hdc.get(), bitmap);
|
| + base::win::ScopedSelectObject select_bitmap(mem_hdc, bitmap);
|
| // Clear the bitmap to white (so that rounded corners on windows
|
| // show up on a white background, and strangely-shaped windows
|
| // look reasonable). Not capturing an alpha mask saves a
|
| // bit of space.
|
| - PatBlt(mem_hdc.get(), 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
|
| + PatBlt(mem_hdc, 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
|
| WHITENESS);
|
| + // Grab a copy of the window
|
| + // First, see if PrintWindow is defined (it's not in Windows 2000).
|
| + typedef BOOL (WINAPI *PrintWindowPointer)(HWND, HDC, UINT);
|
| + PrintWindowPointer print_window =
|
| + reinterpret_cast<PrintWindowPointer>(
|
| + GetProcAddress(GetModuleHandle(L"User32.dll"), "PrintWindow"));
|
|
|
| - if (snapshot_bounds.origin() != gfx::Point()) {
|
| - BitBlt(mem_hdc.get(),
|
| - 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
|
| - window_hdc,
|
| - snapshot_bounds.x(), snapshot_bounds.y(),
|
| - SRCCOPY);
|
| - } else if (!PrintWindow(window_handle, mem_hdc.get(), 0)) {
|
| - NOTREACHED();
|
| - }
|
| + // If PrintWindow is defined, use it. It will work on partially
|
| + // obscured windows, and works better for out of process sub-windows.
|
| + // Otherwise grab the bits we can get with BitBlt; it's better
|
| + // than nothing and will work fine in the average case (window is
|
| + // completely on screen).
|
| + if (snapshot_bounds.origin() == gfx::Point() && print_window)
|
| + (*print_window)(window_handle, mem_hdc, 0);
|
| + else
|
| + BitBlt(mem_hdc, 0, 0, snapshot_bounds.width(), snapshot_bounds.height(),
|
| + window_hdc, snapshot_bounds.x(), snapshot_bounds.y(), SRCCOPY);
|
|
|
| // We now have a copy of the window contents in a DIB, so
|
| // encode it into a useful format for posting to the bug report
|
|
|