void AwtScrollPane::SetScrollInfo(int orient, int max, int page, BOOL disableNoScroll) { DTRACE_PRINTLN4("AwtScrollPane::SetScrollInfo %d, %d, %d, %d", orient, max, page, disableNoScroll); SCROLLINFO si; int posBefore; int posAfter; posBefore = GetScrollPos(orient); si.cbSize = sizeof(SCROLLINFO); si.nMin = 0; si.nMax = max; si.fMask = SIF_RANGE; if (disableNoScroll) { si.fMask |= SIF_DISABLENOSCROLL; } if (page > 0) { si.fMask |= SIF_PAGE; si.nPage = page; } ::SetScrollInfo(GetHWnd(), orient, &si, TRUE); // scroll position may have changed when thumb is at the end of the bar // and the page size changes posAfter = GetScrollPos(orient); if (posBefore != posAfter) { PostScrollEvent(orient, SB_THUMBPOSITION, posAfter); } }
void AwtScrollPane::SetScrollInfo(int orient, int max, int page, BOOL disableNoScroll) { DTRACE_PRINTLN4("AwtScrollPane::SetScrollInfo %d, %d, %d, %d", orient, max, page, disableNoScroll); SCROLLINFO si; int posBefore; int posAfter; posBefore = GetScrollPos(orient); si.cbSize = sizeof(SCROLLINFO); si.nMin = 0; si.nMax = max; si.fMask = SIF_RANGE; if (disableNoScroll) { si.fMask |= SIF_DISABLENOSCROLL; } if (page > 0) { si.fMask |= SIF_PAGE; si.nPage = page; } ::SetScrollInfo(GetHWnd(), orient, &si, TRUE); // scroll position may have changed when thumb is at the end of the bar // and the page size changes posAfter = GetScrollPos(orient); if (posBefore != posAfter) { if(max==0 && posAfter==0) { // Caller used nMin==nMax idiom to hide scrollbar. // On the new themes (Windows XP, Vista) this would reset // scroll position to zero ("just inside the range") (6404832). // PostScrollEvent(orient, SB_THUMBPOSITION, posBefore); }else{ PostScrollEvent(orient, SB_THUMBPOSITION, posAfter); } } }
MsgRouting AwtScrollPane::WmHScroll(UINT scrollCode, UINT pos, HWND hScrollPane) { // While user scrolls using tracker, SCROLLINFO.nPos is not changed, SCROLLINFO.nTrackPos is changed instead. int dragP = scrollCode == SB_THUMBPOSITION || scrollCode == SB_THUMBTRACK; int newPos = GetScrollPos(SB_HORZ); if ( dragP ) { SCROLLINFO si; ZeroMemory(&si, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_TRACKPOS; ::GetScrollInfo(GetHWnd(), SB_HORZ, &si); newPos = si.nTrackPos; } PostScrollEvent(SB_HORZ, scrollCode, newPos); return mrConsume; }