void comboWnd::ensureVisible(int iIndex) { if( m_pOwner->getCurSel() < 0 ) return; m_pLayout->findSelectable(m_pOwner->getCurSel(), false); RECT rcItem = m_pLayout->getItemAt(iIndex)->getPosition(); RECT rcList = m_pLayout->getPosition(); scrollBarUC* pHorizontalScrollBar = m_pLayout->getHorizontalScrollBar(); if( pHorizontalScrollBar && pHorizontalScrollBar->isVisible() ) rcList.bottom -= pHorizontalScrollBar->getFixedHeight(); int iPos = m_pLayout->getScrollPos().cy; if( rcItem.top >= rcList.top && rcItem.bottom < rcList.bottom ) return; int dx = 0; if( rcItem.top < rcList.top ) dx = rcItem.top - rcList.top; if( rcItem.bottom > rcList.bottom ) dx = rcItem.bottom - rcList.bottom; dx += rectHeight(rcList) - rectHeight(rcItem); // 确保显示行在最上显示 scroll(0, dx); }
/*