BitBlt ignora CAPTUREBLT y parece capturar siempre una copia en caché del objetivo

Estoy tratando de capturar capturas de pantalla usando la función BitBlt. Sin embargo, cada vez que capturo una captura de pantalla, el área que no es cliente NUNCA cambia sin importar lo que haga. Es como si estuviera obteniendo una copia en caché. El área del cliente se captura correctamente.

Si cierro y luego vuelvo a abrir la ventana, y tomo una captura de pantalla, el área no cliente se capturará tal como está. Cualquier captura posterior después de mover / cambiar el tamaño de la ventana no tiene efecto en la captura de pantalla capturada. Nuevamente, el área del cliente será correcta.

Además, la bandera CAPTUREBLT parece no hacer absolutamente nada en absoluto. No noto ningún cambio con o sin él. Aquí está mi código de captura:

QPixmap WindowManagerUtils::grabWindow(WId windowId, GrabWindowFlags flags, int x, int y, int w, int h)
{
    RECT r;

    switch (flags)
    {
        case WindowManagerUtils::GrabWindowRect:
            GetWindowRect(windowId, &r);
            break;
        case WindowManagerUtils::GrabClientRect:
            GetClientRect(windowId, &r);
            break;
        case WindowManagerUtils::GrabScreenWindow:
            GetWindowRect(windowId, &r);
            return QPixmap::grabWindow(QApplication::desktop()->winId(), r.left, r.top, r.right - r.left, r.bottom - r.top);
        case WindowManagerUtils::GrabScreenClient:
            GetClientRect(windowId, &r);
            return QPixmap::grabWindow(QApplication::desktop()->winId(), r.left, r.top, r.right - r.left, r.bottom - r.top);
        default:
            return QPixmap();
    }

    if (w < 0)
    {
        w = r.right - r.left;
    }

    if (h < 0)
    {
        h = r.bottom - r.top;
    }

#ifdef Q_WS_WINCE_WM
    if (qt_wince_is_pocket_pc())
    {
        QWidget *widget = QWidget::find(winId);
        if (qobject_cast<QDesktopWidget*>(widget))
        {
            RECT rect = {0,0,0,0};
            AdjustWindowRectEx(&rect, WS_BORDER | WS_CAPTION, FALSE, 0);
            int magicNumber = qt_wince_is_high_dpi() ? 4 : 2;
            y += rect.top - magicNumber;
        }
    }
#endif

    // Before we start creating objects, let's make CERTAIN of the following so we don't have a mess
    Q_ASSERT(flags == WindowManagerUtils::GrabWindowRect || flags == WindowManagerUtils::GrabClientRect);

    // Create and setup bitmap
    HDC display_dc = NULL;
    if (flags == WindowManagerUtils::GrabWindowRect)
    {
        display_dc = GetWindowDC(NULL);
    }
    else if (flags == WindowManagerUtils::GrabClientRect)
    {
        display_dc = GetDC(NULL);
    }

    HDC bitmap_dc = CreateCompatibleDC(display_dc);
    HBITMAP bitmap = CreateCompatibleBitmap(display_dc, w, h);
    HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap);

    // copy data
    HDC window_dc = NULL;
    if (flags == WindowManagerUtils::GrabWindowRect)
    {
        window_dc = GetWindowDC(windowId);
    }
    else if (flags == WindowManagerUtils::GrabClientRect)
    {
        window_dc = GetDC(windowId);
    }

    DWORD ropFlags = SRCCOPY;
#ifndef Q_WS_WINCE
    ropFlags = ropFlags | CAPTUREBLT;
#endif

    BitBlt(bitmap_dc, 0, 0, w, h, window_dc, x, y, ropFlags);

    // clean up all but bitmap
    ReleaseDC(windowId, window_dc);
    SelectObject(bitmap_dc, null_bitmap);
    DeleteDC(bitmap_dc);

    QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap);

    DeleteObject(bitmap);
    ReleaseDC(NULL, display_dc);

    return pixmap;
}

La mayor parte de este código proviene de la función QWidget :: grabWindow de Qt, ya que quería hacer algunos cambios para que fuera más flexible. La documentación de Qt establece que:

La función grabWindow () toma píxeles de la pantalla, no de la ventana, es decir, si hay otra ventana parcial o totalmente sobre la que usted toma, también obtendrá píxeles de la ventana superior.

Sin embargo, experimento exactamente lo contrario ... independientemente del indicador CAPTUREBLT. He intentado todo lo que puedo pensar ... nada funciona. ¿Algunas ideas?

Respuestas a la pregunta(2)

Su respuesta a la pregunta