2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
5 * FILE: subsys/win32k/ntuser/scrollbar.c
6 * PROGRAMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
7 * Jason Filby (jasonfilby@yahoo.com)
11 DBG_DEFAULT_CHANNEL(UserScrollbar
);
13 #define MINTRACKTHUMB 8 /* Minimum size of the rectangle between the arrows */
15 /* What to do after SetScrollInfo() */
16 #define SA_SSI_HIDE 0x0001
17 #define SA_SSI_SHOW 0x0002
18 #define SA_SSI_REFRESH 0x0004
19 #define SA_SSI_REPAINT_ARROWS 0x0008
21 #define SBRG_SCROLLBAR 0 /* The scrollbar itself */
22 #define SBRG_TOPRIGHTBTN 1 /* The top or right button */
23 #define SBRG_PAGEUPRIGHT 2 /* The page up or page right region */
24 #define SBRG_SCROLLBOX 3 /* The scroll box */
25 #define SBRG_PAGEDOWNLEFT 4 /* The page down or page left region */
26 #define SBRG_BOTTOMLEFTBTN 5 /* The bottom or left button */
28 #define CHANGERGSTATE(item, status) \
29 if(Info->rgstate[(item)] != (status)) \
31 Info->rgstate[(item)] = (status);
33 /* FUNCTIONS *****************************************************************/
35 /* Ported from WINE20020904 */
36 /* Compute the scroll bar rectangle, in drawing coordinates (i.e. client coords for SB_CTL, window coords for SB_VERT and
37 * SB_HORZ). 'arrowSize' returns the width or height of an arrow (depending on * the orientation of the scrollbar),
38 * 'thumbSize' returns the size of the thumb, and 'thumbPos' returns the position of the thumb relative to the left or to
39 * the top. Return TRUE if the scrollbar is vertical, FALSE if horizontal.
42 IntGetScrollBarRect (PWND Wnd
, INT nBar
, RECTL
*lprect
)
45 RECTL ClientRect
= Wnd
->rcClient
;
46 RECTL WindowRect
= Wnd
->rcWindow
;
51 lprect
->left
= ClientRect
.left
- WindowRect
.left
;
52 lprect
->top
= ClientRect
.bottom
- WindowRect
.top
;
53 lprect
->right
= ClientRect
.right
- WindowRect
.left
;
54 lprect
->bottom
= lprect
->top
+ UserGetSystemMetrics (SM_CYHSCROLL
);
59 if(Wnd
->ExStyle
& WS_EX_LEFTSCROLLBAR
)
61 lprect
->right
= ClientRect
.left
- WindowRect
.left
;
62 lprect
->left
= lprect
->right
- UserGetSystemMetrics(SM_CXVSCROLL
);
66 lprect
->left
= ClientRect
.right
- WindowRect
.left
;
67 lprect
->right
= lprect
->left
+ UserGetSystemMetrics(SM_CXVSCROLL
);
69 lprect
->top
= ClientRect
.top
- WindowRect
.top
;
70 lprect
->bottom
= ClientRect
.bottom
- WindowRect
.top
;
75 IntGetClientRect (Wnd
, lprect
);
76 vertical
= ((Wnd
->style
& SBS_VERT
) != 0);
87 IntCalculateThumb(PWND Wnd
, LONG idObject
, PSCROLLBARINFO psbi
, LPSCROLLINFO psi
)
89 INT Thumb
, ThumbBox
, ThumbPos
, cxy
, mx
;
95 Thumb
= UserGetSystemMetrics(SM_CXHSCROLL
);
96 cxy
= psbi
->rcScrollBar
.right
- psbi
->rcScrollBar
.left
;
99 Thumb
= UserGetSystemMetrics(SM_CYVSCROLL
);
100 cxy
= psbi
->rcScrollBar
.bottom
- psbi
->rcScrollBar
.top
;
103 IntGetClientRect(Wnd
, &ClientRect
);
104 if(Wnd
->style
& SBS_VERT
)
106 Thumb
= UserGetSystemMetrics(SM_CYVSCROLL
);
107 cxy
= ClientRect
.bottom
- ClientRect
.top
;
111 Thumb
= UserGetSystemMetrics(SM_CXHSCROLL
);
112 cxy
= ClientRect
.right
- ClientRect
.left
;
120 /* Calculate Thumb */
121 if(cxy
<= (2 * Thumb
))
124 psbi
->xyThumbTop
= 0;
125 psbi
->xyThumbBottom
= 0;
130 ThumbBox
= psi
->nPage
? MINTRACKTHUMB
: UserGetSystemMetrics(SM_CXHTHUMB
);
136 ThumbBox
= max(EngMulDiv(cxy
, psi
->nPage
, psi
->nMax
- psi
->nMin
+ 1), ThumbBox
);
141 mx
= psi
->nMax
- max(psi
->nPage
- 1, 0);
143 ThumbPos
= Thumb
+ EngMulDiv(cxy
- ThumbBox
, psi
->nPos
- psi
->nMin
, mx
- psi
->nMin
);
145 ThumbPos
= Thumb
+ ThumbBox
;
148 psbi
->xyThumbTop
= ThumbPos
;
149 psbi
->xyThumbBottom
= ThumbPos
+ ThumbBox
;
153 psbi
->xyThumbTop
= 0;
154 psbi
->xyThumbBottom
= 0;
157 psbi
->dxyLineButton
= Thumb
;
163 IntUpdateSBInfo(PWND Window
, int wBar
)
169 ASSERT(Window
->pSBInfo
);
170 ASSERT(Window
->pSBInfoex
);
172 sbi
= IntGetScrollbarInfoFromWindow(Window
, wBar
);
173 psi
= IntGetScrollInfoFromWindow(Window
, wBar
);
174 IntGetScrollBarRect(Window
, wBar
, &(sbi
->rcScrollBar
));
175 IntCalculateThumb(Window
, wBar
, sbi
, psi
);
179 co_IntGetScrollInfo(PWND Window
, INT nBar
, LPSCROLLINFO lpsi
)
184 ASSERT_REFS_CO(Window
);
186 if(!SBID_IS_VALID(nBar
))
188 EngSetLastError(ERROR_INVALID_PARAMETER
);
189 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar
);
193 if (!Window
->pSBInfo
) return FALSE
;
195 psi
= IntGetScrollInfoFromWindow(Window
, nBar
);
197 if (lpsi
->fMask
== SIF_ALL
)
199 Mask
= SIF_PAGE
| SIF_POS
| SIF_RANGE
| SIF_TRACKPOS
;
206 if (0 != (Mask
& SIF_PAGE
))
208 lpsi
->nPage
= psi
->nPage
;
211 if (0 != (Mask
& SIF_POS
))
213 lpsi
->nPos
= psi
->nPos
;
216 if (0 != (Mask
& SIF_RANGE
))
218 lpsi
->nMin
= psi
->nMin
;
219 lpsi
->nMax
= psi
->nMax
;
222 if (0 != (Mask
& SIF_TRACKPOS
))
224 lpsi
->nTrackPos
= psi
->nTrackPos
;
231 NEWco_IntGetScrollInfo(
238 PSBTRACK pSBTrack
= pWnd
->head
.pti
->pSBTrack
;
240 if (!SBID_IS_VALID(nBar
))
242 EngSetLastError(ERROR_INVALID_PARAMETER
);
243 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar
);
247 if (!pWnd
->pSBInfo
|| !pSBTrack
) return FALSE
;
251 if (0 != (Mask
& SIF_PAGE
))
253 lpsi
->nPage
= pSBData
->page
;
256 if (0 != (Mask
& SIF_POS
))
258 lpsi
->nPos
= pSBData
->pos
;
261 if (0 != (Mask
& SIF_RANGE
))
263 lpsi
->nMin
= pSBData
->posMin
;
264 lpsi
->nMax
= pSBData
->posMax
;
267 if (0 != (Mask
& SIF_TRACKPOS
))
270 pSBTrack
->nBar
== nBar
&&
271 pSBTrack
->spwndTrack
== pWnd
)
272 lpsi
->nTrackPos
= pSBTrack
->posNew
;
274 lpsi
->nTrackPos
= pSBData
->pos
;
276 return (Mask
& SIF_ALL
) !=0;
279 static DWORD FASTCALL
280 co_IntSetScrollInfo(PWND Window
, INT nBar
, LPCSCROLLINFO lpsi
, BOOL bRedraw
)
283 * Update the scrollbar state and set action flags according to
284 * what has to be done graphics wise.
291 BOOL bChangeParams
= FALSE
; /* Don't show/hide scrollbar if params don't change */
293 ASSERT_REFS_CO(Window
);
295 if(!SBID_IS_VALID(nBar
))
297 EngSetLastError(ERROR_INVALID_PARAMETER
);
298 ERR("Trying to set scrollinfo for unknown scrollbar type %d", nBar
);
302 if(!co_IntCreateScrollBars(Window
))
307 if (lpsi
->cbSize
!= sizeof(SCROLLINFO
) &&
308 lpsi
->cbSize
!= (sizeof(SCROLLINFO
) - sizeof(lpsi
->nTrackPos
)))
310 EngSetLastError(ERROR_INVALID_PARAMETER
);
313 if (lpsi
->fMask
& ~(SIF_ALL
| SIF_DISABLENOSCROLL
))
315 EngSetLastError(ERROR_INVALID_PARAMETER
);
319 psbi
= IntGetScrollbarInfoFromWindow(Window
, nBar
);
320 Info
= IntGetScrollInfoFromWindow(Window
, nBar
);
322 /* Set the page size */
323 if (lpsi
->fMask
& SIF_PAGE
)
325 if (Info
->nPage
!= lpsi
->nPage
)
327 Info
->nPage
= lpsi
->nPage
;
328 bChangeParams
= TRUE
;
332 /* Set the scroll pos */
333 if (lpsi
->fMask
& SIF_POS
)
335 if (Info
->nPos
!= lpsi
->nPos
)
337 Info
->nPos
= lpsi
->nPos
;
338 bChangeParams
= TRUE
;
342 /* Set the scroll range */
343 if (lpsi
->fMask
& SIF_RANGE
)
345 /* Invalid range -> range is set to (0,0) */
346 if ((lpsi
->nMin
> lpsi
->nMax
) ||
347 ((UINT
)(lpsi
->nMax
- lpsi
->nMin
) >= 0x80000000))
351 bChangeParams
= TRUE
;
353 else if (Info
->nMin
!= lpsi
->nMin
|| Info
->nMax
!= lpsi
->nMax
)
355 Info
->nMin
= lpsi
->nMin
;
356 Info
->nMax
= lpsi
->nMax
;
357 bChangeParams
= TRUE
;
361 /* Make sure the page size is valid */
364 else if ((Info
->nMax
- Info
->nMin
+ 1UL) < Info
->nPage
)
366 Info
->nPage
= Info
->nMax
- Info
->nMin
+ 1;
369 /* Make sure the pos is inside the range */
370 if (Info
->nPos
< Info
->nMin
)
372 Info
->nPos
= Info
->nMin
;
374 else if (Info
->nPos
> (Info
->nMax
- max((int)Info
->nPage
- 1, 0)))
376 Info
->nPos
= Info
->nMax
- max(Info
->nPage
- 1, 0);
380 * Don't change the scrollbar state if SetScrollInfo is just called
381 * with SIF_DISABLENOSCROLL
383 if (!(lpsi
->fMask
& SIF_ALL
))
385 goto done
; //return Info->nPos;
388 /* Check if the scrollbar should be hidden or disabled */
389 if (lpsi
->fMask
& (SIF_RANGE
| SIF_PAGE
| SIF_DISABLENOSCROLL
))
391 new_flags
= Window
->pSBInfo
->WSBflags
;
392 if (Info
->nMin
>= (int)(Info
->nMax
- max(Info
->nPage
- 1, 0)))
394 /* Hide or disable scroll-bar */
395 if (lpsi
->fMask
& SIF_DISABLENOSCROLL
)
397 new_flags
= ESB_DISABLE_BOTH
;
398 bChangeParams
= TRUE
;
400 else if ((nBar
!= SB_CTL
) && bChangeParams
)
402 action
= SA_SSI_HIDE
;
405 else /* Show and enable scroll-bar only if no page only changed. */
406 if (lpsi
->fMask
!= SIF_PAGE
)
408 new_flags
= ESB_ENABLE_BOTH
;
409 if ((nBar
!= SB_CTL
) && bChangeParams
)
411 action
|= SA_SSI_SHOW
;
415 if (Window
->pSBInfo
->WSBflags
!= new_flags
) /* Check arrow flags */
417 Window
->pSBInfo
->WSBflags
= new_flags
;
418 action
|= SA_SSI_REPAINT_ARROWS
;
423 if ( action
& SA_SSI_HIDE
)
425 co_UserShowScrollBar(Window
, nBar
, FALSE
, FALSE
);
429 if ( action
& SA_SSI_SHOW
)
430 if ( co_UserShowScrollBar(Window
, nBar
, TRUE
, TRUE
) )
431 return Info
->nPos
; /* SetWindowPos() already did the painting */
433 { // FIXME: Arrows and interior.
434 RECTL UpdateRect
= psbi
->rcScrollBar
;
435 UpdateRect
.left
-= Window
->rcClient
.left
- Window
->rcWindow
.left
;
436 UpdateRect
.right
-= Window
->rcClient
.left
- Window
->rcWindow
.left
;
437 UpdateRect
.top
-= Window
->rcClient
.top
- Window
->rcWindow
.top
;
438 UpdateRect
.bottom
-= Window
->rcClient
.top
- Window
->rcWindow
.top
;
439 co_UserRedrawWindow(Window
, &UpdateRect
, 0, RDW_INVALIDATE
| RDW_FRAME
);
441 else if( action
& SA_SSI_REPAINT_ARROWS
)
443 RECTL UpdateRect
= psbi
->rcScrollBar
;
444 UpdateRect
.left
-= Window
->rcClient
.left
- Window
->rcWindow
.left
;
445 UpdateRect
.right
-= Window
->rcClient
.left
- Window
->rcWindow
.left
;
446 UpdateRect
.top
-= Window
->rcClient
.top
- Window
->rcWindow
.top
;
447 UpdateRect
.bottom
-= Window
->rcClient
.top
- Window
->rcWindow
.top
;
448 co_UserRedrawWindow(Window
, &UpdateRect
, 0, RDW_INVALIDATE
| RDW_FRAME
);
451 /* Return current position */
456 co_IntGetScrollBarInfo(PWND Window
, LONG idObject
, PSCROLLBARINFO psbi
)
461 ASSERT_REFS_CO(Window
);
463 Bar
= SBOBJ_TO_SBID(idObject
);
465 if(!SBID_IS_VALID(Bar
))
467 EngSetLastError(ERROR_INVALID_PARAMETER
);
468 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar
);
472 if(!co_IntCreateScrollBars(Window
))
477 sbi
= IntGetScrollbarInfoFromWindow(Window
, Bar
);
478 psi
= IntGetScrollInfoFromWindow(Window
, Bar
);
480 IntGetScrollBarRect(Window
, Bar
, &(sbi
->rcScrollBar
));
481 IntCalculateThumb(Window
, Bar
, sbi
, psi
);
483 RtlCopyMemory(psbi
, sbi
, sizeof(SCROLLBARINFO
));
489 co_IntCreateScrollBars(PWND Window
)
496 ASSERT_REFS_CO(Window
);
498 if (Window
->pSBInfo
&& Window
->pSBInfoex
)
500 /* No need to create it anymore */
504 /* Allocate memory for all scrollbars (HORZ, VERT, CONTROL) */
505 Size
= 3 * (sizeof(SBINFOEX
));
506 if(!(Window
->pSBInfoex
= ExAllocatePoolWithTag(PagedPool
, Size
, TAG_SBARINFO
)))
508 ERR("Unable to allocate memory for scrollbar information for window 0x%x\n", Window
->head
.h
);
512 RtlZeroMemory(Window
->pSBInfoex
, Size
);
514 if(!(Window
->pSBInfo
= DesktopHeapAlloc( Window
->head
.rpdesk
, sizeof(SBINFO
))))
516 ERR("Unable to allocate memory for scrollbar information for window 0x%x\n", Window
->head
.h
);
520 RtlZeroMemory(Window
->pSBInfo
, sizeof(SBINFO
));
521 Window
->pSBInfo
->Vert
.posMax
= 100;
522 Window
->pSBInfo
->Horz
.posMax
= 100;
524 co_WinPosGetNonClientSize(Window
,
528 for(s
= SB_HORZ
; s
<= SB_VERT
; s
++)
530 psbi
= IntGetScrollbarInfoFromWindow(Window
, s
);
531 psbi
->cbSize
= sizeof(SCROLLBARINFO
);
532 for (i
= 0; i
< CCHILDREN_SCROLLBAR
+ 1; i
++)
533 psbi
->rgstate
[i
] = 0;
535 psi
= IntGetScrollInfoFromWindow(Window
, s
);
536 psi
->cbSize
= sizeof(LPSCROLLINFO
);
539 IntGetScrollBarRect(Window
, s
, &(psbi
->rcScrollBar
));
540 IntCalculateThumb(Window
, s
, psbi
, psi
);
547 IntDestroyScrollBars(PWND Window
)
549 if (Window
->pSBInfo
&& Window
->pSBInfoex
)
551 DesktopHeapFree(Window
->head
.rpdesk
, Window
->pSBInfo
);
552 Window
->pSBInfo
= NULL
;
553 ExFreePool(Window
->pSBInfoex
);
554 Window
->pSBInfoex
= NULL
;
561 IntEnableScrollBar(BOOL Horz
, PSCROLLBARINFO Info
, UINT wArrows
)
566 case ESB_DISABLE_BOTH
:
567 CHANGERGSTATE(SBRG_TOPRIGHTBTN
, STATE_SYSTEM_UNAVAILABLE
);
568 CHANGERGSTATE(SBRG_BOTTOMLEFTBTN
, STATE_SYSTEM_UNAVAILABLE
);
570 case ESB_DISABLE_RTDN
:
573 CHANGERGSTATE(SBRG_BOTTOMLEFTBTN
, STATE_SYSTEM_UNAVAILABLE
);
577 CHANGERGSTATE(SBRG_TOPRIGHTBTN
, STATE_SYSTEM_UNAVAILABLE
);
580 case ESB_DISABLE_LTUP
:
583 CHANGERGSTATE(SBRG_TOPRIGHTBTN
, STATE_SYSTEM_UNAVAILABLE
);
587 CHANGERGSTATE(SBRG_BOTTOMLEFTBTN
, STATE_SYSTEM_UNAVAILABLE
);
590 case ESB_ENABLE_BOTH
:
591 CHANGERGSTATE(SBRG_TOPRIGHTBTN
, 0);
592 CHANGERGSTATE(SBRG_BOTTOMLEFTBTN
, 0);
598 /* Ported from WINE20020904 (SCROLL_ShowScrollBar) */
600 co_UserShowScrollBar(PWND Wnd
, int nBar
, BOOL fShowH
, BOOL fShowV
)
602 ULONG old_style
, set_bits
= 0, clear_bits
= 0;
610 if (Wnd
->pSBInfo
) IntUpdateSBInfo(Wnd
, SB_CTL
); // Is this needed? Was tested w/o!
612 co_WinPosShowWindow(Wnd
, fShowH
? SW_SHOW
: SW_HIDE
);
617 if (fShowH
) set_bits
|= WS_HSCROLL
;
618 else clear_bits
|= WS_HSCROLL
;
619 if( nBar
== SB_HORZ
) break;
622 if (fShowV
) set_bits
|= WS_VSCROLL
;
623 else clear_bits
|= WS_VSCROLL
;
626 EngSetLastError(ERROR_INVALID_PARAMETER
);
631 old_style
= Wnd
->style
;
632 Wnd
->style
= (Wnd
->style
| set_bits
) & ~clear_bits
;
634 if (fShowH
|| fShowV
)
636 if (!Wnd
->pSBInfo
) co_IntCreateScrollBars(Wnd
);
639 if ((old_style
& clear_bits
) != 0 || (old_style
& set_bits
) != set_bits
)
641 ///// Is this needed? Was tested w/o!
642 if (Wnd
->style
& WS_HSCROLL
) IntUpdateSBInfo(Wnd
, SB_HORZ
);
643 if (Wnd
->style
& WS_VSCROLL
) IntUpdateSBInfo(Wnd
, SB_VERT
);
645 /* Frame has been changed, let the window redraw itself */
646 co_WinPosSetWindowPos(Wnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
647 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
| SWP_NOSENDCHANGING
);
657 NtUserGetScrollBarInfo(HWND hWnd
, LONG idObject
, PSCROLLBARINFO psbi
)
663 DECLARE_RETURN(BOOL
);
664 USER_REFERENCE_ENTRY Ref
;
666 TRACE("Enter NtUserGetScrollBarInfo\n");
667 UserEnterExclusive();
669 Status
= MmCopyFromCaller(&sbi
, psbi
, sizeof(SCROLLBARINFO
));
670 if(!NT_SUCCESS(Status
) || (sbi
.cbSize
!= sizeof(SCROLLBARINFO
)))
672 SetLastNtError(Status
);
676 if(!(Window
= UserGetWindowObject(hWnd
)))
681 UserRefObjectCo(Window
, &Ref
);
682 Ret
= co_IntGetScrollBarInfo(Window
, idObject
, &sbi
);
683 UserDerefObjectCo(Window
);
685 Status
= MmCopyToCaller(psbi
, &sbi
, sizeof(SCROLLBARINFO
));
686 if(!NT_SUCCESS(Status
))
688 SetLastNtError(Status
);
695 TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_
);
714 DECLARE_RETURN(BOOL
);
715 USER_REFERENCE_ENTRY Ref
;
717 TRACE("Enter NtUserGetScrollInfo\n");
718 UserEnterExclusive();
720 Status
= MmCopyFromCaller(&psi
.cbSize
, &(lpsi
->cbSize
), sizeof(UINT
));
721 if(!NT_SUCCESS(Status
) ||
722 !((psi
.cbSize
== sizeof(SCROLLINFO
)) || (psi
.cbSize
== sizeof(SCROLLINFO
) - sizeof(psi
.nTrackPos
))))
724 SetLastNtError(Status
);
728 Status
= MmCopyFromCaller(&psi
, lpsi
, sz
);
729 if (!NT_SUCCESS(Status
))
731 SetLastNtError(Status
);
735 if(!(Window
= UserGetWindowObject(hWnd
)))
740 UserRefObjectCo(Window
, &Ref
);
741 Ret
= co_IntGetScrollInfo(Window
, fnBar
, &psi
);
742 UserDerefObjectCo(Window
);
744 Status
= MmCopyToCaller(lpsi
, &psi
, sz
);
745 if(!NT_SUCCESS(Status
))
747 SetLastNtError(Status
);
754 TRACE("Leave NtUserGetScrollInfo, ret=%i\n",_ret_
);
761 NtUserEnableScrollBar(
768 PSCROLLBARINFO InfoV
= NULL
, InfoH
= NULL
;
770 DECLARE_RETURN(BOOL
);
771 USER_REFERENCE_ENTRY Ref
;
773 TRACE("Enter NtUserEnableScrollBar\n");
774 UserEnterExclusive();
776 if (!(Window
= UserGetWindowObject(hWnd
)))
780 UserRefObjectCo(Window
, &Ref
);
782 if (!co_IntCreateScrollBars(Window
))
787 OrigArrows
= Window
->pSBInfo
->WSBflags
;
788 Window
->pSBInfo
->WSBflags
= wArrows
;
790 if (wSBflags
== SB_CTL
)
792 if ((wArrows
== ESB_DISABLE_BOTH
|| wArrows
== ESB_ENABLE_BOTH
))
793 IntEnableWindow(hWnd
, (wArrows
== ESB_ENABLE_BOTH
));
798 if(wSBflags
!= SB_BOTH
&& !SBID_IS_VALID(wSBflags
))
800 EngSetLastError(ERROR_INVALID_PARAMETER
);
801 ERR("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags
);
808 InfoV
= IntGetScrollbarInfoFromWindow(Window
, SB_VERT
);
811 InfoH
= IntGetScrollbarInfoFromWindow(Window
, SB_HORZ
);
814 InfoV
= IntGetScrollbarInfoFromWindow(Window
, SB_VERT
);
821 Chg
= IntEnableScrollBar(FALSE
, InfoV
, wArrows
);
824 Chg
= (IntEnableScrollBar(TRUE
, InfoH
, wArrows
) || Chg
);
826 ERR("FIXME: EnableScrollBar wSBflags %d wArrows %d Chg %d\n",wSBflags
,wArrows
, Chg
);
828 // SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
830 if (OrigArrows
== wArrows
) RETURN( FALSE
);
835 UserDerefObjectCo(Window
);
837 TRACE("Leave NtUserEnableScrollBar, ret=%i\n",_ret_
);
852 SCROLLINFO ScrollInfo
;
853 DECLARE_RETURN(DWORD
);
854 USER_REFERENCE_ENTRY Ref
;
856 TRACE("Enter NtUserSetScrollInfo\n");
857 UserEnterExclusive();
859 if(!(Window
= UserGetWindowObject(hWnd
)))
863 UserRefObjectCo(Window
, &Ref
);
865 Status
= MmCopyFromCaller(&ScrollInfo
, lpsi
, sizeof(SCROLLINFO
) - sizeof(ScrollInfo
.nTrackPos
));
866 if(!NT_SUCCESS(Status
))
868 SetLastNtError(Status
);
872 RETURN(co_IntSetScrollInfo(Window
, fnBar
, &ScrollInfo
, bRedraw
));
876 UserDerefObjectCo(Window
);
878 TRACE("Leave NtUserSetScrollInfo, ret=%i\n",_ret_
);
885 NtUserShowScrollBar(HWND hWnd
, int nBar
, DWORD bShow
)
888 DECLARE_RETURN(DWORD
);
890 USER_REFERENCE_ENTRY Ref
;
892 TRACE("Enter NtUserShowScrollBar\n");
893 UserEnterExclusive();
895 if (!(Window
= UserGetWindowObject(hWnd
)))
900 UserRefObjectCo(Window
, &Ref
);
901 ret
= co_UserShowScrollBar(Window
, nBar
, (nBar
== SB_VERT
) ? 0 : bShow
,
902 (nBar
== SB_HORZ
) ? 0 : bShow
);
903 UserDerefObjectCo(Window
);
908 TRACE("Leave NtUserShowScrollBar, ret%i\n",_ret_
);
915 //// Ugly NtUser API ////
919 NtUserSetScrollBarInfo(
922 SETSCROLLBARINFO
*info
)
925 SETSCROLLBARINFO Safeinfo
;
930 DECLARE_RETURN(BOOL
);
931 USER_REFERENCE_ENTRY Ref
;
933 TRACE("Enter NtUserSetScrollBarInfo\n");
934 UserEnterExclusive();
936 if(!(Window
= UserGetWindowObject(hWnd
)))
940 UserRefObjectCo(Window
, &Ref
);
942 Obj
= SBOBJ_TO_SBID(idObject
);
943 if(!SBID_IS_VALID(Obj
))
945 EngSetLastError(ERROR_INVALID_PARAMETER
);
946 ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", Obj
);
950 if(!co_IntCreateScrollBars(Window
))
955 Status
= MmCopyFromCaller(&Safeinfo
, info
, sizeof(SETSCROLLBARINFO
));
956 if(!NT_SUCCESS(Status
))
958 SetLastNtError(Status
);
962 sbi
= IntGetScrollbarInfoFromWindow(Window
, Obj
);
963 psi
= IntGetScrollInfoFromWindow(Window
, Obj
);
965 psi
->nTrackPos
= Safeinfo
.nTrackPos
;
966 sbi
->reserved
= Safeinfo
.reserved
;
967 RtlCopyMemory(&sbi
->rgstate
, &Safeinfo
.rgstate
, sizeof(Safeinfo
.rgstate
));
973 UserDerefObjectCo(Window
);
975 TRACE("Leave NtUserSetScrollBarInfo, ret=%i\n",_ret_
);