DWORD APIENTRY NtUserShowScrollBar(HWND hWnd, int nBar, DWORD bShow) { PWND Window; DECLARE_RETURN(DWORD); DWORD ret; USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserShowScrollBar\n"); UserEnterExclusive(); if (!(Window = UserGetWindowObject(hWnd))) { RETURN(0); } UserRefObjectCo(Window, &Ref); ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow, (nBar == SB_HORZ) ? 0 : bShow); UserDerefObjectCo(Window); RETURN(ret); CLEANUP: TRACE("Leave NtUserShowScrollBar, ret%lu\n", _ret_); UserLeave(); END_CLEANUP; }
static DWORD FASTCALL co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { /* * Update the scrollbar state and set action flags according to * what has to be done graphics wise. */ LPSCROLLINFO Info; PSCROLLBARINFO psbi; UINT new_flags; INT action = 0; PSBDATA pSBData; DWORD OldPos = 0; BOOL bChangeParams = FALSE; /* Don't show/hide scrollbar if params don't change */ UINT MaxPage; int MaxPos; ASSERT_REFS_CO(Window); if(!SBID_IS_VALID(nBar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %d", nBar); return FALSE; } if(!co_IntCreateScrollBars(Window)) { return FALSE; } if (lpsi->cbSize != sizeof(SCROLLINFO) && lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_PREVIOUSPOS)) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } psbi = IntGetScrollbarInfoFromWindow(Window, nBar); Info = IntGetScrollInfoFromWindow(Window, nBar); pSBData = IntGetSBData(Window, nBar); /* Set the page size */ if (lpsi->fMask & SIF_PAGE) { if (Info->nPage != lpsi->nPage) { Info->nPage = lpsi->nPage; pSBData->page = lpsi->nPage; bChangeParams = TRUE; } } /* Set the scroll pos */ if (lpsi->fMask & SIF_POS) { if (Info->nPos != lpsi->nPos) { OldPos = Info->nPos; Info->nPos = lpsi->nPos; pSBData->pos = lpsi->nPos; bChangeParams = TRUE; } } /* Set the scroll range */ if (lpsi->fMask & SIF_RANGE) { if (lpsi->nMin > lpsi->nMax) { Info->nMin = lpsi->nMin; Info->nMax = lpsi->nMin; pSBData->posMin = lpsi->nMin; pSBData->posMax = lpsi->nMin; bChangeParams = TRUE; } else if (Info->nMin != lpsi->nMin || Info->nMax != lpsi->nMax) { Info->nMin = lpsi->nMin; Info->nMax = lpsi->nMax; pSBData->posMin = lpsi->nMin; pSBData->posMax = lpsi->nMax; bChangeParams = TRUE; } } /* Make sure the page size is valid */ MaxPage = abs(Info->nMax - Info->nMin) + 1; if (Info->nPage > MaxPage) { pSBData->page = Info->nPage = MaxPage; } /* Make sure the pos is inside the range */ MaxPos = Info->nMax + 1 - (int)max(Info->nPage, 1); ASSERT(MaxPos >= Info->nMin); if (Info->nPos < Info->nMin) { pSBData->pos = Info->nPos = Info->nMin; } else if (Info->nPos > MaxPos) { pSBData->pos = Info->nPos = MaxPos; } /* * Don't change the scrollbar state if SetScrollInfo is just called * with SIF_DISABLENOSCROLL */ if (!(lpsi->fMask & SIF_ALL)) { //goto done; return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; } /* Check if the scrollbar should be hidden or disabled */ if (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL)) { new_flags = Window->pSBInfo->WSBflags; if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0))) { /* Hide or disable scroll-bar */ if (lpsi->fMask & SIF_DISABLENOSCROLL) { new_flags = ESB_DISABLE_BOTH; bChangeParams = TRUE; } else if ((nBar != SB_CTL) && bChangeParams) { action = SA_SSI_HIDE; } } else /* Show and enable scroll-bar only if no page only changed. */ if (lpsi->fMask != SIF_PAGE) { new_flags = ESB_ENABLE_BOTH; if ((nBar != SB_CTL) && bChangeParams) { action |= SA_SSI_SHOW; } } if (Window->pSBInfo->WSBflags != new_flags) /* Check arrow flags */ { Window->pSBInfo->WSBflags = new_flags; action |= SA_SSI_REPAINT_ARROWS; } } //done: if ( action & SA_SSI_HIDE ) { co_UserShowScrollBar(Window, nBar, FALSE, FALSE); } else { if ( action & SA_SSI_SHOW ) if ( co_UserShowScrollBar(Window, nBar, TRUE, TRUE) ) return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; /* SetWindowPos() already did the painting */ if (bRedraw) { // FIXME: Arrows and interior. RECTL UpdateRect = psbi->rcScrollBar; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } // FIXME: Arrows /* else if( action & SA_SSI_REPAINT_ARROWS ) { RECTL UpdateRect = psbi->rcScrollBar; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } */ } /* Return current position */ return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; }
static DWORD FASTCALL co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { /* * Update the scrollbar state and set action flags according to * what has to be done graphics wise. */ LPSCROLLINFO Info; PSCROLLBARINFO psbi; /* UINT new_flags;*/ BOOL bChangeParams = FALSE; /* don't show/hide scrollbar if params don't change */ ASSERT_REFS_CO(Window); if(!SBID_IS_VALID(nBar)) { EngSetLastError(ERROR_INVALID_PARAMETER); ERR("Trying to set scrollinfo for unknown scrollbar type %d", nBar); return FALSE; } if(!co_IntCreateScrollBars(Window)) { return FALSE; } if (lpsi->cbSize != sizeof(SCROLLINFO) && lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) { EngSetLastError(ERROR_INVALID_PARAMETER); return 0; } psbi = IntGetScrollbarInfoFromWindow(Window, nBar); Info = IntGetScrollInfoFromWindow(Window, nBar); /* Set the page size */ if (0 != (lpsi->fMask & SIF_PAGE)) { if (Info->nPage != lpsi->nPage) { Info->nPage = lpsi->nPage; bChangeParams = TRUE; } } /* Set the scroll pos */ if (0 != (lpsi->fMask & SIF_POS)) { if (Info->nPos != lpsi->nPos) { Info->nPos = lpsi->nPos; } } /* Set the scroll range */ if (0 != (lpsi->fMask & SIF_RANGE)) { /* Invalid range -> range is set to (0,0) */ if (lpsi->nMin > lpsi->nMax || 0x80000000 <= (UINT)(lpsi->nMax - lpsi->nMin)) { Info->nMin = 0; Info->nMax = 0; bChangeParams = TRUE; } else if (Info->nMin != lpsi->nMin || Info->nMax != lpsi->nMax) { Info->nMin = lpsi->nMin; Info->nMax = lpsi->nMax; bChangeParams = TRUE; } } /* Make sure the page size is valid */ if (Info->nMax - Info->nMin + 1 < Info->nPage) { Info->nPage = Info->nMax - Info->nMin + 1; } /* Make sure the pos is inside the range */ if (Info->nPos < Info->nMin) { Info->nPos = Info->nMin; } else if (Info->nPos > Info->nMax - max(Info->nPage - 1, 0)) { Info->nPos = Info->nMax - max(Info->nPage - 1, 0); } /* * Don't change the scrollbar state if SetScrollInfo is just called * with SIF_DISABLENOSCROLL */ if (0 == (lpsi->fMask & SIF_ALL)) { return Info->nPos; } /* Check if the scrollbar should be hidden or disabled */ if (0 != (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))) { if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0))) { /* Hide or disable scroll-bar */ if (0 != (lpsi->fMask & SIF_DISABLENOSCROLL)) { /* new_flags = ESB_DISABLE_BOTH;*/ } else if ((nBar != SB_CTL) && bChangeParams) { co_UserShowScrollBar(Window, nBar, FALSE); return Info->nPos; } } else /* Show and enable scroll-bar */ { /* new_flags = 0;*/ if ((nBar != SB_CTL) && bChangeParams) { co_UserShowScrollBar(Window, nBar, TRUE); } } #if 0 if (infoPtr->flags != new_flags) /* check arrow flags */ { infoPtr->flags = new_flags; *Action |= SA_SSI_REPAINT_ARROWS; } #endif } if (bRedraw) { RECTL UpdateRect = psbi->rcScrollBar; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } /* Return current position */ return Info->nPos; }