15,979
社区成员
发帖
与我相关
我的任务
分享
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);
}
// CustomDraw uses 2 buffers = LVS_EX_DOUBLEBUFFER
void CReportCtrl::OnPaint()
{
#define HEAD 24
#if 1 //
CPaintDC dc(this); // device context for painting
// 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 );
#if 0 // to see
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP,(HBITMAP)bitmap);
CloseClipboard();
#endif
// to dc ! bitmap without HeaderCtrl !
dc.BitBlt(0,HEAD,rc.Width(),rc.Height(),&memDC,0,HEAD,SRCCOPY);
// set back
memDC.SelectObject(oldBmp);
// free
DeleteObject(bitmap.m_hObject);
DeleteObject(memDC);
#else
CListCtrl::OnPaint();// for painting messages
#endif
}