user10072928
user10072928

Reputation:

BitBlt drawing black squares (Windows 7)

I am creating a desktop virtualization capture driver. Basically, the driver opens a virtualized desktop and captures the screen into a bitmap buffer and sends it to the client which then gets drawn onto their screen (GetDIBits/SetDIBits).

The problem is, the problem is with PrintWindow in Windows 7. In Windows 8.1+ there was an extra flag added to this function PW_RENDERFULLCONTENT which draws the entire desktop in one go, however in Windows 7 this flag doesn't exist.

My question is, how can I properly emulate this flags behaviour in Windows 7 such that all windows are drawn properly. For example, without this flag, when the host machine opens Chrome in their virtualized desktop, the PrintWindow call fails since Chrome is rendered with Aura and PrintWindow isn't built to handle this functionality, hence chrome is drawn with a black square in the middle:

image

Upvotes: 0

Views: 1235

Answers (1)

Jerry Coffin
Jerry Coffin

Reputation: 490108

A quick test indicates the capturing the correct area of the screen produces correct results. Code like this:

memDC.BitBlt(0, 0, src_rect.Width(), src_rect.Height(), 
             &screen, 
             src_rect.TopLeft().x, src_rect.TopLeft().y, 
             SRCCOPY | CAPTUREBLT);

...was adequate to capture a picture of your question being displayed in Chrome:

enter image description here

CAPTUREBLT is recommended, but doesn't seem to be truly necessary for this particular case. This code is using MFC's wrapper around BitBlt, but that shouldn't change anything significant compared to calling BitBlt directly.

Upvotes: 1

Related Questions