先在资源里导入你的<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); }
加载一张bmp图片作为MFC对话框的背景
最新推荐文章于 2023-09-08 16:45:34 发布