void DrawBitmap(CRect rcItem,UINT IDResource)
{
CDC *pDC=GetDC();
CBitmap bmp;
if (bmp.LoadBitmap(IDResource))
{
// Get the size of the bitmap.
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
// Create an in-memory device context compatible with the
// display device context that is used to paint.
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
// Select the bitmap into the in-memory device context.
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
// Find a center point for the bitmap in the client area.
int nX = rcItem.left;
int nY = rcItem.top;
// Copy the bits from the in-memory device context to the on-
// screen device context to do the painting. Use the computed center
// point for the target offset.
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
}
};