static void DoScroll( HWND wnd, int dx, int dy, BOOL lock ) /*********************************************************/ { /* scroll 'wnd' by 'dx' and 'dy'. 'lock' says to lock the scrolling on the */ /* bottom and right into the scrolling rectangle */ POINT offset; RECT srect; GetOffset( &offset ); GetScrollBounds( &srect, lock ); dx = AdjustScroll( offset.x, srect.left, srect.right, dx ); dy = AdjustScroll( offset.y, srect.top, srect.bottom, dy ); if( dx != 0 || dy != 0 ) { offset.x += dx; offset.y += dy; SetOffset( offset ); ScrollWindow( wnd, -dx, -dy, NULL, NULL ); if( GetScrollConfig() & SCROLL_HORZ ) { SetScrollPos( wnd, SB_HORZ, offset.x, TRUE ); } if( GetScrollConfig() & SCROLL_VERT ) { SetScrollPos( wnd, SB_VERT, offset.y, TRUE ); } } }
//*************************************************************************** void CBCGPDropDownList::HighlightItem (int nIndex) { ASSERT_VALID (this); CBCGPPopupMenuBar* pMenuBar = GetMenuBar (); ASSERT_VALID (pMenuBar); if (nIndex < 0) { return; } pMenuBar->m_iHighlighted = nIndex; SCROLLINFO scrollInfo; ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_ALL; m_wndScrollBarVert.GetScrollInfo (&scrollInfo); int iOffset = nIndex; int nMaxOffset = scrollInfo.nMax; iOffset = min (max (0, iOffset), nMaxOffset); if (iOffset != pMenuBar->GetOffset ()) { pMenuBar->SetOffset (iOffset); m_wndScrollBarVert.SetScrollPos (iOffset); AdjustScroll (); } }