扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:整理 来源:互联网 2007年10月16日
关键字:
/*************************************************************************/ /************************************************************************/ /* 宏功能: 界面刷新时仅刷新指定控件以外的空白区域;可有效避免窗口闪烁 /* 使用于: WM_ERASEBKGND 消息处理函数 OnEraseBkgnd(); /************************************************************************/ #define ERASE_BKGND_BEGIN \ CRect bgRect;\ GetWindowRect(&bgRect);\ CRgn bgRgn;\ bgRgn.CreateRectRgnIndirect(bgRect); //#define ERASE_BKGND_BEGIN // Marco parameter 'IDC' specifies the identifier of the control #define ADD_NOERASE_CONTROL(IDC)\ {\ CRect controlRect;\ GetDlgItem(IDC)->GetWindowRect(&controlRect);\ CRgn controlRgn;\ controlRgn.CreateRectRgnIndirect(controlRect);\ if(bgRgn.CombineRgn(&bgRgn, &controlRgn, RGN_XOR)==ERROR)\ return false;\ } // Marco parameter 'noEraseRect' specifies a screen coordinates based RECT, // which needn't erase. #define ADD_NOERASE_RECT(noEraseRect)\ {\ CRgn noEraseRgn;\ noEraseRgn.CreateRectRgnIndirect(noEraseRect);\ if(bgRgn.CombineRgn(&bgRgn, &noEraseRgn, RGN_XOR)==ERROR)\ return false;\ } // Marco parameter 'pDC' is a kind of (CDC *) type. // Marco parameter 'clBrushColor' specifies the color to brush the area. #define ERASE_BKGND_END(pDC, clBrushColor)\ CBrush brush;\ brush.CreateSolidBrush(clBrushColor);\ CPoint saveOrg = (pDC)->GetWindowOrg();\ (pDC)->SetWindowOrg(bgRect.TopLeft());\ (pDC)->FillRgn(&bgRgn, &brush);\ (pDC)->SetWindowOrg(saveOrg);\ brush.DeleteObject();\ //#define ERASE_BKGND_END /*************************************************/ |
BOOL CMyWnd::OnEraseBkgnd(CDC* pDC) { ERASE_BKGND_BEGIN; ADD_NOERASE_RGN(IDC_BUTTON2); ADD_NOERASE_RGN(IDC_BUTTON1); ADD_NOERASE_RGN(IDC_LIST_STAT); ERASE_BKGND_END(pDC, GetSysColor(COLOR_3DFACE)); return false; } |
/* * No further full-erasing is required, * to prevent screen flashing caused by background erase and view repaint. * Only erase the blank area. */ BOOL CExListCtrl::OnEraseBkgnd(CDC* pDC) { //compute the holding-data-items area of this list control CRect rect; CPoint dataRgnTopLeftPoint; CPoint dataRgnBottomRightPoint; GetItemPosition(0 , &dataRgnTopLeftPoint); GetItemPosition(GetItemCount() , &dataRgnBottomRightPoint); if(!GetHeaderCtrl()->GetItemRect(GetHeaderCtrl()->GetItemCount()-1, rect)) return CListCtrl::OnEraseBkgnd(pDC); dataRgnBottomRightPoint.x = rect.right; rect.SetRect(dataRgnTopLeftPoint, (CPoint)(dataRgnBottomRightPoint - CPoint(2,2))); ClientToScreen(dataRgnRect); //compute and erase the blank area. Using the Marco. ERASE_BKGND_BEGIN; ADD_NOERASE_RECT(dataRgnRect); ERASE_BKGND_END(pDC, GetBkColor()); return false; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者