15,979
社区成员
发帖
与我相关
我的任务
分享
#if 1 // simple way, color changed ! bk not move
BOOL cTree::OnEraseBkgnd(CDC* pDC)
{
CRect rc;
GetClientRect(&rc);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
HBITMAP hBmp=(HBITMAP)MemDC.SelectObject(m_bitmap.m_hObject);
pDC->StretchBlt(0,0,rc.Width(),rc.Height(),&MemDC,0,0,320,240,SRCCOPY);
// set back
(HBITMAP)MemDC.SelectObject(hBmp);
// free
DeleteObject(MemDC);
//
return TRUE;
}
//
void cTree::OnPaint()
{
CPaintDC dc(this);
// get size
CRect rc;
GetClientRect(&rc);
// Create a compatible memory DC
CDC memDC;
memDC.CreateCompatibleDC(&dc);
// Select a compatible bitmap into the memory DC
CBitmap bitmap;
bitmap.CreateCompatibleBitmap( &dc, rc.Width(), rc.Height());
HBITMAP oldBmp=(HBITMAP)memDC.SelectObject(&bitmap);
// Let the control draws the tree.
DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0 );
// 'and' to the background,
dc.BitBlt(0,0,rc.Width(),rc.Height(),&memDC,0,0,SRCAND);
// set back
memDC.SelectObject(oldBmp);
// free
DeleteObject(bitmap.m_hObject);
DeleteObject(memDC);
}
#else // scrolled back ground
。。。。。。