[0.4.11] Update Scrollbar code to state of master 2023-March-12

by porting back:
0.4.15-dev-5784-g 2aea4ab945 [NTUSER] Scrollbar.c pure whitespace fixes
0.4.15-dev-5680-g 5ad5737370 CORE-18050 [NTUSER] Delete temporary workarounds in co_IntSetScrollInfo() (#4985)
0.4.15-dev-5355-g 0484beb04b CORE-18593 [NTUSER] Don't redraw scrollbar if it is hidden command prompt (#4849)
0.4.15-dev-4492-g 03422451b3 Add '\n' to debug logs (partially, only the scrollbar.c part)
0.4.15-dev-3875-g 977c129f33 CORE-18048 [USER32] SetScrollPos should not bypass UserApiHook (#4372)
0.4.15-dev-3849-g fd28a69de6 CORE-17780 [WIN32SS] Store the scrollbar theming enabled flag in the scrollbar (#4367)
0.4.15-dev-3175-g 222acf5a3e CORE-17777 [NTUSER] Scrollbar.c, Avoid potential out-of-bounds-accesses in co_IntSetScrollInfo()
0.4.15-dev-3174-g dda9c3979e CORE-17769 'Rapps Listview manual resize may erroneously not draw the triangles sometimes'
0.4.15-dev-3147-g 3bf7e3ac13 CORE-17754 and CORE-17755 [NTUSER] Improve Themed Scrollbars by Minimizing Updates (#3953)
0.4.15-dev-3086-g 236649c626 CORE-16375 [UXTHEME][NTUSER] Fix flashing of scrollbar when scrolling (#3868)
0.4.15-dev-2375-g ffea5152e6 [WIN32SS][NTUSER] Fix an integer underflow within scrollbar info setting
0.4.14-dev-1134-g 00adb1a3f9 [WIN32SS] Improve Drawing Scrollbars
- CORE-14755 fixed, flashing scrollbar triangles (we know 131 affected apps just from rapps!)
- CORE-13931 fixed, FamiTracker invisible about-dlg
- CORE-14685 improves a bit, but is not entirely fixed
- CORE-11561 'Notepad scrollbars problem' fixed

This will also speed up NSIS installers that display their file-copy-progress by
a self-scrolling listview.
This commit is contained in:
Joachim Henze 2023-03-12 11:01:41 +01:00
parent 14e4939dc4
commit 0eb86c9990
4 changed files with 269 additions and 300 deletions

View file

@ -571,6 +571,29 @@ dodefault:
return g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi); return g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
} }
INT WINAPI ThemeSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
{
PWND_DATA pwndData;
SCROLLINFO siout;
LPSCROLLINFO lpsiout = &siout;
BOOL IsThemed = FALSE;
pwndData = ThemeGetWndData(hWnd);
if (!pwndData)
goto dodefault;
if (pwndData->hthemeScrollbar)
IsThemed = TRUE;
memcpy(&siout, lpsi, sizeof(SCROLLINFO));
if (IsThemed)
siout.fMask |= SIF_THEMED;
dodefault:
return g_user32ApiHook.SetScrollInfo(hWnd, fnBar, lpsiout, bRedraw);
}
/********************************************************************** /**********************************************************************
* Exports * Exports
*/ */
@ -606,6 +629,7 @@ ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
puah->SetWindowRgn = ThemeSetWindowRgn; puah->SetWindowRgn = ThemeSetWindowRgn;
puah->GetScrollInfo = ThemeGetScrollInfo; puah->GetScrollInfo = ThemeGetScrollInfo;
puah->SetScrollInfo = ThemeSetScrollInfo;
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCPAINT); UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCPAINT);
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCACTIVATE); UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCACTIVATE);

View file

