分类:
2008-04-07 10:59:27
方法一
OnEraseBkgnd(CDC* pDC)
{
// 设置画刷为希望的背景
CDC backBmp;
backBmp.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BG);
CBrush m_brushBackground;
m_brushBackground.CreatePatternBrush(&bitmap); ///创建位图画刷
CBrush* pOldMemDCBrush=pDC->SelectObject(&m_brushBackground);
pDC->PatBlt(0,0,m_ScrollRect.Width(),m_ScrollRect.Height(),PATCOPY);
pDC->SelectObject(pOldMemDCBrush);
return TRUE;
}
方法二
OnEraseBkgnd(CDC* pDC)
{
CBitmap m_pMap;
m_pMap.LoadBitmap(IDB_BG);
CRect rect;
GetClientRect(&rect);
BITMAP bm;
CDC dcMem;
m_pMap.GetObject(sizeof(BITMAP),&bm);
dcMem.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = dcMem.SelectObject(&m_pMap);
for (register int nX=0;nX
dcMem.SelectObject(pOldBitmap);
return TRUE;
}
方法三
OnEraseBkgnd(CDC* pDC)
{
CBitmap bmp;
bmp.LoadBitmap(IDB_BG); ///加载位图
CBrush m_brushBackground;
m_brushBackground.CreatePatternBrush(&bmp); ///创建位图画刷
CRect rect;
GetClientRect(&rect);
pDC->FillRect(rect,&m_brushBackground); //用背景画填充区域
return TRUE;
}