void CControlBase::SetUpdate(BOOL bUpdate, COLORREF clr/* = 0*/) { m_bUpdate = bUpdate; for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase) { pControlBase->SetUpdate(bUpdate, clr); } } }
// 重置控件 void CDlgPopup::ResetControl() { for (size_t i = 0; i < m_vecArea.size(); i++) { CControlBase * pControlBase = m_vecArea.at(i); if (pControlBase) { pControlBase->SetUpdate(FALSE);//, m_clrBK); } } for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase) { pControlBase->SetUpdate(FALSE);//, m_clrBK); } } InvalidateRect(NULL); }
LRESULT CDlgPopup::OnControlUpdate(CRect rcUpdate, BOOL bUpdate, CControlBase *pUpdateControlBase) { if(pUpdateControlBase == NULL) return 0; if(bUpdate) { pUpdateControlBase->SetUpdate(FALSE); } CRect rcAllUpDate = rcUpdate; if(m_bInit) { BOOL bFind = false; for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase) { if(bFind) { if (pControlBase->GetVisible() && !(pControlBase->GetRect() & rcUpdate).IsRectEmpty()) { rcAllUpDate |= pControlBase->GetRect(); pControlBase->SetUpdate(FALSE); } } else if(pControlBase == pUpdateControlBase) { bFind = true; } } } } if(GetSafeHwnd()) { InvalidateRect(&rcAllUpDate); } return 0L; };
// 控件界面刷新 LRESULT CDuiPanel::OnControlUpdate(CRect rcUpdate, BOOL bUpdate, CControlBase *pUpdateControlBase) { if(pUpdateControlBase == NULL) return 0; if(bUpdate) { pUpdateControlBase->SetUpdate(FALSE); } int nVirtualTop = 0; if(m_nVirtualHeight > m_rc.Height()) { // 计算显示位置 CDuiScrollVertical* pScrollV = (CDuiScrollVertical*)m_pControScrollV; int nCurPos = pScrollV->GetScrollCurrentPos(); // 当前top位置 int nMaxRange = pScrollV->GetScrollMaxRange(); nVirtualTop = (nMaxRange > 0) ? nCurPos*(m_nVirtualHeight-m_rc.Height())/nMaxRange : 0; // 当前显示的是虚拟图片中什么位置开始的图片 } int nVirtualLeft = 0; if(m_nVirtualWidth > m_rc.Width()) { // 计算显示位置 CDuiScrollHorizontal* pScrollH = (CDuiScrollHorizontal*)m_pControScrollH; int nCurPosH = pScrollH->GetScrollCurrentPos(); // 当前top位置 int nMaxRangeH = pScrollH->GetScrollMaxRange(); nVirtualLeft = (nMaxRangeH > 0) ? nCurPosH*(m_nVirtualLeft-m_rc.Width())/nMaxRangeH : 0; // 当前显示的是虚拟图片中什么位置开始的图片 } CRect rcAllUpDate = rcUpdate; if(m_bInit) { BOOL bFind = false; for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase) { if(bFind) { if (pControlBase->GetVisible() && !(pControlBase->GetRect() & rcUpdate).IsRectEmpty()) { rcAllUpDate |= pControlBase->GetRect(); pControlBase->SetUpdate(FALSE); } } else if(pControlBase == pUpdateControlBase) { bFind = true; } } } } // 按照滚动位置修改更新区域 rcAllUpDate.OffsetRect(-nVirtualLeft, -nVirtualTop); rcAllUpDate |= m_rc; InvalidateRect(&rcAllUpDate); return 0L; };