Bitmap backgrounds This works on CDialog and CView. CMainFrame requires additional steps not described here. See "The MFC Answer Book". CDialog and CView will experience some screen flicker, if you have dynamically moving controls. 1. Import a bitmap resource (Import a resource is something you learned in a previous lab) 2. Add a CBitmap class member 3. Go to your initialization routine, e.g. OnInitialUpdate(), OnInitDialog() 4. In your initialization routine, direct your CBitmap variable to call LoadBitmap(). 5. In ClassWizard, add a handler for WM_ERASEBKGND 6. Goto OnEraseBkgnd() 7. Create a copy of pDC, like so CDC dc; dc.CreateCompatibleDC(pDC); The second dc allows double buffering. Double buffering is a technique used to prevent screen flicker. Screen flicker is caused by sending multiple writes to the same pixels in the dc. In double buffering, we use an off-screen memory dc to which we send all the writes. When we're finished drawing to the memory dc, we copy the results by BitBlt() to the screen dc. 8. Next call SelectObject() on your CBitmap, but save the previous CBitmap, e.g. CBitmap* pOldBitmap = dc.SelectObject(&m_bitmap); The dc now contains your bitmap. Be aware that if you make any changes to your dc, the changes will appear in your m_bitmap. 9. Now BitBlt() from your off screen dc to the real dc, e.g. pDC->BitBlt (xo, yo, clientRect.Width(), clientRect.Height(), &memdc, 0, 0, SRCCOPY); 10. As a form of clean up, call SelectObject with the original CBitmap, e.g. dc.SelectObject(pOldBitmap); All the code I've seen, has this function call at the end. I think I saw on J. Newcomer's page an explanation that failure to make this function call will result in a memory leak on the GDI heap. 11. comment out the call to the base class's EraseBkgnd(). 12. return TRUE. TRUE indicates that the background was erased. 13. If your bitmap isn't big enough to cover the background, you'll have to FillRect() areas beyond the bitmap. 14. Optional: Alternatively, you can tile your bitmap to fill the entire background. If you want to do tiling, you'll need bitmap dimensions. Call GetBitmap() to retrieve a structure containing the bitmap size. 15. Optional: If you want a stretch-to-fit bitmap, try using StretchBlt()