// 鼠标滚轮消息处理 BOOL CDlgPopup::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { ScreenToClient(&pt); zDelta /= WHEEL_DELTA; UINT nFlag = (zDelta>0) ? SB_LINEUP : SB_LINEDOWN; zDelta = abs(zDelta); BOOL bResponse = FALSE; for(short i = 0; i < zDelta; i++) { if (m_pControl && m_pControl->OnScroll(TRUE, nFlag, pt)) { bResponse = TRUE; continue; }else { // 窗口控件事件处理 for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase && pControlBase->OnScroll(TRUE, nFlag, pt)) { bResponse = TRUE; break; } } } } return bResponse; }
// 滚动事件处理 BOOL CControlBase::OnScroll(BOOL bVertical, UINT nFlags, CPoint point) { if(!m_bIsVisible || !m_bRresponse) return false; BOOL bRresponse = false; if(m_pControl) { // 判断当前活动控件 if(m_pControl->PtInRect(point) && m_pControl->OnCheckMouseResponse(nFlags, point)) { if(m_pControl->OnScroll(bVertical, nFlags, point)) { return true; } return false; } } if(PtInRect(point)) { // 在此控件范围内,先判断此控件是否能处理 if(OnControlScroll(bVertical, nFlags, point)) { return true; }else { // 此控件没有处理,则遍历子控件看是否能处理 for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase && pControlBase->PtInRect(point)) { if(pControlBase->OnScroll(bVertical, nFlags, point)) { return true; } } } } } return false; }