加载一张bmp图片作为MFC对话框的背景

先在资源里导入你的<a target=_blank target="_blank" class="inner-link decor-none" href="http://zhidao.baidu.com/search?word=%E4%BD%8D%E5%9B%BE&fr=qb_search_exp&ie=utf8" rel="nofollow" style="color: rgb(45, 100, 179); text-decoration: none;">位图</a>,分配好ID号;
在OnPaint()函数中:
if (IsIconic())
   {……}
   else
   {
       //CDialog::OnPaint();把这个注释掉,不调用<a target=_blank target="_blank" class="inner-link decor-none" href="http://zhidao.baidu.com/search?word=%E5%9F%BA%E7%B1%BB&fr=qb_search_exp&ie=utf8" rel="nofollow" style="color: rgb(45, 100, 179); text-decoration: none;">基类</a>的OnPaint()

       CPaintDC dc(this);

       CDC memdc;
       memdc.CreateCompatibleDC(&dc);//创建兼容DC

       CBitmap bkg;
       bkg.LoadBitmap(这里写你导入<a target=_blank target="_blank" class="inner-link decor-none" href="http://zhidao.baidu.com/search?word=%E4%BD%8D%E5%9B%BE&fr=qb_search_exp&ie=utf8" rel="nofollow" style="color: rgb(45, 100, 179); text-decoration: none;">位图</a>的ID号);//载入<a target=_blank target="_blank" class="inner-link decor-none" href="http://zhidao.baidu.com/search?word=%E4%BD%8D%E5%9B%BE&fr=qb_search_exp&ie=utf8" rel="nofollow" style="color: rgb(45, 100, 179); text-decoration: none;">位图</a>

       BITMAP bkginfo;
       bkg.GetBitmap(&bkginfo);//获取位图信息

       memdc.SelectObject(&bkg);

       RECT rect;
       GetWindowRect(&rect);//获取对话框信息

       dc.StretchBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&memdc,0,0,bkginfo.bmWidth,bkginfo.bmHeight,SRCCOPY);
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值