MFC 对话框背景

来源:互联网 发布:浙江大学图书馆数据库 编辑:程序博客网 时间:2024/06/05 04:01
1. 增加bitmap资源
   以import方式导入,分配ID
2. 对话框初始化时,加载bitmap
  m_BackgroundBMP.LoadBitmap(IDB_BITMAP_WATER_BLUE_A);
3. 重载OnEraseBkgnd()
      CDialog::OnEraseBkgnd(pDC);


if(!m_BackgroundBMP.m_hObject)
return TRUE;

CRect rect;
GetClientRect(&rect);
CDC dc;
dc.CreateCompatibleDC(pDC);
CBitmap* pOldBmp =dc.SelectObject(&m_BackgroundBMP);
BITMAP bm;
m_BackgroundBMP.GetBitmap(&bm);
pDC->StretchBlt(0, 0, rect.Width(),rect.Height(), &dc, 0, 0, bm.bmWidth, bm.bmHeight,SRCCOPY);

dc.SelectObject(pOldBmp);

return TRUE;
0 0
原创粉丝点击