You should try to understand the tutuorials/references, instead of copy-n-pasting chunks of code from them.
Here is the OnPaint() of the attached code:
Code:
// our paint DC
CPaintDC dc(this);
// load up our bitmap into bmME
CBitmap cbmME;
// for resources use:
// cbmME.LoadBitmap(IDB_BITMAP_ME);
// for files use this:
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, "avatar.bmp", IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hBmp == NULL)
{
TRACE0("::LoadImage('avator.bmp') failed");
return;
}//if
cbmME.Attach(hBmp);
// use our hidden static frame for bitmap placement
CRect framerect;
GetDlgItem(IDC_STATIC_ME)->GetWindowRect(framerect);
ScreenToClient(framerect);
// create a memory DC
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
// select the bitmap into the memory dc
CBitmap *old = dcMem.SelectObject(&cbmME);
// get the raw bitmap for access to its attributes
BITMAP bm;
cbmME.GetBitmap(&bm);
// blit it
dc.BitBlt(framerect.left, framerect.top,
bm.bmWidth, bm.bmHeight,
&dcMem, 0, 0, SRCCOPY);
dcMem.SelectObject(old);
::DeleteObject(hBmp);
CDialog::OnPaint();
gg