Using the function
OnEraseBkgnd(CDC* pDC)
I write on the CDialog derived class, a background image that fills the screen.
Then inside the OnPaint I have the following code that is executed only once (for the 1st time OnPaint is called).
    GetInfoBarRect(&m_InfoBarRect);
    m_InfoBarBGBitmap.CreateCompatibleBitmap(&dc, m_InfoBarRect.Width(), m_InfoBarRect.Height() );
    bdc.CreateCompatibleDC(&dc);    
    pOldBitmap = bdc.SelectObject(&m_InfoBarBGBitmap);
    bdc.BitBlt (m_InfoBarRect.left, m_InfoBarRect.top, m_InfoBarRect.Width(),m_InfoBarRect.Height(), &dc, 0, 0, SRCCOPY);
    CImage image;
    image.Attach(m_InfoBarBGBitmap);
    image.Save(_T("C:\\test.bmp"), Gdiplus::ImageFormatBMP);
    bdc.SelectObject(pOldBitmap);   
    bdc.DeleteDC();
The above code, copies the m_InfoBarRect part of the screen in the memory CBitmap.
Intead of having the part of the background image, I only get a blank filled rectangle with correct dimensions.
Is there something wrong with my code ?