It's not related to your question, but there is a conceptual error in your function: when you select a
GDI object, like a bitmap onto a
device context you must keep trace of the previously selected one and restore it, before destroying the device context.
void CPlay::OnBackground(CBitmap* p, CDC* pDC)
{
CDC dcMemory;
BITMAP bm;
dcMemory.CreateCompatibleDC(pDC);
CBitmap *pOriginalBmp = dcMemory.SelectObject(p);
p->GetBitmap(&bm);
pDC->StretchBlt(0, 0, screenX, screenY, &dcMemory, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
dcMemory.SelectObject(pOriginalBmp);
}