If you add the bitmap as a resource, you can create an instance of the CBitmap class using the resource ID of the bitmap as the image to be loaded. If you want to load a bitmap from a file, you can use the LoadImage API call to load the bitmap from the file. After you load the bitmap, you can use the handle for the image to attach the image to the CBitmap class, like so:
Code:
HBITMAP hBitmap= (HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_sFileName, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
m_bmpBitmap.Attach(hBitmap);
//create a second device context and select the bitmap into it
CDC dcMem;
dcMem.CreateCompatibleDC(dc);
dcMem.SelectObject(&m_bmpBitmap);
//copy the bitmap into the regular display device context
dc->BitBlt(10, 10, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY);
//you can also copy and resize the image
dc->StretchBlt(10, 10, (lRect.Width() - 20), (lRect.Height() -20), &dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);