OpenGL to bitmap not working on Windows 10

My code captures a window to the Clipboard as a bmp that I can paste into many other programs. This works fine if the window has only simple graphics, but for an OpenGL window, when I paste the bmp all I get is an empty frame when running Windows 10.

The problem did not show up under Windows XP and 7, so it looks like a W10 problem. Here is the code I use to do the capture:

void CmyOGLView::makeBitMap()
{
CBitmap BitmapClip; // taken from Young, page 1105
CClientDC ClientDC (this);
CDC MemDC;
RECT Rect;

GetClientRect( &Rect );
BitmapClip.CreateCompatibleBitmap
	( &ClientDC,
	Rect.right - Rect.left,
	Rect.bottom - Rect.top);
MemDC.CreateCompatibleDC( &ClientDC );
MemDC.SelectObject( &BitmapClip );

MemDC.BitBlt
	(0,
	0,
	Rect.right - Rect.left,
	Rect.bottom - Rect.top,
	&ClientDC,
	0,
	0,
	SRCCOPY  );

::CloseClipboard();
if ( !OpenClipboard() )
	return;

HANDLE WH;
BOOL WB;

WB = ::EmptyClipboard();
WH = ::SetClipboardData( CF_BITMAP, BitmapClip.m_hObject );
BitmapClip.Detach();
::CloseClipboard();	

}

Can anyone figure out why the bitmap is not captured in W10? The return values of WH and WB look fine.

Was the DWM disabled on the Windows 7 machine it worked on? This may be a DWM problem rather than a Windows 10 problem, and if so, it would also be expected to fail on 8 and 8.1 as they also no longer allow the DWM to be disabled.

I never touched DWM, so I can’t say. It worked on every W7 machine out there, though, and also on XP. What’s weird is that the same code can save ordinary graphics windows bitmaps just fine. But not from an OpenGL window. Is there any plausible reason for that?

How can I test W10 for a DWM problem?

Because OpenGL isn’t ordinary graphics.

Seriously - do you have access to a Windows 7 machine you can test on? I don’t mean a VM, I mean an actual physical Windows 7 machine.

Yes, I have tested the same program, same version, on a native W7 PC, and the bitmap copy and paste work perfectly.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.