给对话框程序加入背景图片

CPaintDC dc(this); // device context for painting
 CBitmap bmp;
 bmp.LoadBitmap(IDB_BITMAP3);
 // Get the size of the bitmap
 BITMAP bmpInfo;
 bmp.GetBitmap(&bmpInfo);
 // Create an in-memory DC compatible with the
 // display DC we're using to paint
 CDC dcMemory;
 dcMemory.CreateCompatibleDC(&dc);
 // Select the bitmap into the in-memory DC
 CBitmap *pOldBmp=dcMemory.SelectObject(&bmp);
 //Get Client area
 CRect wndRt;
 this->GetClientRect(&wndRt);
 // Stretch and copy the bits from the in-memory DC into the on-
 // screen DC to actually do the painting
 dc.StretchBlt(0, 0, wndRt.Width(), wndRt.Height(), &dcMemory, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, SRCCOPY);
 dcMemory.SelectObject(pOldBmp);
 
在OnPaint里面用,IDB_BITMAP3是你添加的位图ID

你可能感兴趣的:(给对话框程序加入背景图片)