I'd like to create a bitmap copy of the current contents of my CView, which may or may not be currently visible on the screen. Here is the code I've added to my OnDraw function:
void
MyView::OnDraw
(
CDC* pDC
)
{
... normal processing ...
// Copy the view contents to a bitmap.
CDC dc;
dc.CreateCompatibleDC( pDC );
if ( m_pBitmap != NULL )
{
delete m_pBitmap;
}
m_pBitmap = new CBitmap();
m_pBitmap->CreateCompatibleBitmap( &dc, szView.cx, szView.cy );
CBitmap* pOld = ( CBitmap* )dc.SelectObject( m_pBitmap );
dc.BitBlt( 0, 0, szView.cx, szView.cy, pDC, 0, 0, SRCCOPY );
dc.SelectObject( pOld );
}
But now when I examine the bitmap I can see that there is only 1 bit per pixel. I'm sure I'm missing something, can anyone help?
Thanks, Kevin
The problem was that &dc needed to be changed to pDC in the call to CreateCompatibleBitmap.
Kevin