MFC 添加背景图片

           CPaintDC dc(this);
CBitmap m_bitmap;
m_bitmap.LoadBitmap(IDB_BITMAP2);
CDC memdc;
memdc.CreateCompatibleDC(&memdc);
memdc.SelectObject(&m_bitmap);
int Width, Height;
BITMAP bmp;
m_bitmap.GetBitmap(&bmp);
Width = bmp.bmWidth;
Height = bmp.bmHeight;
CRect rect;
this->GetClientRect(&rect);
dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memdc, 0, 0, Width, Height, SRCCOPY);
memdc.DeleteDC();
::DeleteObject(&m_bitmap);

猜你喜欢

转载自blog.csdn.net/syb198810/article/details/80721672