you can do it as following:
//
CBitmap bmp;
bmp.CreateCompatibleBitmap(&dc,100,100);
CDC MemDC;
MemDC.CreateCompatibleDC(&dc,100,100);
pOldBmp = MemDC.SelectObject(&bmp);
MemDC.FillSolidRect(&rect,color);
//
//Draw what you want
//
dc.bitblt(0,0,100,100,&MemDC,0,0,SRCCOPY);
//
That's all.if you have some problem about the function.
you can see the msdn help.