0
点赞
收藏
分享

微信扫一扫

对话框加载bmp为背景

_刘彦辉 2022-12-22 阅读 113


void CXXXDlg::OnPaint()
{
// CPaintDC dc(this); // device context for painting
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BG);//IDB_BG为资源文件添加的BMP图像 ID,图像尺寸应该与对话框大小一致(system 12,1:2)
BITMAP bitmap;
bmpBackground.GetBitmap(&bitmap);
CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,
bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);
}



还有很多方法,自己编写一个类实现也可以。

举报

相关推荐

0 条评论