@ -1221,6 +1221,7 @@ extern "C" {
#define SIF_RANGE 1 #define SIF_RANGE 1
#define SIF_DISABLENOSCROLL 8 #define SIF_DISABLENOSCROLL 8
#define SIF_TRACKPOS 16 #define SIF_TRACKPOS 16
#define SIF_THEMED 128
#define SWP_DRAWFRAME 32 #define SWP_DRAWFRAME 32
#define SWP_FRAMECHANGED 32 #define SWP_FRAMECHANGED 32
#define SWP_HIDEWINDOW 128 #define SWP_HIDEWINDOW 128

View file

@ -1,9 +1,8 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* LICENSE: See COPYING in the top level directory
* PURPOSE: Scrollbars * PURPOSE: Scrollbars
* FILE: win32ss/user/ntuser/scrollbar.c * COPYRIGHT: Thomas Weidenmueller (w3seek@users.sourceforge.net)
* PROGRAMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
* Jason Filby (jasonfilby@yahoo.com) * Jason Filby (jasonfilby@yahoo.com)
*/ */
@ -18,8 +17,7 @@ DBG_DEFAULT_CHANNEL(UserScrollbar);
#define SCROLL_BOTTOM_RECT 0x04 /* Rectangle between the thumb and the bottom arrow */ #define SCROLL_BOTTOM_RECT 0x04 /* Rectangle between the thumb and the bottom arrow */
#define SCROLL_BOTTOM_ARROW 0x05 /* Bottom or right arrow */ #define SCROLL_BOTTOM_ARROW 0x05 /* Bottom or right arrow */
#define SCROLL_FIRST_DELAY 200 /* Delay (in ms) before first repetition when #define SCROLL_FIRST_DELAY 200 /* Delay (in ms) before first repetition when holding the button down */
holding the button down */
#define SCROLL_REPEAT_DELAY 50 /* Delay (in ms) between scroll repetitions */ #define SCROLL_REPEAT_DELAY 50 /* Delay (in ms) between scroll repetitions */
#define SCROLL_TIMER 0 /* Scroll timer id */ #define SCROLL_TIMER 0 /* Scroll timer id */
@ -33,9 +31,6 @@ DBG_DEFAULT_CHANNEL(UserScrollbar);
/* Overlap between arrows and thumb */ /* Overlap between arrows and thumb */
#define SCROLL_ARROW_THUMB_OVERLAP 0 #define SCROLL_ARROW_THUMB_OVERLAP 0
//
//
//
#define MINTRACKTHUMB 8 /* Minimum size of the rectangle between the arrows */ #define MINTRACKTHUMB 8 /* Minimum size of the rectangle between the arrows */
/* What to do after SetScrollInfo() */ /* What to do after SetScrollInfo() */
@ -61,6 +56,8 @@ DBG_DEFAULT_CHANNEL(UserScrollbar);
BOOL APIENTRY BOOL APIENTRY
IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows); IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows);
static void
IntRefeshScrollInterior(PWND pWnd, INT nBar, PSCROLLBARINFO psbi);
/* Ported from WINE20020904 */ /* Ported from WINE20020904 */
/* Compute the scrollbar rectangle, in drawing coordinates (i.e. client coords for SB_CTL, window coords for SB_VERT and /* Compute the scrollbar rectangle, in drawing coordinates (i.e. client coords for SB_CTL, window coords for SB_VERT and
@ -92,13 +89,13 @@ IntGetSBData(PWND pwnd, INT Bar)
case SB_CTL: case SB_CTL:
if (pwnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND))) if (pwnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND)))
{ {
ERR("IntGetSBData Wrong Extra bytes for CTL Scrollbar!\n"); ERR("IntGetSBData Wrong Extra bytes for CTL Scrollbar\n");
return 0; return 0;
} }
pSBWnd = (PSBWND)pwnd; pSBWnd = (PSBWND)pwnd;
return (PSBDATA)&pSBWnd->SBCalc; return (PSBDATA)&pSBWnd->SBCalc;
default: default:
ERR("IntGetSBData Bad Bar!\n"); ERR("IntGetSBData Bad Bar\n");
} }
return NULL; return NULL;
} }
@ -199,7 +196,7 @@ IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi, PSBDATA pSBData)
} }
ThumbPos = Thumb; ThumbPos = Thumb;
/* Calculate Thumb */ // Calculate Thumb
if(cxy <= (2 * Thumb)) if(cxy <= (2 * Thumb))
{ {
Thumb = cxy / 2; Thumb = cxy / 2;
@ -211,7 +208,7 @@ IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi, PSBDATA pSBData)
psbi->rgstate[SBRG_BOTTOMLEFTBTN] == STATE_SYSTEM_UNAVAILABLE && psbi->rgstate[SBRG_BOTTOMLEFTBTN] == STATE_SYSTEM_UNAVAILABLE &&
pSBData->posMin >= (int)(pSBData->posMax - max(pSBData->page - 1, 0))) pSBData->posMin >= (int)(pSBData->posMax - max(pSBData->page - 1, 0)))
{ {
/* Nothing to scroll */ // Nothing to scroll
psbi->xyThumbTop = 0; psbi->xyThumbTop = 0;
psbi->xyThumbBottom = 0; psbi->xyThumbBottom = 0;
} }
@ -222,9 +219,7 @@ IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi, PSBDATA pSBData)
if(cxy >= ThumbBox) if(cxy >= ThumbBox)
{ {
if(pSBData->page) if(pSBData->page)
{
ThumbBox = max(EngMulDiv(cxy, pSBData->page, pSBData->posMax - pSBData->posMin + 1), ThumbBox); ThumbBox = max(EngMulDiv(cxy, pSBData->page, pSBData->posMax - pSBData->posMin + 1), ThumbBox);
}
if(cxy > ThumbBox) if(cxy > ThumbBox)
{ {
@ -273,6 +268,7 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
ASSERT_REFS_CO(Window); ASSERT_REFS_CO(Window);
lpsi->fMask &= ~SIF_THEMED;
if(!SBID_IS_VALID(nBar)) if(!SBID_IS_VALID(nBar))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
@ -282,30 +278,22 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
if (!Window->pSBInfo) if (!Window->pSBInfo)
{ {
ERR("IntGetScrollInfo No window scrollbar info!\n"); ERR("IntGetScrollInfo No window scrollbar info\n");
return FALSE; return FALSE;
} }
psi = IntGetScrollInfoFromWindow(Window, nBar); psi = IntGetScrollInfoFromWindow(Window, nBar);
if (lpsi->fMask == SIF_ALL) if (lpsi->fMask == SIF_ALL)
{
Mask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; Mask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS;
}
else else
{
Mask = lpsi->fMask; Mask = lpsi->fMask;
}
if (0 != (Mask & SIF_PAGE)) if (0 != (Mask & SIF_PAGE))
{
lpsi->nPage = psi->nPage; lpsi->nPage = psi->nPage;
}
if (0 != (Mask & SIF_POS)) if (0 != (Mask & SIF_POS))
{
lpsi->nPos = psi->nPos; lpsi->nPos = psi->nPos;
}
if (0 != (Mask & SIF_RANGE)) if (0 != (Mask & SIF_RANGE))
{ {
@ -314,9 +302,7 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
} }
if (0 != (Mask & SIF_TRACKPOS)) if (0 != (Mask & SIF_TRACKPOS))
{
lpsi->nTrackPos = psi->nTrackPos; lpsi->nTrackPos = psi->nTrackPos;
}
return TRUE; return TRUE;
} }
@ -331,6 +317,7 @@ NEWco_IntGetScrollInfo(
UINT Mask; UINT Mask;
PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack; PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack;
lpsi->fMask &= ~SIF_THEMED;
if (!SBID_IS_VALID(nBar)) if (!SBID_IS_VALID(nBar))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
@ -343,14 +330,10 @@ NEWco_IntGetScrollInfo(
Mask = lpsi->fMask; Mask = lpsi->fMask;
if (0 != (Mask & SIF_PAGE)) if (0 != (Mask & SIF_PAGE))
{
lpsi->nPage = pSBData->page; lpsi->nPage = pSBData->page;
}
if (0 != (Mask & SIF_POS)) if (0 != (Mask & SIF_POS))
{
lpsi->nPos = pSBData->pos; lpsi->nPos = pSBData->pos;
}
if (0 != (Mask & SIF_RANGE)) if (0 != (Mask & SIF_RANGE))
{ {
@ -360,9 +343,7 @@ NEWco_IntGetScrollInfo(
if (0 != (Mask & SIF_TRACKPOS)) if (0 != (Mask & SIF_TRACKPOS))
{ {
if ( pSBTrack && if (pSBTrack && pSBTrack->nBar == nBar && pSBTrack->spwndTrack == pWnd)
pSBTrack->nBar == nBar &&
pSBTrack->spwndTrack == pWnd )
lpsi->nTrackPos = pSBTrack->posNew; lpsi->nTrackPos = pSBTrack->posNew;
else else
lpsi->nTrackPos = pSBData->pos; lpsi->nTrackPos = pSBData->pos;
@ -401,13 +382,13 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject, LPSCROLLBARINFO in
default: return FALSE; default: return FALSE;
} }
/* handle invalid data structure */ // handle invalid data structure
if (info->cbSize != sizeof(*info)) if (info->cbSize != sizeof(*info))
return FALSE; return FALSE;
SCROLL_GetScrollBarRect(hwnd, nBar, &info->rcScrollBar, &nDummy, SCROLL_GetScrollBarRect(hwnd, nBar, &info->rcScrollBar, &nDummy,
&info->dxyLineButton, &info->xyThumbTop); &info->dxyLineButton, &info->xyThumbTop);
/* rcScrollBar needs to be in screen coordinates */ // rcScrollBar needs to be in screen coordinates
GetWindowRect(hwnd, &rect); GetWindowRect(hwnd, &rect);
OffsetRect(&info->rcScrollBar, rect.left, rect.top); OffsetRect(&info->rcScrollBar, rect.left, rect.top);
@ -417,7 +398,7 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject, LPSCROLLBARINFO in
if (!infoPtr) if (!infoPtr)
return FALSE; return FALSE;
/* Scroll bar state */ // Scrollbar state
info->rgstate[0] = 0; info->rgstate[0] = 0;
if ((nBar == SB_HORZ && !(style & WS_HSCROLL)) if ((nBar == SB_HORZ && !(style & WS_HSCROLL))
|| (nBar == SB_VERT && !(style & WS_VSCROLL))) || (nBar == SB_VERT && !(style & WS_VSCROLL)))
@ -434,33 +415,33 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject, LPSCROLLBARINFO in
pressed = ((nBar == SB_VERT) == SCROLL_trackVertical && GetCapture() == hwnd); pressed = ((nBar == SB_VERT) == SCROLL_trackVertical && GetCapture() == hwnd);
/* Top/left arrow button state. MSDN says top/right, but I don't believe it */ // Top/left arrow button state. MSDN says top/right, but I don't believe it
info->rgstate[1] = 0; info->rgstate[1] = 0;
if (pressed && SCROLL_trackHitTest == SCROLL_TOP_ARROW) if (pressed && SCROLL_trackHitTest == SCROLL_TOP_ARROW)
info->rgstate[1] |= STATE_SYSTEM_PRESSED; info->rgstate[1] |= STATE_SYSTEM_PRESSED;
if (infoPtr->flags & ESB_DISABLE_LTUP) if (infoPtr->flags & ESB_DISABLE_LTUP)
info->rgstate[1] |= STATE_SYSTEM_UNAVAILABLE; info->rgstate[1] |= STATE_SYSTEM_UNAVAILABLE;
/* Page up/left region state. MSDN says up/right, but I don't believe it */ // Page up/left region state. MSDN says up/right, but I don't believe it
info->rgstate[2] = 0; info->rgstate[2] = 0;
if (infoPtr->curVal == infoPtr->minVal) if (infoPtr->curVal == infoPtr->minVal)
info->rgstate[2] |= STATE_SYSTEM_INVISIBLE; info->rgstate[2] |= STATE_SYSTEM_INVISIBLE;
if (pressed && SCROLL_trackHitTest == SCROLL_TOP_RECT) if (pressed && SCROLL_trackHitTest == SCROLL_TOP_RECT)
info->rgstate[2] |= STATE_SYSTEM_PRESSED; info->rgstate[2] |= STATE_SYSTEM_PRESSED;
/* Thumb state */ // Thumb state
info->rgstate[3] = 0; info->rgstate[3] = 0;
if (pressed && SCROLL_trackHitTest == SCROLL_THUMB) if (pressed && SCROLL_trackHitTest == SCROLL_THUMB)
info->rgstate[3] |= STATE_SYSTEM_PRESSED; info->rgstate[3] |= STATE_SYSTEM_PRESSED;
/* Page down/right region state. MSDN says down/left, but I don't believe it */ // Page down/right region state. MSDN says down/left, but I don't believe it
info->rgstate[4] = 0; info->rgstate[4] = 0;
if (infoPtr->curVal >= infoPtr->maxVal - 1) if (infoPtr->curVal >= infoPtr->maxVal - 1)
info->rgstate[4] |= STATE_SYSTEM_INVISIBLE; info->rgstate[4] |= STATE_SYSTEM_INVISIBLE;
if (pressed && SCROLL_trackHitTest == SCROLL_BOTTOM_RECT) if (pressed && SCROLL_trackHitTest == SCROLL_BOTTOM_RECT)
info->rgstate[4] |= STATE_SYSTEM_PRESSED; info->rgstate[4] |= STATE_SYSTEM_PRESSED;
/* Bottom/right arrow button state. MSDN says bottom/left, but I don't believe it */ // Bottom/right arrow button state. MSDN says bottom/left, but I don't believe it
info->rgstate[5] = 0; info->rgstate[5] = 0;
if (pressed && SCROLL_trackHitTest == SCROLL_BOTTOM_ARROW) if (pressed && SCROLL_trackHitTest == SCROLL_BOTTOM_ARROW)
info->rgstate[5] |= STATE_SYSTEM_PRESSED; info->rgstate[5] |= STATE_SYSTEM_PRESSED;
@ -473,10 +454,8 @@ static BOOL SCROLL_GetScrollBarInfo(HWND hwnd, LONG idObject, LPSCROLLBARINFO in
static DWORD FASTCALL static DWORD FASTCALL
co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
{ {
/* // Update the scrollbar state and set action flags according to
* Update the scrollbar state and set action flags according to // what has to be done graphics wise.
* what has to be done graphics wise.
*/
LPSCROLLINFO Info; LPSCROLLINFO Info;
PSCROLLBARINFO psbi; PSCROLLBARINFO psbi;
@ -484,23 +463,22 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
INT action = 0; INT action = 0;
PSBDATA pSBData; PSBDATA pSBData;
DWORD OldPos = 0; DWORD OldPos = 0;
BOOL bChangeParams = FALSE; /* Don't show/hide scrollbar if params don't change */ BOOL bChangeParams = FALSE; // Don't show/hide scrollbar if params don't change
UINT MaxPage; UINT MaxPage;
int MaxPos; int MaxPos;
BOOL bVisible;
ASSERT_REFS_CO(Window); ASSERT_REFS_CO(Window);
if(!SBID_IS_VALID(nBar)) if(!SBID_IS_VALID(nBar))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
ERR("Trying to set scrollinfo for unknown scrollbar type %d", nBar); ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", nBar);
return FALSE; return FALSE;
} }
if(!co_IntCreateScrollBars(Window)) if(!co_IntCreateScrollBars(Window))
{
return FALSE; return FALSE;
}
if (lpsi->cbSize != sizeof(SCROLLINFO) && if (lpsi->cbSize != sizeof(SCROLLINFO) &&
lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos))) lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos)))
@ -508,7 +486,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
return 0; return 0;
} }
if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_PREVIOUSPOS)) if ((lpsi->fMask & ~SIF_THEMED) & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_PREVIOUSPOS))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
return 0; return 0;
@ -518,7 +496,10 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Info = IntGetScrollInfoFromWindow(Window, nBar); Info = IntGetScrollInfoFromWindow(Window, nBar);
pSBData = IntGetSBData(Window, nBar); pSBData = IntGetSBData(Window, nBar);
/* Set the page size */ if (lpsi->fMask & SIF_THEMED && !(Info->fMask & SIF_THEMED))
Info->fMask |= SIF_THEMED;
// Set the page size
if (lpsi->fMask & SIF_PAGE) if (lpsi->fMask & SIF_PAGE)
{ {
if (Info->nPage != lpsi->nPage) if (Info->nPage != lpsi->nPage)
@ -529,18 +510,18 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
} }
} }
/* Set the scroll pos */ // Set the scroll pos
if (lpsi->fMask & SIF_POS) if (lpsi->fMask & SIF_POS)
{ {
OldPos = Info->nPos;
if (Info->nPos != lpsi->nPos) if (Info->nPos != lpsi->nPos)
{ {
OldPos = Info->nPos;
Info->nPos = lpsi->nPos; Info->nPos = lpsi->nPos;
pSBData->pos = lpsi->nPos; pSBData->pos = lpsi->nPos;
} }
} }
/* Set the scroll range */ // Set the scroll range
if (lpsi->fMask & SIF_RANGE) if (lpsi->fMask & SIF_RANGE)
{ {
if (lpsi->nMin > lpsi->nMax) if (lpsi->nMin > lpsi->nMax)
@ -561,42 +542,30 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
} }
} }
/* Make sure the page size is valid */ // Make sure the page size is valid
MaxPage = abs(Info->nMax - Info->nMin) + 1; MaxPage = abs(Info->nMax - Info->nMin) + 1;
if (Info->nPage > MaxPage) if (Info->nPage > MaxPage)
{
pSBData->page = Info->nPage = MaxPage; pSBData->page = Info->nPage = MaxPage;
}
/* Make sure the pos is inside the range */ // Make sure the pos is inside the range
MaxPos = Info->nMax + 1 - (int)max(Info->nPage, 1); MaxPos = Info->nMax + 1 - (int)max(Info->nPage, 1);
ASSERT(MaxPos >= Info->nMin); ASSERT(MaxPos >= Info->nMin);
if (Info->nPos < Info->nMin) if (Info->nPos < Info->nMin)
{
pSBData->pos = Info->nPos = Info->nMin; pSBData->pos = Info->nPos = Info->nMin;
}
else if (Info->nPos > MaxPos) else if (Info->nPos > MaxPos)
{
pSBData->pos = Info->nPos = MaxPos; pSBData->pos = Info->nPos = MaxPos;
}
/* // Don't change the scrollbar state if SetScrollInfo is just called with SIF_DISABLENOSCROLL
* Don't change the scrollbar state if SetScrollInfo is just called
* with SIF_DISABLENOSCROLL
*/
if (!(lpsi->fMask & SIF_ALL)) if (!(lpsi->fMask & SIF_ALL))
{
//goto done;
return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos;
}
/* Check if the scrollbar should be hidden or disabled */ // Check if the scrollbar should be hidden or disabled
if (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL)) if (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
{ {
new_flags = Window->pSBInfo->WSBflags; new_flags = Window->pSBInfo->WSBflags;
if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0))) if (Info->nMin + (int)max(Info->nPage, 1) > Info->nMax)
{ {
/* Hide or disable scroll-bar */ // Hide or disable scrollbar
if (lpsi->fMask & SIF_DISABLENOSCROLL) if (lpsi->fMask & SIF_DISABLENOSCROLL)
{ {
new_flags = ESB_DISABLE_BOTH; new_flags = ESB_DISABLE_BOTH;
@ -607,9 +576,8 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
action = SA_SSI_HIDE; action = SA_SSI_HIDE;
} }
} }
else /* Show and enable scroll-bar only if no page only changed. */ else if ((lpsi->fMask & ~SIF_THEMED) != SIF_PAGE)
if (lpsi->fMask != SIF_PAGE) { // Show and enable scrollbar only if no page only changed
{
if ((nBar != SB_CTL) && bChangeParams) if ((nBar != SB_CTL) && bChangeParams)
{ {
new_flags = ESB_ENABLE_BOTH; new_flags = ESB_ENABLE_BOTH;
@ -621,14 +589,13 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
} }
} }
if (Window->pSBInfo->WSBflags != new_flags) /* Check arrow flags */ if (Window->pSBInfo->WSBflags != new_flags) // Check arrow flags
{ {
Window->pSBInfo->WSBflags = new_flags; Window->pSBInfo->WSBflags = new_flags;
action |= SA_SSI_REPAINT_ARROWS; action |= SA_SSI_REPAINT_ARROWS;
} }
} }
//done:
if (action & SA_SSI_HIDE) if (action & SA_SSI_HIDE)
{ {
co_UserShowScrollBar(Window, nBar, FALSE, FALSE); co_UserShowScrollBar(Window, nBar, FALSE, FALSE);
@ -637,17 +604,29 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
{ {
if (action & SA_SSI_SHOW) if (action & SA_SSI_SHOW)
if (co_UserShowScrollBar(Window, nBar, TRUE, TRUE)) if (co_UserShowScrollBar(Window, nBar, TRUE, TRUE))
return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; /* SetWindowPos() already did the painting */ return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; // SetWindowPos() already did the painting
if (bRedraw)
{ // FIXME: Arrows and interior. switch (nBar)
RECTL UpdateRect = psbi->rcScrollBar; {
UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; case SB_HORZ:
UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left; bVisible = (Window->style & WS_HSCROLL);
UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top; break;
UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; case SB_VERT:
co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); bVisible = (Window->style & WS_VSCROLL);
} // FIXME: Arrows break;
/* else if( action & SA_SSI_REPAINT_ARROWS ) case SB_CTL:
bVisible = (Window->style & WS_VISIBLE);
break;
default:
bVisible = FALSE;
break;
}
if (bRedraw && bVisible)
{
if (!(Info->fMask & SIF_THEMED))
{
if (action & SA_SSI_REPAINT_ARROWS)
{ {
RECTL UpdateRect = psbi->rcScrollBar; RECTL UpdateRect = psbi->rcScrollBar;
UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left; UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
@ -656,14 +635,26 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top; UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top;
co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME);
} }
*/ } else
IntRefeshScrollInterior(Window, nBar, psbi);
}
else
{
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;
if (bChangeParams || (OldPos != pSBData->pos))
co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME);
}
}
}
if (bChangeParams && (nBar == SB_HORZ || nBar == SB_VERT) && (lpsi->fMask & SIF_DISABLENOSCROLL)) if (bChangeParams && (nBar == SB_HORZ || nBar == SB_VERT) && (lpsi->fMask & SIF_DISABLENOSCROLL))
{
IntEnableScrollBar(nBar == SB_HORZ, psbi, Window->pSBInfo->WSBflags); IntEnableScrollBar(nBar == SB_HORZ, psbi, Window->pSBInfo->WSBflags);
}
/* Return current position */ // Return current position
return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos;
} }
@ -686,7 +677,7 @@ co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO psbi)
if(!co_IntCreateScrollBars(Window)) if(!co_IntCreateScrollBars(Window))
{ {
ERR("Failed to create scrollbars for window.\n"); ERR("Failed to create scrollbars for window\n");
return FALSE; return FALSE;
} }
@ -696,7 +687,7 @@ co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO psbi)
IntGetScrollBarRect(Window, Bar, &(sbi->rcScrollBar)); IntGetScrollBarRect(Window, Bar, &(sbi->rcScrollBar));
IntCalculateThumb(Window, Bar, sbi, pSBData); IntCalculateThumb(Window, Bar, sbi, pSBData);
/* Scroll bar state */ // Scrollbar state
psbi->rgstate[0] = 0; psbi->rgstate[0] = 0;
if ((Bar == SB_HORZ && !(Window->style & WS_HSCROLL)) if ((Bar == SB_HORZ && !(Window->style & WS_HSCROLL))
|| (Bar == SB_VERT && !(Window->style & WS_VSCROLL))) || (Bar == SB_VERT && !(Window->style & WS_VSCROLL)))
@ -735,7 +726,7 @@ co_IntSetScrollBarInfo(PWND Window, LONG idObject, PSETSCROLLBARINFO psbi)
if(!co_IntCreateScrollBars(Window)) if(!co_IntCreateScrollBars(Window))
{ {
ERR("Failed to create scrollbars for window.\n"); ERR("Failed to create scrollbars for window\n");
return FALSE; return FALSE;
} }
@ -760,12 +751,9 @@ co_IntCreateScrollBars(PWND Window)
ASSERT_REFS_CO(Window); ASSERT_REFS_CO(Window);
if (Window->pSBInfo && Window->pSBInfoex) if (Window->pSBInfo && Window->pSBInfoex)
{ return TRUE; // No need to create it anymore
/* No need to create it anymore */
return TRUE;
}
/* Allocate memory for all scrollbars (HORZ, VERT, CONTROL) */ // Allocate memory for all scrollbars (HORZ, VERT, CONTROL)
Size = 3 * (sizeof(SBINFOEX)); Size = 3 * (sizeof(SBINFOEX));
if(!(Window->pSBInfoex = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO))) if(!(Window->pSBInfoex = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO)))
{ {
@ -785,9 +773,7 @@ co_IntCreateScrollBars(PWND Window)
Window->pSBInfo->Vert.posMax = 100; Window->pSBInfo->Vert.posMax = 100;
Window->pSBInfo->Horz.posMax = 100; Window->pSBInfo->Horz.posMax = 100;
co_WinPosGetNonClientSize(Window, co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
&Window->rcWindow,
&Window->rcClient);
for(s = SB_HORZ; s <= SB_VERT; s++) for(s = SB_HORZ; s <= SB_VERT; s++)
{ {
@ -870,7 +856,6 @@ co_UserShowScrollBar(PWND Wnd, int nBar, BOOL fShowH, BOOL fShowV)
case SB_CTL: case SB_CTL:
{ {
//IntUpdateSBInfo(Wnd, SB_CTL); // Is this needed? Was tested w/o! //IntUpdateSBInfo(Wnd, SB_CTL); // Is this needed? Was tested w/o!
co_WinPosShowWindow(Wnd, fShowH ? SW_SHOW : SW_HIDE); co_WinPosShowWindow(Wnd, fShowH ? SW_SHOW : SW_HIDE);
return TRUE; return TRUE;
} }
@ -879,29 +864,29 @@ co_UserShowScrollBar(PWND Wnd, int nBar, BOOL fShowH, BOOL fShowV)
if (fShowH) set_bits |= WS_HSCROLL; if (fShowH) set_bits |= WS_HSCROLL;
else clear_bits |= WS_HSCROLL; else clear_bits |= WS_HSCROLL;
if( nBar == SB_HORZ ) break; if( nBar == SB_HORZ ) break;
/* Fall through */ // Fall through
case SB_VERT: case SB_VERT:
if (fShowV) set_bits |= WS_VSCROLL; if (fShowV) set_bits |= WS_VSCROLL;
else clear_bits |= WS_VSCROLL; else clear_bits |= WS_VSCROLL;
break; break;
default: default:
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE; /* Nothing to do! */ return FALSE; // Nothing to do
} }
old_style = IntSetStyle(Wnd, set_bits, clear_bits); old_style = IntSetStyle(Wnd, set_bits, clear_bits);
if ((old_style & clear_bits) != 0 || (old_style & set_bits) != set_bits) if ((old_style & clear_bits) != 0 || (old_style & set_bits) != set_bits)
{ {
///// Is this needed? Was tested w/o! //// Is this needed? Was tested w/o!
//if (Wnd->style & WS_HSCROLL) IntUpdateSBInfo(Wnd, SB_HORZ); //if (Wnd->style & WS_HSCROLL) IntUpdateSBInfo(Wnd, SB_HORZ);
//if (Wnd->style & WS_VSCROLL) IntUpdateSBInfo(Wnd, SB_VERT); //if (Wnd->style & WS_VSCROLL) IntUpdateSBInfo(Wnd, SB_VERT);
/////
/* Frame has been changed, let the window redraw itself */ // Frame has been changed, let the window redraw itself
co_WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE co_WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
| SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
return TRUE; return TRUE;
} }
return FALSE; /* no frame changes */ return FALSE; // no frame changes
} }
static void static void
@ -918,11 +903,9 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINF
if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_RECT] & STATE_SYSTEM_PRESSED) if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_RECT] & STATE_SYSTEM_PRESSED)
BottomSelected = TRUE; BottomSelected = TRUE;
/* // Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
* Only scrollbar controls send WM_CTLCOLORSCROLLBAR. // The window-owned scrollbars need to call DefWndControlColor
* The window-owned scrollbars need to call DefWndControlColor // to correctly setup default scrollbar colors
* to correctly setup default scrollbar colors
*/
if (nBar == SB_CTL) if (nBar == SB_CTL)
{ {
hBrush = GetControlBrush(pWnd, hDC, WM_CTLCOLORSCROLLBAR); hBrush = GetControlBrush(pWnd, hDC, WM_CTLCOLORSCROLLBAR);
@ -936,7 +919,7 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINF
hSaveBrush = NtGdiSelectBrush(hDC, hBrush); hSaveBrush = NtGdiSelectBrush(hDC, hBrush);
/* Calculate the scroll rectangle */ // Calculate the scroll rectangle
if (Vertical) if (Vertical)
{ {
Rect.top = ScrollBarInfo->rcScrollBar.top + ScrollBarInfo->dxyLineButton; Rect.top = ScrollBarInfo->rcScrollBar.top + ScrollBarInfo->dxyLineButton;
@ -952,13 +935,13 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINF
Rect.right = ScrollBarInfo->rcScrollBar.right - ScrollBarInfo->dxyLineButton; Rect.right = ScrollBarInfo->rcScrollBar.right - ScrollBarInfo->dxyLineButton;
} }
/* Draw the scroll rectangles and thumb */ // Draw scroll rectangles and thumb
if (!ScrollBarInfo->xyThumbBottom) if (!ScrollBarInfo->xyThumbBottom)
{ {
NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left, NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
Rect.bottom - Rect.top, PATCOPY); Rect.bottom - Rect.top, PATCOPY);
/* Cleanup and return */ // Cleanup and return
NtGdiSelectBrush(hDC, hSaveBrush); NtGdiSelectBrush(hDC, hSaveBrush);
return; return;
} }
@ -1010,15 +993,14 @@ IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINF
} }
} }
/* Draw the thumb */ // Draw thumb
if (ThumbSize) if (ThumbSize)
DrawEdge(hDC, &Rect, EDGE_RAISED, BF_RECT | BF_MIDDLE); DrawEdge(hDC, &Rect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
/* Cleanup */ // Cleanup
NtGdiSelectBrush(hDC, hSaveBrush); NtGdiSelectBrush(hDC, hSaveBrush);
} }
static VOID FASTCALL static VOID FASTCALL
IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical) IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
{ {
@ -1042,21 +1024,16 @@ IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
} }
if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_PRESSED) if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_PRESSED)
{
ScrollDirFlagLT |= DFCS_PUSHED | DFCS_FLAT; ScrollDirFlagLT |= DFCS_PUSHED | DFCS_FLAT;
}
if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_UNAVAILABLE) if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_UNAVAILABLE)
{
ScrollDirFlagLT |= DFCS_INACTIVE; ScrollDirFlagLT |= DFCS_INACTIVE;
}
if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_PRESSED) if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_PRESSED)
{
ScrollDirFlagRB |= DFCS_PUSHED | DFCS_FLAT; ScrollDirFlagRB |= DFCS_PUSHED | DFCS_FLAT;
}
if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_UNAVAILABLE) if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_UNAVAILABLE)
{
ScrollDirFlagRB |= DFCS_INACTIVE; ScrollDirFlagRB |= DFCS_INACTIVE;
}
DrawFrameControl(hDC, &RectLT, DFC_SCROLL, ScrollDirFlagLT); DrawFrameControl(hDC, &RectLT, DFC_SCROLL, ScrollDirFlagLT);
DrawFrameControl(hDC, &RectRB, DFC_SCROLL, ScrollDirFlagRB); DrawFrameControl(hDC, &RectRB, DFC_SCROLL, ScrollDirFlagRB);
@ -1072,20 +1049,31 @@ IntScrollGetObjectId(INT SBType)
return OBJID_CLIENT; return OBJID_CLIENT;
} }
static void
IntRefeshScrollInterior(PWND pWnd, INT nBar, PSCROLLBARINFO psbi)
{
HDC hdc;
BOOL Vertical = ((nBar == SB_CTL) ? ((pWnd->style & SBS_VERT) != 0) : (nBar == SB_VERT));
hdc = UserGetDCEx(pWnd, NULL, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
if (hdc)
{
co_IntGetScrollBarInfo(pWnd, IntScrollGetObjectId(nBar), psbi);
IntDrawScrollInterior(pWnd, hdc, nBar, Vertical, psbi);
UserReleaseDC(pWnd, hdc, FALSE);
}
}
void void
IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar) IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar)
{ {
//PSBWND pSBWnd;
//INT ThumbSize;
PTHREADINFO pti; PTHREADINFO pti;
SCROLLBARINFO Info; SCROLLBARINFO Info;
BOOL Vertical; BOOL Vertical;
pti = PsGetCurrentThreadWin32Thread(); pti = PsGetCurrentThreadWin32Thread();
/* // Get scrollbar info
* Get scroll bar info.
*/
switch (Bar) switch (Bar)
{ {
case SB_HORZ: case SB_HORZ:
@ -1105,46 +1093,27 @@ IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar)
} }
if (!co_IntGetScrollBarInfo(Wnd, IntScrollGetObjectId(Bar), &Info)) if (!co_IntGetScrollBarInfo(Wnd, IntScrollGetObjectId(Bar), &Info))
{
return; return;
}
if (RECTL_bIsEmptyRect(&Info.rcScrollBar)) if (RECTL_bIsEmptyRect(&Info.rcScrollBar))
{
return; return;
}
//ThumbSize = pSBWnd->pSBCalc->pxThumbBottom - pSBWnd->pSBCalc->pxThumbTop; // Draw arrows
/*
* Draw the arrows.
*/
if (Info.dxyLineButton) if (Info.dxyLineButton)
{
IntDrawScrollArrows(DC, &Info, Vertical); IntDrawScrollArrows(DC, &Info, Vertical);
}
/* // Draw interior
* Draw the interior.
*/
IntDrawScrollInterior(Wnd, DC, Bar, Vertical, &Info); IntDrawScrollInterior(Wnd, DC, Bar, Vertical, &Info);
/* // If scrollbar has focus, reposition the caret
* If scroll bar has focus, reposition the caret.
*/
if (Wnd == pti->MessageQueue->spwndFocus && Bar == SB_CTL) if (Wnd == pti->MessageQueue->spwndFocus && Bar == SB_CTL)
{ {
if (Vertical) if (Vertical)
{
co_IntSetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1); co_IntSetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1);
}
else else
{
co_IntSetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1); co_IntSetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1);
} }
} }
}
LRESULT APIENTRY LRESULT APIENTRY
ScrollBarWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) ScrollBarWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
@ -1157,19 +1126,13 @@ ScrollBarWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
switch(Msg) switch(Msg)
{ {
case WM_ENABLE: case WM_ENABLE:
{
if (pWnd->pSBInfo) if (pWnd->pSBInfo)
{
pWnd->pSBInfo->WSBflags = wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH; pWnd->pSBInfo->WSBflags = wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH;
}
}
break; break;
} }
return lResult; return lResult;
} }
////
BOOL BOOL
APIENTRY APIENTRY
NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi) NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
@ -1192,9 +1155,7 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
} }
if(!(Window = UserGetWindowObject(hWnd))) if(!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE); RETURN(FALSE);
}
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi); Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
@ -1213,7 +1174,6 @@ CLEANUP:
TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_); TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_);
UserLeave(); UserLeave();
END_CLEANUP; END_CLEANUP;
} }
BOOL BOOL
@ -1238,13 +1198,11 @@ NtUserSBGetParms(
{ {
RtlCopyMemory(&psi, lpsi, sizeof(SCROLLINFO)); RtlCopyMemory(&psi, lpsi, sizeof(SCROLLINFO));
if (pSBData) if (pSBData)
{
RtlCopyMemory(&SBDataSafe, pSBData, sizeof(SBDATA)); RtlCopyMemory(&SBDataSafe, pSBData, sizeof(SBDATA));
} }
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
ERR("NtUserGetScrollInfo Failed size.\n"); ERR("NtUserGetScrollInfo Failed size\n");
SetLastNtError(_SEH2_GetExceptionCode()); SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN(FALSE)); _SEH2_YIELD(RETURN(FALSE));
} }
@ -1252,7 +1210,7 @@ NtUserSBGetParms(
if(!(Window = UserGetWindowObject(hWnd))) if(!(Window = UserGetWindowObject(hWnd)))
{ {
ERR("NtUserGetScrollInfo Bad window.\n"); ERR("NtUserGetScrollInfo Bad window\n");
RETURN(FALSE); RETURN(FALSE);
} }
@ -1266,7 +1224,7 @@ NtUserSBGetParms(
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
ERR("NtUserGetScrollInfo Failed copy to user.\n"); ERR("NtUserGetScrollInfo Failed copy to user\n");
SetLastNtError(_SEH2_GetExceptionCode()); SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN(FALSE)); _SEH2_YIELD(RETURN(FALSE));
} }
@ -1297,17 +1255,13 @@ NtUserEnableScrollBar(
TRACE("Enter NtUserEnableScrollBar\n"); TRACE("Enter NtUserEnableScrollBar\n");
UserEnterExclusive(); UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)) || if (!(Window = UserGetWindowObject(hWnd)) || UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
{
RETURN(FALSE); RETURN(FALSE);
}
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
if (!co_IntCreateScrollBars(Window)) if (!co_IntCreateScrollBars(Window))
{
RETURN(FALSE); RETURN(FALSE);
}
OrigArrows = Window->pSBInfo->WSBflags; OrigArrows = Window->pSBInfo->WSBflags;
Window->pSBInfo->WSBflags = wArrows; Window->pSBInfo->WSBflags = wArrows;
@ -1323,7 +1277,7 @@ NtUserEnableScrollBar(
if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags)) if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
ERR("Trying to set scrollinfo for unknown scrollbar type %u", wSBflags); ERR("Trying to set scrollinfo for unknown scrollbar type %u\n", wSBflags);
RETURN(FALSE); RETURN(FALSE);
} }
@ -1331,7 +1285,7 @@ NtUserEnableScrollBar(
{ {
case SB_BOTH: case SB_BOTH:
InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT); InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
/* Fall through */ // Fall through
case SB_HORZ: case SB_HORZ:
InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ); InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ);
break; break;
@ -1382,11 +1336,9 @@ NtUserSetScrollInfo(
TRACE("Enter NtUserSetScrollInfo\n"); TRACE("Enter NtUserSetScrollInfo\n");
UserEnterExclusive(); UserEnterExclusive();
if(!(Window = UserGetWindowObject(hWnd)) || if(!(Window = UserGetWindowObject(hWnd)) || UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
{
RETURN(0); RETURN(0);
}
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos)); Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos));
@ -1405,7 +1357,6 @@ CLEANUP:
TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", _ret_); TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP; END_CLEANUP;
} }
DWORD APIENTRY DWORD APIENTRY
@ -1420,9 +1371,7 @@ NtUserShowScrollBar(HWND hWnd, int nBar, DWORD bShow)
UserEnterExclusive(); UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd))) if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(0); RETURN(0);
}
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow, ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow,
@ -1435,11 +1384,9 @@ CLEANUP:
TRACE("Leave NtUserShowScrollBar, ret%lu\n", _ret_); TRACE("Leave NtUserShowScrollBar, ret%lu\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP; END_CLEANUP;
} }
// Ugly NtUser API
//// Ugly NtUser API ////
BOOL BOOL
APIENTRY APIENTRY
@ -1461,9 +1408,8 @@ NtUserSetScrollBarInfo(
UserEnterExclusive(); UserEnterExclusive();
if(!(Window = UserGetWindowObject(hWnd))) if(!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE); RETURN(FALSE);
}
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
Obj = SBOBJ_TO_SBID(idObject); Obj = SBOBJ_TO_SBID(idObject);
@ -1475,9 +1421,7 @@ NtUserSetScrollBarInfo(
} }
if(!co_IntCreateScrollBars(Window)) if(!co_IntCreateScrollBars(Window))
{
RETURN(FALSE); RETURN(FALSE);
}
Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO)); Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))

View file

@ -1723,7 +1723,7 @@ SetScrollPos(HWND hWnd, INT nBar, INT nPos, BOOL bRedraw)
ScrollInfo.fMask = SIF_POS|SIF_PREVIOUSPOS; ScrollInfo.fMask = SIF_POS|SIF_PREVIOUSPOS;
ScrollInfo.nPos = nPos; ScrollInfo.nPos = nPos;
return RealSetScrollInfo(hWnd, nBar, &ScrollInfo, bRedraw); return SetScrollInfo(hWnd, nBar, &ScrollInfo, bRedraw);
} }
/* /*