[0.4.10] 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:03:05 +01:00
parent 1bb175b0b5
commit dc4ce33558
4 changed files with 269 additions and 300 deletions

View file

@ -571,6 +571,29 @@ dodefault:
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
*/
@ -606,6 +629,7 @@ ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
puah->SetWindowRgn = ThemeSetWindowRgn;
puah->GetScrollInfo = ThemeGetScrollInfo;
puah->SetScrollInfo = ThemeSetScrollInfo;
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCPAINT);
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCACTIVATE);

View file

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

View file

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