ReactOS 0.4.16-dev-1405-gc14a14e
scrollbar.c File Reference
#include <win32k.h>
Include dependency graph for scrollbar.c:

Go to the source code of this file.

Macros

#define SCROLL_NOWHERE   0x00 /* Outside the scrollbar */
 
#define SCROLL_TOP_ARROW   0x01 /* Top or left arrow */
 
#define SCROLL_TOP_RECT   0x02 /* Rectangle between the top arrow and the thumb */
 
#define SCROLL_THUMB   0x03 /* Thumb rectangle */
 
#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_REPEAT_DELAY   50 /* Delay (in ms) between scroll repetitions */
 
#define SCROLL_TIMER   0 /* Scroll timer id */
 
#define SCROLL_MIN_RECT   4
 
#define SCROLL_MIN_THUMB   6
 
#define SCROLL_ARROW_THUMB_OVERLAP   0
 
#define MINTRACKTHUMB   8 /* Minimum size of the rectangle between the arrows */
 
#define SA_SSI_HIDE   0x0001
 
#define SA_SSI_SHOW   0x0002
 
#define SA_SSI_REFRESH   0x0004
 
#define SA_SSI_REPAINT_ARROWS   0x0008
 
#define SBRG_SCROLLBAR   0 /* The scrollbar itself */
 
#define SBRG_TOPRIGHTBTN   1 /* The top or right button */
 
#define SBRG_PAGEUPRIGHT   2 /* The page up or page right region */
 
#define SBRG_SCROLLBOX   3 /* The scroll box */
 
#define SBRG_PAGEDOWNLEFT   4 /* The page down or page left region */
 
#define SBRG_BOTTOMLEFTBTN   5 /* The bottom or left button */
 
#define CHANGERGSTATE(item, status)
 

Functions

 DBG_DEFAULT_CHANNEL (UserScrollbar)
 
BOOL APIENTRY IntEnableScrollBar (BOOL Horz, PSCROLLBARINFO Info, UINT wArrows)
 
static void IntRefeshScrollInterior (PWND pWnd, INT nBar, PSCROLLBARINFO psbi)
 
static void mirror_rect (const RECT *window_rect, RECT *rect)
 
PSBDATA FASTCALL IntGetSBData (PWND pwnd, INT Bar)
 
BOOL FASTCALL IntGetScrollBarRect (PWND Wnd, INT nBar, RECTL *lprect)
 
BOOL FASTCALL IntCalculateThumb (PWND Wnd, LONG idObject, PSCROLLBARINFO psbi, PSBDATA pSBData)
 
static BOOL FASTCALL co_IntGetScrollInfo (PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
 
BOOL FASTCALL NEWco_IntGetScrollInfo (PWND pWnd, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
 
static DWORD FASTCALL co_IntSetScrollInfo (PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
 
BOOL FASTCALL co_IntGetScrollBarInfo (PWND Window, LONG idObject, PSCROLLBARINFO psbi)
 
BOOL FASTCALL co_IntSetScrollBarInfo (PWND Window, LONG idObject, PSETSCROLLBARINFO psbi)
 
BOOL FASTCALL co_IntCreateScrollBars (PWND Window)
 
BOOL FASTCALL IntDestroyScrollBars (PWND Window)
 
DWORD FASTCALL co_UserShowScrollBar (PWND Wnd, int nBar, BOOL fShowH, BOOL fShowV)
 
static void IntDrawScrollInterior (PWND pWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINFO ScrollBarInfo)
 
static VOID FASTCALL IntDrawScrollArrows (HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
 
static LONG FASTCALL IntScrollGetObjectId (INT SBType)
 
void IntDrawScrollBar (PWND Wnd, HDC DC, INT Bar)
 
LRESULT APIENTRY ScrollBarWndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL APIENTRY NtUserGetScrollBarInfo (HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
 
BOOL APIENTRY NtUserSBGetParms (HWND hWnd, int fnBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
 
BOOL APIENTRY NtUserEnableScrollBar (HWND hWnd, UINT wSBflags, UINT wArrows)
 
DWORD APIENTRY NtUserSetScrollInfo (HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
 
DWORD APIENTRY NtUserShowScrollBar (HWND hWnd, int nBar, DWORD bShow)
 
BOOL APIENTRY NtUserSetScrollBarInfo (HWND hWnd, LONG idObject, SETSCROLLBARINFO *info)
 

Macro Definition Documentation

◆ CHANGERGSTATE

#define CHANGERGSTATE (   item,
  status 
)
Value:
if(Info->rgstate[(item)] != (status)) \
Chg = TRUE; \
Info->rgstate[(item)] = (status);
#define TRUE
Definition: types.h:120
Definition: ps.c:97
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Definition at line 49 of file scrollbar.c.

◆ MINTRACKTHUMB

#define MINTRACKTHUMB   8 /* Minimum size of the rectangle between the arrows */

Definition at line 34 of file scrollbar.c.

◆ SA_SSI_HIDE

#define SA_SSI_HIDE   0x0001

Definition at line 37 of file scrollbar.c.

◆ SA_SSI_REFRESH

#define SA_SSI_REFRESH   0x0004

Definition at line 39 of file scrollbar.c.

◆ SA_SSI_REPAINT_ARROWS

#define SA_SSI_REPAINT_ARROWS   0x0008

Definition at line 40 of file scrollbar.c.

◆ SA_SSI_SHOW

#define SA_SSI_SHOW   0x0002

Definition at line 38 of file scrollbar.c.

◆ SBRG_BOTTOMLEFTBTN

#define SBRG_BOTTOMLEFTBTN   5 /* The bottom or left button */

Definition at line 47 of file scrollbar.c.

◆ SBRG_PAGEDOWNLEFT

#define SBRG_PAGEDOWNLEFT   4 /* The page down or page left region */

Definition at line 46 of file scrollbar.c.

◆ SBRG_PAGEUPRIGHT

#define SBRG_PAGEUPRIGHT   2 /* The page up or page right region */

Definition at line 44 of file scrollbar.c.

◆ SBRG_SCROLLBAR

#define SBRG_SCROLLBAR   0 /* The scrollbar itself */

Definition at line 42 of file scrollbar.c.

◆ SBRG_SCROLLBOX

#define SBRG_SCROLLBOX   3 /* The scroll box */

Definition at line 45 of file scrollbar.c.

◆ SBRG_TOPRIGHTBTN

#define SBRG_TOPRIGHTBTN   1 /* The top or right button */

Definition at line 43 of file scrollbar.c.

◆ SCROLL_ARROW_THUMB_OVERLAP

#define SCROLL_ARROW_THUMB_OVERLAP   0

Definition at line 32 of file scrollbar.c.

◆ SCROLL_BOTTOM_ARROW

#define SCROLL_BOTTOM_ARROW   0x05 /* Bottom or right arrow */

Definition at line 18 of file scrollbar.c.

◆ SCROLL_BOTTOM_RECT

#define SCROLL_BOTTOM_RECT   0x04 /* Rectangle between the thumb and the bottom arrow */

Definition at line 17 of file scrollbar.c.

◆ SCROLL_FIRST_DELAY

#define SCROLL_FIRST_DELAY   200 /* Delay (in ms) before first repetition when holding the button down */

Definition at line 20 of file scrollbar.c.

◆ SCROLL_MIN_RECT

#define SCROLL_MIN_RECT   4

Definition at line 26 of file scrollbar.c.

◆ SCROLL_MIN_THUMB

#define SCROLL_MIN_THUMB   6

Definition at line 29 of file scrollbar.c.

◆ SCROLL_NOWHERE

#define SCROLL_NOWHERE   0x00 /* Outside the scrollbar */

Definition at line 13 of file scrollbar.c.

◆ SCROLL_REPEAT_DELAY

#define SCROLL_REPEAT_DELAY   50 /* Delay (in ms) between scroll repetitions */

Definition at line 21 of file scrollbar.c.

◆ SCROLL_THUMB

#define SCROLL_THUMB   0x03 /* Thumb rectangle */

Definition at line 16 of file scrollbar.c.

◆ SCROLL_TIMER

#define SCROLL_TIMER   0 /* Scroll timer id */

Definition at line 23 of file scrollbar.c.

◆ SCROLL_TOP_ARROW

#define SCROLL_TOP_ARROW   0x01 /* Top or left arrow */

Definition at line 14 of file scrollbar.c.

◆ SCROLL_TOP_RECT

#define SCROLL_TOP_RECT   0x02 /* Rectangle between the top arrow and the thumb */

Definition at line 15 of file scrollbar.c.

Function Documentation

◆ co_IntCreateScrollBars()

BOOL FASTCALL co_IntCreateScrollBars ( PWND  Window)

Definition at line 758 of file scrollbar.c.

759{
760 PSCROLLBARINFO psbi;
761 PSBDATA pSBData;
762 ULONG Size, s;
763 INT i;
764
766
767 if (Window->pSBInfo && Window->pSBInfoex)
768 return TRUE; // No need to create it anymore
769
770 // Allocate memory for all scrollbars (HORZ, VERT, CONTROL)
771 Size = 3 * (sizeof(SBINFOEX));
773 {
774 ERR("Unable to allocate memory for scrollbar information for window %p\n", UserHMGetHandle(Window));
775 return FALSE;
776 }
777
778 RtlZeroMemory(Window->pSBInfoex, Size);
779
780 if(!(Window->pSBInfo = DesktopHeapAlloc(Window->head.rpdesk, sizeof(SBINFO))))
781 {
782 ERR("Unable to allocate memory for scrollbar information for window %p\n", UserHMGetHandle(Window));
783 return FALSE;
784 }
785
786 RtlZeroMemory(Window->pSBInfo, sizeof(SBINFO));
787 Window->pSBInfo->Vert.posMax = 100;
788 Window->pSBInfo->Horz.posMax = 100;
789
790 co_WinPosGetNonClientSize(Window, &Window->rcWindow, &Window->rcClient);
791
792 for(s = SB_HORZ; s <= SB_VERT; s++)
793 {
795 psbi->cbSize = sizeof(SCROLLBARINFO);
796 for (i = 0; i < CCHILDREN_SCROLLBAR + 1; i++)
797 psbi->rgstate[i] = 0;
798
799 pSBData = IntGetSBData(Window, s);
800 ASSERT(pSBData != NULL);
801
803 IntCalculateThumb(Window, s, psbi, pSBData);
804 }
805
806 return TRUE;
807}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
GLdouble s
Definition: gl.h:2039
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
struct _SBINFOEX SBINFOEX
#define ASSERT(a)
Definition: mode.c:44
PSBDATA FASTCALL IntGetSBData(PWND pwnd, INT Bar)
Definition: scrollbar.c:77
BOOL FASTCALL IntCalculateThumb(PWND Wnd, LONG idObject, PSCROLLBARINFO psbi, PSBDATA pSBData)
Definition: scrollbar.c:166
BOOL FASTCALL IntGetScrollBarRect(PWND Wnd, INT nBar, RECTL *lprect)
Definition: scrollbar.c:104
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2387
#define IntGetScrollbarInfoFromWindow(Window, i)
Definition: scroll.h:33
Definition: window.c:28
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3830
int32_t INT
Definition: typedefs.h:58
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
#define TAG_SBARINFO
Definition: tags.h:9
#define SB_VERT
Definition: winuser.h:553
#define CCHILDREN_SCROLLBAR
Definition: winuser.h:3821
struct tagSCROLLBARINFO SCROLLBARINFO
#define SB_HORZ
Definition: winuser.h:552

Referenced by co_IntGetScrollBarInfo(), co_IntSetScrollBarInfo(), co_IntSetScrollInfo(), NtUserEnableScrollBar(), and NtUserSetScrollBarInfo().

◆ co_IntGetScrollBarInfo()

BOOL FASTCALL co_IntGetScrollBarInfo ( PWND  Window,
LONG  idObject,
PSCROLLBARINFO  psbi 
)

Definition at line 671 of file scrollbar.c.

672{
673 INT Bar;
674 PSCROLLBARINFO sbi;
675 PSBDATA pSBData;
677
678 Bar = SBOBJ_TO_SBID(idObject);
679
680 if(!SBID_IS_VALID(Bar))
681 {
683 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar);
684 return FALSE;
685 }
686
688 {
689 ERR("Failed to create scrollbars for window\n");
690 return FALSE;
691 }
692
694 pSBData = IntGetSBData(Window, Bar);
695 if (pSBData == NULL)
696 {
697 ERR("co_IntGetScrollBarInfo: No scrollbar info for window %p, bar %d\n", UserHMGetHandle(Window), Bar);
698 return FALSE;
699 }
700
702 IntCalculateThumb(Window, Bar, sbi, pSBData);
703
704 // Scrollbar state
705 psbi->rgstate[0] = 0;
706 if ((Bar == SB_HORZ && !(Window->style & WS_HSCROLL))
707 || (Bar == SB_VERT && !(Window->style & WS_VSCROLL)))
709 if (pSBData->posMin >= pSBData->posMax - max(pSBData->page - 1, 0))
710 {
711 if (!(psbi->rgstate[0] & STATE_SYSTEM_INVISIBLE))
713 else
715 }
716 if (Bar == SB_CTL && !(Window->style & WS_DISABLED))
718
719 RtlCopyMemory(psbi, sbi, sizeof(SCROLLBARINFO));
720
721 return TRUE;
722}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
void Bar(void)
Definition: terminate.cpp:70
BOOL FASTCALL co_IntCreateScrollBars(PWND Window)
Definition: scrollbar.c:758
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_DISABLED
Definition: pedump.c:621
#define WS_HSCROLL
Definition: pedump.c:628
#define SBID_IS_VALID(id)
Definition: scroll.h:40
#define SBOBJ_TO_SBID(Obj)
Definition: scroll.h:39
INT posMax
Definition: ntuser.h:506
INT posMin
Definition: ntuser.h:505
INT page
Definition: ntuser.h:507
#define max(a, b)
Definition: svc.c:63
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2953
#define STATE_SYSTEM_OFFSCREEN
Definition: winuser.h:2954
#define STATE_SYSTEM_UNAVAILABLE
Definition: winuser.h:2938
#define SB_CTL
Definition: winuser.h:554

Referenced by IntDrawScrollBar(), IntIsScrollBarVisible(), IntRefeshScrollInterior(), and NtUserGetScrollBarInfo().

◆ co_IntGetScrollInfo()

static BOOL FASTCALL co_IntGetScrollInfo ( PWND  Window,
INT  nBar,
PSBDATA  pSBData,
LPSCROLLINFO  lpsi 
)
static

Definition at line 264 of file scrollbar.c.

265{
266 UINT Mask;
267 LPSCROLLINFO psi;
268
270
271 lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
272 if(!SBID_IS_VALID(nBar))
273 {
275 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
276 return FALSE;
277 }
278
279 if (!Window->pSBInfo)
280 {
281 ERR("IntGetScrollInfo No window scrollbar info\n");
282 return FALSE;
283 }
284
286
287 if (lpsi->fMask == SIF_ALL)
289 else
290 Mask = lpsi->fMask;
291
292 if (0 != (Mask & SIF_PAGE))
293 lpsi->nPage = psi->nPage;
294
295 if (0 != (Mask & SIF_POS))
296 lpsi->nPos = psi->nPos;
297
298 if (0 != (Mask & SIF_RANGE))
299 {
300 lpsi->nMin = psi->nMin;
301 lpsi->nMax = psi->nMax;
302 }
303
304 if (0 != (Mask & SIF_TRACKPOS))
305 lpsi->nTrackPos = psi->nTrackPos;
306
307 return TRUE;
308}
unsigned int Mask
Definition: fpcontrol.c:82
unsigned int UINT
Definition: ndis.h:50
#define IntGetScrollInfoFromWindow(Window, i)
Definition: scroll.h:36
#define SIF_RANGE
Definition: winuser.h:1246
#define SIF_PAGE
Definition: winuser.h:1244
#define SIF_TRACKPOS
Definition: winuser.h:1248
#define SIF_ALL
Definition: winuser.h:1243
#define SIF_POS
Definition: winuser.h:1245

Referenced by NtUserSBGetParms().

◆ co_IntSetScrollBarInfo()

BOOL FASTCALL co_IntSetScrollBarInfo ( PWND  Window,
LONG  idObject,
PSETSCROLLBARINFO  psbi 
)

Definition at line 725 of file scrollbar.c.

726{
727 INT Bar;
728 PSCROLLBARINFO sbi;
729 LPSCROLLINFO psi;
731
732 Bar = SBOBJ_TO_SBID(idObject);
733
734 if(!SBID_IS_VALID(Bar))
735 {
737 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar);
738 return FALSE;
739 }
740
742 {
743 ERR("Failed to create scrollbars for window\n");
744 return FALSE;
745 }
746
749
750 psi->nTrackPos = psbi->nTrackPos;
751 sbi->reserved = psbi->reserved;
752 RtlCopyMemory(&sbi->rgstate, &psbi->rgstate, sizeof(psbi->rgstate));
753
754 return TRUE;
755}
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: ntuser.h:3645

◆ co_IntSetScrollInfo()

static DWORD FASTCALL co_IntSetScrollInfo ( PWND  Window,
INT  nBar,
LPCSCROLLINFO  lpsi,
BOOL  bRedraw 
)
static

Definition at line 455 of file scrollbar.c.

456{
457 // Update the scrollbar state and set action flags according to
458 // what has to be done graphics wise.
459
461 PSCROLLBARINFO psbi;
462 UINT new_flags;
463 INT action = 0;
464 PSBDATA pSBData;
465 DWORD OldPos = 0;
466 BOOL bChangeParams = FALSE; // Don't show/hide scrollbar if params don't change
467 UINT MaxPage;
468 int MaxPos;
469 BOOL bVisible;
470
472
473 if(!SBID_IS_VALID(nBar))
474 {
476 ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", nBar);
477 return FALSE;
478 }
479
481 return FALSE;
482
483 if (lpsi->cbSize != sizeof(SCROLLINFO) &&
484 lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos)))
485 {
487 return 0;
488 }
490 {
492 return 0;
493 }
494
497 pSBData = IntGetSBData(Window, nBar);
498 if (pSBData == NULL)
499 {
500 ERR("co_IntSetScrollInfo: No SBDATA for window %p, bar %d\n", UserHMGetHandle(Window), nBar);
501 return FALSE;
502 }
503
504 if (lpsi->fMask & SIF_THEMED && !(Info->fMask & SIF_THEMED))
505 Info->fMask |= SIF_THEMED;
506
507 // Set the page size
508 if (lpsi->fMask & SIF_PAGE)
509 {
510 if (Info->nPage != lpsi->nPage)
511 {
512 Info->nPage = lpsi->nPage;
513 pSBData->page = lpsi->nPage;
514 bChangeParams = TRUE;
515 }
516 }
517
518 // Set the scroll pos
519 if (lpsi->fMask & SIF_POS)
520 {
521 OldPos = Info->nPos;
522 if (Info->nPos != lpsi->nPos)
523 {
524 Info->nPos = lpsi->nPos;
525 pSBData->pos = lpsi->nPos;
526 }
527 }
528
529 // Set the scroll range
530 if (lpsi->fMask & SIF_RANGE)
531 {
532 if (lpsi->nMin > lpsi->nMax)
533 {
534 Info->nMin = lpsi->nMin;
535 Info->nMax = lpsi->nMin;
536 pSBData->posMin = lpsi->nMin;
537 pSBData->posMax = lpsi->nMin;
538 bChangeParams = TRUE;
539 }
540 else if (Info->nMin != lpsi->nMin || Info->nMax != lpsi->nMax)
541 {
542 Info->nMin = lpsi->nMin;
543 Info->nMax = lpsi->nMax;
544 pSBData->posMin = lpsi->nMin;
545 pSBData->posMax = lpsi->nMax;
546 bChangeParams = TRUE;
547 }
548 }
549
550 // Make sure the page size is valid
551 MaxPage = abs(Info->nMax - Info->nMin) + 1;
552 if (Info->nPage > MaxPage)
553 pSBData->page = Info->nPage = MaxPage;
554
555 // Make sure the pos is inside the range
556 MaxPos = Info->nMax + 1 - (int)max(Info->nPage, 1);
557 ASSERT(MaxPos >= Info->nMin);
558 if (Info->nPos < Info->nMin)
559 pSBData->pos = Info->nPos = Info->nMin;
560 else if (Info->nPos > MaxPos)
561 pSBData->pos = Info->nPos = MaxPos;
562
563 // Don't change the scrollbar state if SetScrollInfo is just called with SIF_DISABLENOSCROLL
564 if (!(lpsi->fMask & SIF_ALL))
565 return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos;
566
567 // Check if the scrollbar should be hidden or disabled
569 {
570 new_flags = Window->pSBInfo->WSBflags;
571 if (Info->nMin + (int)max(Info->nPage, 1) > Info->nMax)
572 {
573 // Hide or disable scrollbar
574 if (lpsi->fMask & SIF_DISABLENOSCROLL)
575 {
576 new_flags = ESB_DISABLE_BOTH;
577 bChangeParams = TRUE;
578 }
579 else if ((nBar != SB_CTL) && bChangeParams)
580 {
582 }
583 }
584 else if ((lpsi->fMask & ~SIF_THEMED) != SIF_PAGE)
585 { // Show and enable scrollbar only if no page only changed
586 if ((nBar != SB_CTL) && bChangeParams)
587 {
588 new_flags = ESB_ENABLE_BOTH;
590 }
591 else if (nBar == SB_CTL)
592 {
593 new_flags = ESB_ENABLE_BOTH;
594 }
595 }
596
597 if (Window->pSBInfo->WSBflags != new_flags) // Check arrow flags
598 {
599 Window->pSBInfo->WSBflags = new_flags;
601 }
602 }
603
604 if (action & SA_SSI_HIDE)
605 {
607 }
608 else
609 {
610 if (action & SA_SSI_SHOW)
612 return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; // SetWindowPos() already did the painting
613
614 switch (nBar)
615 {
616 case SB_HORZ:
617 bVisible = (Window->style & WS_HSCROLL);
618 break;
619 case SB_VERT:
620 bVisible = (Window->style & WS_VSCROLL);
621 break;
622 case SB_CTL:
623 bVisible = (Window->style & WS_VISIBLE);
624 break;
625 default:
626 bVisible = FALSE;
627 break;
628 }
629
630 if (bRedraw && bVisible)
631 {
632 if (!(Info->fMask & SIF_THEMED)) // Not Using Themes
633 {
635 {
636 // Redraw the entire bar
638 UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
639 UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left;
640 UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top;
641 UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top;
643 }
644 else
645 {
646 // Redraw only the interior part of the bar
647 IntRefeshScrollInterior(Window, nBar, psbi);
648 }
649 }
650 else // Using Themes
651 {
653 UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
654 UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left;
655 UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top;
656 UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top;
657 if (bChangeParams || (OldPos != pSBData->pos))
659 }
660 }
661 }
662
663 if (bChangeParams && (nBar == SB_HORZ || nBar == SB_VERT) && (lpsi->fMask & SIF_DISABLENOSCROLL))
664 IntEnableScrollBar(nBar == SB_HORZ, psbi, Window->pSBInfo->WSBflags);
665
666 // Return current position
667 return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos;
668}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
action
Definition: namespace.c:707
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SA_SSI_SHOW
Definition: scrollbar.c:38
static void IntRefeshScrollInterior(PWND pWnd, INT nBar, PSCROLLBARINFO psbi)
Definition: scrollbar.c:1068
#define SA_SSI_REPAINT_ARROWS
Definition: scrollbar.c:40
BOOL APIENTRY IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows)
Definition: scrollbar.c:824
#define SA_SSI_HIDE
Definition: scrollbar.c:37
DWORD FASTCALL co_UserShowScrollBar(PWND Wnd, int nBar, BOOL fShowH, BOOL fShowV)
Definition: scrollbar.c:863
#define WS_VISIBLE
Definition: pedump.c:620
INT pos
Definition: ntuser.h:508
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
#define SIF_PREVIOUSPOS
Definition: undocuser.h:90
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:895
#define SIF_THEMED
Definition: winuser.h:1249
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1247
#define RDW_FRAME
Definition: winuser.h:1223
#define ESB_ENABLE_BOTH
Definition: winuser.h:563
#define RDW_INVALIDATE
Definition: winuser.h:1225

Referenced by NtUserSetScrollInfo().

◆ co_UserShowScrollBar()

DWORD FASTCALL co_UserShowScrollBar ( PWND  Wnd,
int  nBar,
BOOL  fShowH,
BOOL  fShowV 
)

Definition at line 863 of file scrollbar.c.

864{
865 ULONG old_style, set_bits = 0, clear_bits = 0;
866
867 ASSERT_REFS_CO(Wnd);
868
869 switch(nBar)
870 {
871 case SB_CTL:
872 {
873 //IntUpdateSBInfo(Wnd, SB_CTL); // Is this needed? Was tested w/o!
874 co_WinPosShowWindow(Wnd, fShowH ? SW_SHOW : SW_HIDE);
875 return TRUE;
876 }
877 case SB_BOTH:
878 case SB_HORZ:
879 if (fShowH) set_bits |= WS_HSCROLL;
880 else clear_bits |= WS_HSCROLL;
881 if( nBar == SB_HORZ ) break;
882 // Fall through
883 case SB_VERT:
884 if (fShowV) set_bits |= WS_VSCROLL;
885 else clear_bits |= WS_VSCROLL;
886 break;
887 default:
889 return FALSE; // Nothing to do
890 }
891
892 old_style = IntSetStyle(Wnd, set_bits, clear_bits);
893 if ((old_style & clear_bits) != 0 || (old_style & set_bits) != set_bits)
894 {
896 //if (Wnd->style & WS_HSCROLL) IntUpdateSBInfo(Wnd, SB_HORZ);
897 //if (Wnd->style & WS_VSCROLL) IntUpdateSBInfo(Wnd, SB_VERT);
898
899 // Frame has been changed, let the window redraw itself
900 co_WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
902 return TRUE;
903 }
904 return FALSE; // no frame changes
905}
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1792
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2594
ULONG FASTCALL IntSetStyle(PWND pwnd, ULONG set_bits, ULONG clear_bits)
Definition: window.c:145
#define SW_HIDE
Definition: winuser.h:779
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define SWP_FRAMECHANGED
Definition: winuser.h:1251
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SWP_NOSIZE
Definition: winuser.h:1256
#define SB_BOTH
Definition: winuser.h:555
#define SW_SHOW
Definition: winuser.h:786
#define SWP_NOZORDER
Definition: winuser.h:1258

Referenced by co_IntSetScrollInfo(), co_UserCreateWindowEx(), and NtUserShowScrollBar().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserScrollbar  )

◆ IntCalculateThumb()

BOOL FASTCALL IntCalculateThumb ( PWND  Wnd,
LONG  idObject,
PSCROLLBARINFO  psbi,
PSBDATA  pSBData 
)

Definition at line 166 of file scrollbar.c.

167{
168 INT Thumb, ThumbBox, ThumbPos, cxy, mx;
169 RECTL ClientRect;
170
171 switch(idObject)
172 {
173 case SB_HORZ:
175 cxy = psbi->rcScrollBar.right - psbi->rcScrollBar.left;
176 break;
177 case SB_VERT:
179 cxy = psbi->rcScrollBar.bottom - psbi->rcScrollBar.top;
180 break;
181 case SB_CTL:
182 IntGetClientRect(Wnd, &ClientRect);
183 if(Wnd->style & SBS_VERT)
184 {
186 cxy = ClientRect.bottom - ClientRect.top;
187 }
188 else
189 {
191 cxy = ClientRect.right - ClientRect.left;
192 }
193 break;
194 default:
195 return FALSE;
196 }
197
198 ThumbPos = Thumb;
199 // Calculate Thumb
200 if(cxy <= (2 * Thumb))
201 {
202 Thumb = cxy / 2;
203 psbi->xyThumbTop = 0;
204 psbi->xyThumbBottom = 0;
205 ThumbPos = Thumb;
206 }
209 pSBData->posMin >= (int)(pSBData->posMax - max(pSBData->page - 1, 0)))
210 {
211 // Nothing to scroll
212 psbi->xyThumbTop = 0;
213 psbi->xyThumbBottom = 0;
214 }
215 else
216 {
217 ThumbBox = pSBData->page ? MINTRACKTHUMB : UserGetSystemMetrics(SM_CXHTHUMB);
218 cxy -= (2 * Thumb);
219 if(cxy >= ThumbBox)
220 {
221 if(pSBData->page)
222 ThumbBox = max(EngMulDiv(cxy, pSBData->page, pSBData->posMax - pSBData->posMin + 1), ThumbBox);
223
224 if(cxy > ThumbBox)
225 {
226 mx = pSBData->posMax - max(pSBData->page - 1, 0);
227 if(pSBData->posMin < mx)
228 ThumbPos = Thumb + EngMulDiv(cxy - ThumbBox, pSBData->pos - pSBData->posMin, mx - pSBData->posMin);
229 else
230 ThumbPos = Thumb + ThumbBox;
231 }
232
233 psbi->xyThumbTop = ThumbPos;
234 psbi->xyThumbBottom = ThumbPos + ThumbBox;
235 }
236 else
237 {
238 psbi->xyThumbTop = 0;
239 psbi->xyThumbBottom = 0;
240 }
241 }
242 psbi->dxyLineButton = Thumb;
243
244 return TRUE;
245}
#define SBRG_BOTTOMLEFTBTN
Definition: scrollbar.c:47
#define MINTRACKTHUMB
Definition: scrollbar.c:34
#define SBRG_TOPRIGHTBTN
Definition: scrollbar.c:43
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
DWORD style
Definition: ntuser.h:706
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:210
VOID FASTCALL IntGetClientRect(PWND WindowObject, RECTL *Rect)
Definition: winpos.c:92
ENGAPI INT APIENTRY EngMulDiv(_In_ INT a, _In_ INT b, _In_ INT c)
Definition: math.c:26
#define SM_CXHTHUMB
Definition: winuser.h:982
#define SM_CYVSCROLL
Definition: winuser.h:992
#define SBS_VERT
Definition: winuser.h:334
#define SM_CXHSCROLL
Definition: winuser.h:993

Referenced by co_IntCreateScrollBars(), and co_IntGetScrollBarInfo().

◆ IntDestroyScrollBars()

BOOL FASTCALL IntDestroyScrollBars ( PWND  Window)

Definition at line 810 of file scrollbar.c.

811{
812 if (Window->pSBInfo && Window->pSBInfoex)
813 {
814 DesktopHeapFree(Window->head.rpdesk, Window->pSBInfo);
815 Window->pSBInfo = NULL;
817 Window->pSBInfoex = NULL;
818 return TRUE;
819 }
820 return FALSE;
821}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215

Referenced by co_UserFreeWindow().

◆ IntDrawScrollArrows()

static VOID FASTCALL IntDrawScrollArrows ( HDC  hDC,
PSCROLLBARINFO  ScrollBarInfo,
BOOL  Vertical 
)
static

Definition at line 1020 of file scrollbar.c.

1021{
1022 RECT RectLT, RectRB;
1023 INT ScrollDirFlagLT, ScrollDirFlagRB;
1024
1025 RectLT = RectRB = ScrollBarInfo->rcScrollBar;
1026 if (Vertical)
1027 {
1028 ScrollDirFlagLT = DFCS_SCROLLUP;
1029 ScrollDirFlagRB = DFCS_SCROLLDOWN;
1030 RectLT.bottom = RectLT.top + ScrollBarInfo->dxyLineButton;
1031 RectRB.top = RectRB.bottom - ScrollBarInfo->dxyLineButton;
1032 }
1033 else
1034 {
1035 ScrollDirFlagLT = DFCS_SCROLLLEFT;
1036 ScrollDirFlagRB = DFCS_SCROLLRIGHT;
1037 RectLT.right = RectLT.left + ScrollBarInfo->dxyLineButton;
1038 RectRB.left = RectRB.right - ScrollBarInfo->dxyLineButton;
1039 }
1040
1041 if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_PRESSED)
1042 ScrollDirFlagLT |= DFCS_PUSHED | DFCS_FLAT;
1043
1045 ScrollDirFlagLT |= DFCS_INACTIVE;
1046
1047 if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_PRESSED)
1048 ScrollDirFlagRB |= DFCS_PUSHED | DFCS_FLAT;
1049
1051 ScrollDirFlagRB |= DFCS_INACTIVE;
1052
1053 DrawFrameControl(hDC, &RectLT, DFC_SCROLL, ScrollDirFlagLT);
1054 DrawFrameControl(hDC, &RectRB, DFC_SCROLL, ScrollDirFlagRB);
1055}
static HDC hDC
Definition: 3dtext.c:33
#define SCROLL_BOTTOM_ARROW
Definition: scrollbar.c:18
#define SCROLL_TOP_ARROW
Definition: scrollbar.c:14
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2941
#define DFC_SCROLL
Definition: winuser.h:475
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_FLAT
Definition: winuser.h:510
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DFCS_SCROLLUP
Definition: winuser.h:489
#define DFCS_SCROLLLEFT
Definition: winuser.h:491
#define DFCS_SCROLLRIGHT
Definition: winuser.h:492
#define DFCS_SCROLLDOWN
Definition: winuser.h:490
#define DFCS_PUSHED
Definition: winuser.h:503

Referenced by IntDrawScrollBar(), and IntUpdateScrollArrows().

◆ IntDrawScrollBar()

void IntDrawScrollBar ( PWND  Wnd,
HDC  DC,
INT  Bar 
)

Definition at line 1083 of file scrollbar.c.

1084{
1085 PTHREADINFO pti;
1087 BOOL Vertical;
1088
1090
1091 // Get scrollbar info
1092 switch (Bar)
1093 {
1094 case SB_HORZ:
1095 Vertical = FALSE;
1096 break;
1097
1098 case SB_VERT:
1099 Vertical = TRUE;
1100 break;
1101
1102 case SB_CTL:
1103 Vertical = (Wnd->style & SBS_VERT) != 0;
1104 break;
1105
1106 default:
1107 return;
1108 }
1109
1111 return;
1112
1113 if (RECTL_bIsEmptyRect(&Info.rcScrollBar))
1114 return;
1115
1116 // Draw arrows
1117 if (Info.dxyLineButton)
1118 IntDrawScrollArrows(DC, &Info, Vertical);
1119
1120 // Draw interior
1121 IntDrawScrollInterior(Wnd, DC, Bar, Vertical, &Info);
1122
1123 // If scrollbar has focus, reposition the caret
1124 if (Wnd == pti->MessageQueue->spwndFocus && Bar == SB_CTL)
1125 {
1126 if (Vertical)
1127 co_IntSetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1);
1128 else
1129 co_IntSetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1);
1130 }
1131}
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
static VOID FASTCALL IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
Definition: scrollbar.c:1020
BOOL FASTCALL co_IntGetScrollBarInfo(PWND Window, LONG idObject, PSCROLLBARINFO psbi)
Definition: scrollbar.c:671
static void IntDrawScrollInterior(PWND pWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINFO ScrollBarInfo)
Definition: scrollbar.c:908
static LONG FASTCALL IntScrollGetObjectId(INT SBType)
Definition: scrollbar.c:1058
Definition: polytest.cpp:41
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
BOOL FASTCALL co_IntSetCaretPos(int X, int Y)
Definition: caret.c:193

Referenced by NC_DoNCPaint(), SCROLL_RefreshScrollBar(), and ScrollBarWndProc_common().

◆ IntDrawScrollInterior()

static void IntDrawScrollInterior ( PWND  pWnd,
HDC  hDC,
INT  nBar,
BOOL  Vertical,
PSCROLLBARINFO  ScrollBarInfo 
)
static

Definition at line 908 of file scrollbar.c.

909{
910 INT ThumbSize = ScrollBarInfo->xyThumbBottom - ScrollBarInfo->xyThumbTop;
911 INT ThumbTop = ScrollBarInfo->xyThumbTop;
912 RECT Rect;
913 HBRUSH hSaveBrush, hBrush;
914 BOOL TopSelected = FALSE, BottomSelected = FALSE;
915
916 if (ScrollBarInfo->rgstate[SCROLL_TOP_RECT] & STATE_SYSTEM_PRESSED)
917 TopSelected = TRUE;
918 if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_RECT] & STATE_SYSTEM_PRESSED)
919 BottomSelected = TRUE;
920
921 // Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
922 // The window-owned scrollbars need to call DefWndControlColor
923 // to correctly setup default scrollbar colors
924 if (nBar == SB_CTL)
925 {
927 if (!hBrush)
929 }
930 else
931 {
933 }
934
935 hSaveBrush = NtGdiSelectBrush(hDC, hBrush);
936
937 // Calculate the scroll rectangle
938 if (Vertical)
939 {
940 Rect.top = ScrollBarInfo->rcScrollBar.top + ScrollBarInfo->dxyLineButton;
941 Rect.bottom = ScrollBarInfo->rcScrollBar.bottom - ScrollBarInfo->dxyLineButton;
942 Rect.left = ScrollBarInfo->rcScrollBar.left;
943 Rect.right = ScrollBarInfo->rcScrollBar.right;
944 }
945 else
946 {
947 Rect.top = ScrollBarInfo->rcScrollBar.top;
948 Rect.bottom = ScrollBarInfo->rcScrollBar.bottom;
949 Rect.left = ScrollBarInfo->rcScrollBar.left + ScrollBarInfo->dxyLineButton;
950 Rect.right = ScrollBarInfo->rcScrollBar.right - ScrollBarInfo->dxyLineButton;
951 }
952
953 // Draw scroll rectangles and thumb
954 if (!ScrollBarInfo->xyThumbBottom)
955 {
956 NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
957 Rect.bottom - Rect.top, PATCOPY);
958
959 // Cleanup and return
960 NtGdiSelectBrush(hDC, hSaveBrush);
961 return;
962 }
963
964 ThumbTop -= ScrollBarInfo->dxyLineButton;
965
966 if (ScrollBarInfo->dxyLineButton)
967 {
968 if (Vertical)
969 {
970 if (ThumbSize)
971 {
972 NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
973 ThumbTop, TopSelected ? BLACKNESS : PATCOPY);
974 Rect.top += ThumbTop;
975 NtGdiPatBlt(hDC, Rect.left, Rect.top + ThumbSize, Rect.right - Rect.left,
976 Rect.bottom - Rect.top - ThumbSize, BottomSelected ? BLACKNESS : PATCOPY);
977 Rect.bottom = Rect.top + ThumbSize;
978 }
979 else
980 {
981 if (ThumbTop)
982 {
983 NtGdiPatBlt(hDC, Rect.left, ScrollBarInfo->dxyLineButton,
984 Rect.right - Rect.left, Rect.bottom - Rect.top, PATCOPY);
985 }
986 }
987 }
988 else
989 {
990 if (ThumbSize)
991 {
992 NtGdiPatBlt(hDC, Rect.left, Rect.top, ThumbTop,
993 Rect.bottom - Rect.top, TopSelected ? BLACKNESS : PATCOPY);
994 Rect.left += ThumbTop;
995 NtGdiPatBlt(hDC, Rect.left + ThumbSize, Rect.top,
996 Rect.right - Rect.left - ThumbSize, Rect.bottom - Rect.top,
997 BottomSelected ? BLACKNESS : PATCOPY);
998 Rect.right = Rect.left + ThumbSize;
999 }
1000 else
1001 {
1002 if (ThumbTop)
1003 {
1004 NtGdiPatBlt(hDC, ScrollBarInfo->dxyLineButton, Rect.top,
1005 Rect.right - Rect.left, Rect.bottom - Rect.top, PATCOPY);
1006 }
1007 }
1008 }
1009 }
1010
1011 // Draw thumb
1012 if (ThumbSize)
1014
1015 // Cleanup
1016 NtGdiSelectBrush(hDC, hSaveBrush);
1017}
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiPatBlt(_In_ HDC hdcDest, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_ DWORD dwRop)
Definition: bitblt.c:990
HBRUSH FASTCALL DefWndControlColor(HDC hDC, UINT ctlType)
Definition: defwnd.c:32
#define SCROLL_BOTTOM_RECT
Definition: scrollbar.c:17
#define SCROLL_TOP_RECT
Definition: scrollbar.c:15
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:180
#define BLACKNESS
Definition: wingdi.h:323
#define PATCOPY
Definition: wingdi.h:335
#define CTLCOLOR_SCROLLBAR
Definition: winuser.h:967
#define COLOR_SCROLLBAR
Definition: winuser.h:923
#define WM_CTLCOLORSCROLLBAR
Definition: winuser.h:1790
#define BF_MIDDLE
Definition: winuser.h:468
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define BF_RECT
Definition: winuser.h:462
#define EDGE_RAISED
Definition: winuser.h:450

Referenced by IntDrawScrollBar(), IntRefeshScrollInterior(), IntScrollDrawMovingThumb(), and IntScrollHandleScrollEvent().

◆ IntEnableScrollBar()

BOOL APIENTRY IntEnableScrollBar ( BOOL  Horz,
PSCROLLBARINFO  Info,
UINT  wArrows 
)

Definition at line 824 of file scrollbar.c.

825{
826 BOOL Chg = FALSE;
827 switch(wArrows)
828 {
829 case ESB_DISABLE_BOTH:
832 break;
833 case ESB_DISABLE_RTDN:
834 if(Horz)
835 {
837 }
838 else
839 {
841 }
842 break;
843 case ESB_DISABLE_LTUP:
844 if(Horz)
845 {
847 }
848 else
849 {
851 }
852 break;
853 case ESB_ENABLE_BOTH:
856 break;
857 }
858 return Chg;
859}
#define CHANGERGSTATE(item, status)
Definition: scrollbar.c:49
#define ESB_DISABLE_RTDN
Definition: winuser.h:561
#define ESB_DISABLE_LTUP
Definition: winuser.h:559

Referenced by co_IntSetScrollInfo(), and NtUserEnableScrollBar().

◆ IntGetSBData()

PSBDATA FASTCALL IntGetSBData ( PWND  pwnd,
INT  Bar 
)

Definition at line 77 of file scrollbar.c.

78{
79 PSBWND pSBWnd;
80 PSBINFO pSBInfo;
81
82 pSBInfo = pwnd->pSBInfo;
83 switch (Bar)
84 {
85 case SB_HORZ:
86 return &pSBInfo->Horz;
87 case SB_VERT:
88 return &pSBInfo->Vert;
89 case SB_CTL:
90 if (pwnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND)))
91 {
92 ERR("IntGetSBData Wrong Extra bytes for CTL Scrollbar\n");
93 return 0;
94 }
95 pSBWnd = (PSBWND)pwnd;
96 return (PSBDATA)&pSBWnd->SBCalc;
97 default:
98 ERR("IntGetSBData Bad Bar\n");
99 }
100 return NULL;
101}
struct _SBWND * PSBWND
Definition: ntuser.h:772
SBCALC SBCalc
Definition: ntuser.h:776
Definition: ntuser.h:694
PSBINFO pSBInfo
Definition: ntuser.h:726
ULONG cbwndExtra
Definition: ntuser.h:738
SBDATA Vert
Definition: ntuser.h:515
SBDATA Horz
Definition: ntuser.h:514

Referenced by co_IntCreateScrollBars(), co_IntGetScrollBarInfo(), co_IntSetScrollInfo(), GetScrollPos(), GetScrollRange(), IntScrollGetThumbVal(), and RealGetScrollInfo().

◆ IntGetScrollBarRect()

BOOL FASTCALL IntGetScrollBarRect ( PWND  Wnd,
INT  nBar,
RECTL lprect 
)

Definition at line 104 of file scrollbar.c.

105{
106 BOOL vertical;
107 *lprect = Wnd->rcClient;
108
109 RECTL_vOffsetRect(lprect, -Wnd->rcWindow.left, -Wnd->rcWindow.top);
110 if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
111 mirror_rect(&Wnd->rcWindow, lprect);
112
113 switch (nBar)
114 {
115 case SB_HORZ:
116 lprect->top = lprect->bottom;
118 if (Wnd->style & WS_BORDER)
119 {
120 lprect->left--;
121 lprect->right++;
122 }
123 else if (Wnd->style & WS_VSCROLL)
124 {
125 lprect->right++;
126 }
127 vertical = FALSE;
128 break;
129
130 case SB_VERT:
132 {
133 lprect->right = lprect->left;
135 }
136 else
137 {
138 lprect->left = lprect->right;
140 }
141 if (Wnd->style & WS_BORDER)
142 {
143 lprect->top--;
144 lprect->bottom++;
145 }
146 else if (Wnd->style & WS_HSCROLL)
147 {
148 lprect->bottom++;
149 }
150 vertical = TRUE;
151 break;
152
153 case SB_CTL:
154 IntGetClientRect(Wnd, lprect);
155 vertical = !!(Wnd->style & SBS_VERT);
156 break;
157
158 default:
159 return FALSE;
160 }
161
162 return vertical;
163}
static void mirror_rect(const RECT *window_rect, RECT *rect)
Definition: scrollbar.c:68
#define WS_BORDER
Definition: pedump.c:625
DWORD ExStyle
Definition: ntuser.h:704
RECT rcClient
Definition: ntuser.h:717
RECT rcWindow
Definition: ntuser.h:716
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define SM_CXVSCROLL
Definition: winuser.h:972
#define SM_CYHSCROLL
Definition: winuser.h:973
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392

Referenced by co_IntCreateScrollBars(), and co_IntGetScrollBarInfo().

◆ IntRefeshScrollInterior()

static void IntRefeshScrollInterior ( PWND  pWnd,
INT  nBar,
PSCROLLBARINFO  psbi 
)
static

Definition at line 1068 of file scrollbar.c.

1069{
1070 HDC hdc;
1071 BOOL Vertical = ((nBar == SB_CTL) ? ((pWnd->style & SBS_VERT) != 0) : (nBar == SB_VERT));
1072
1073 hdc = UserGetDCEx(pWnd, NULL, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
1074 if (hdc)
1075 {
1077 IntDrawScrollInterior(pWnd, hdc, nBar, Vertical, psbi);
1078 UserReleaseDC(pWnd, hdc, FALSE);
1079 }
1080}
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:918
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
#define DCX_CACHE
Definition: winuser.h:2133
#define DCX_WINDOW
Definition: winuser.h:2132

Referenced by co_IntSetScrollInfo().

◆ IntScrollGetObjectId()

static LONG FASTCALL IntScrollGetObjectId ( INT  SBType)
static

Definition at line 1058 of file scrollbar.c.

1059{
1060 if (SBType == SB_VERT)
1061 return OBJID_VSCROLL;
1062 if (SBType == SB_HORZ)
1063 return OBJID_HSCROLL;
1064 return OBJID_CLIENT;
1065}
#define OBJID_VSCROLL
Definition: winable.h:20
#define OBJID_HSCROLL
Definition: winable.h:21
#define OBJID_CLIENT
Definition: winable.h:19

Referenced by IntDrawScrollBar(), IntGetScrollBarInfo(), IntRefeshScrollInterior(), IntScrollHandleScrollEvent(), and IntUpdateScrollArrows().

◆ mirror_rect()

static void mirror_rect ( const RECT window_rect,
RECT rect 
)
inlinestatic

Definition at line 68 of file scrollbar.c.

69{
70 int width = window_rect->right - window_rect->left;
71 int tmp = rect->left;
72 rect->left = width - rect->right;
73 rect->right = width - tmp;
74}
GLint GLint GLsizei width
Definition: gl.h:1546
& rect
Definition: startmenu.cpp:1413

Referenced by IntGetScrollBarRect(), and IntScrollGetScrollBarRect().

◆ NEWco_IntGetScrollInfo()

BOOL FASTCALL NEWco_IntGetScrollInfo ( PWND  pWnd,
INT  nBar,
PSBDATA  pSBData,
LPSCROLLINFO  lpsi 
)

Definition at line 311 of file scrollbar.c.

316{
317 UINT Mask;
318 PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack;
319
320 lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
321 if (!SBID_IS_VALID(nBar))
322 {
324 ERR("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
325 return FALSE;
326 }
327
328 if (!pWnd->pSBInfo || !pSBTrack) return FALSE;
329
330 Mask = lpsi->fMask;
331
332 if (0 != (Mask & SIF_PAGE))
333 lpsi->nPage = pSBData->page;
334
335 if (0 != (Mask & SIF_POS))
336 lpsi->nPos = pSBData->pos;
337
338 if (0 != (Mask & SIF_RANGE))
339 {
340 lpsi->nMin = pSBData->posMin;
341 lpsi->nMax = pSBData->posMax;
342 }
343
344 if (0 != (Mask & SIF_TRACKPOS))
345 {
346 if (pSBTrack && pSBTrack->nBar == nBar && pSBTrack->spwndTrack == pWnd)
347 lpsi->nTrackPos = pSBTrack->posNew;
348 else
349 lpsi->nTrackPos = pSBData->pos;
350 }
351 return (Mask & SIF_ALL) !=0;
352}
THRDESKHEAD head
Definition: ntuser.h:695
INT nBar
Definition: scroll.h:22
INT posNew
Definition: scroll.h:21
PWND spwndTrack
Definition: scroll.h:11

◆ NtUserEnableScrollBar()

BOOL APIENTRY NtUserEnableScrollBar ( HWND  hWnd,
UINT  wSBflags,
UINT  wArrows 
)

Definition at line 1253 of file scrollbar.c.

1257{
1258 UINT OrigArrows;
1259 PWND Window = NULL;
1260 PSCROLLBARINFO InfoV = NULL, InfoH = NULL;
1261 BOOL Chg = FALSE;
1262 BOOL Ret = FALSE;
1264
1265 TRACE("Enter NtUserEnableScrollBar\n");
1267
1269 goto Cleanup; // Return FALSE
1270
1271 UserRefObjectCo(Window, &Ref);
1272
1274 goto Cleanup; // Return FALSE
1275
1276 OrigArrows = Window->pSBInfo->WSBflags;
1277 Window->pSBInfo->WSBflags = wArrows;
1278
1279 if (wSBflags == SB_CTL)
1280 {
1281 if ((wArrows == ESB_DISABLE_BOTH || wArrows == ESB_ENABLE_BOTH))
1282 IntEnableWindow(hWnd, (wArrows == ESB_ENABLE_BOTH));
1283
1284 Ret = TRUE;
1285 goto Cleanup;
1286 }
1287
1288 if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags))
1289 {
1291 ERR("Trying to set scrollinfo for unknown scrollbar type %u\n", wSBflags);
1292 goto Cleanup; // Return FALSE
1293 }
1294
1295 switch(wSBflags)
1296 {
1297 case SB_BOTH:
1299 // Fall through
1300 case SB_HORZ:
1302 break;
1303 case SB_VERT:
1305 break;
1306 default:
1307 goto Cleanup; // Return FALSE
1308 }
1309
1310 if(InfoV)
1311 Chg = IntEnableScrollBar(FALSE, InfoV, wArrows);
1312
1313 if(InfoH)
1314 Chg = (IntEnableScrollBar(TRUE, InfoH, wArrows) || Chg);
1315
1316 ERR("FIXME: EnableScrollBar wSBflags %u wArrows %u Chg %d\n", wSBflags, wArrows, Chg);
1317// Done in user32:
1318// SCROLL_RefreshScrollBar(hwnd, nBar, TRUE, TRUE);
1319
1320 Ret = Chg;
1321 goto Cleanup; // FIXME
1322
1323 if (OrigArrows == wArrows)
1324 {
1325 Ret = FALSE;
1326 goto Cleanup;
1327 }
1328
1329 Ret = TRUE;
1330
1331Cleanup:
1332 if (Window)
1334
1335 TRACE("Leave NtUserEnableScrollBar, ret=%i\n", Ret);
1336 UserLeave();
1337 return Ret;
1338}
HWND hWnd
Definition: settings.c:17
static const WCHAR Cleanup[]
Definition: register.c:80
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:43
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
#define TRACE(s)
Definition: solgame.cpp:4
Definition: object.h:4
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:197
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
BOOL FASTCALL IntEnableWindow(HWND hWnd, BOOL bEnable)
Definition: window.c:222

Referenced by EnableScrollBar(), and ResetUserApiHook().

◆ NtUserGetScrollBarInfo()

BOOL APIENTRY NtUserGetScrollBarInfo ( HWND  hWnd,
LONG  idObject,
PSCROLLBARINFO  psbi 
)

Definition at line 1153 of file scrollbar.c.

1154{
1156 SCROLLBARINFO sbi;
1157 PWND Window;
1158 BOOL Ret = FALSE;
1160
1161 TRACE("Enter NtUserGetScrollBarInfo\n");
1163
1164 Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO));
1165 if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO)))
1166 {
1168 goto Exit; // Return FALSE
1169 }
1170
1172 goto Exit; // Return FALSE
1173
1174 UserRefObjectCo(Window, &Ref);
1175 Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
1177
1178 Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO));
1179 if(!NT_SUCCESS(Status))
1180 {
1182 Ret = FALSE;
1183 }
1184
1185Exit:
1186 TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n", Ret);
1187 UserLeave();
1188 return Ret;
1189}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define MmCopyFromCaller
Definition: polytest.cpp:29
static void Exit(void)
Definition: sock.c:1330
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31

Referenced by GetScrollBarInfo(), IntGetScrollBarInfo(), and ScrollBarWndProc_common().

◆ NtUserSBGetParms()

BOOL APIENTRY NtUserSBGetParms ( HWND  hWnd,
int  fnBar,
PSBDATA  pSBData,
LPSCROLLINFO  lpsi 
)

Definition at line 1193 of file scrollbar.c.

1198{
1199 PWND Window;
1200 SCROLLINFO psi;
1201 BOOL Ret = FALSE;
1202 SBDATA SBDataSafe;
1204
1205 TRACE("Enter NtUserGetScrollInfo\n");
1207
1208 _SEH2_TRY
1209 {
1210 RtlCopyMemory(&psi, lpsi, sizeof(SCROLLINFO));
1211 if (pSBData)
1212 RtlCopyMemory(&SBDataSafe, pSBData, sizeof(SBDATA));
1213 }
1215 {
1216 ERR("NtUserGetScrollInfo Failed size\n");
1218 _SEH2_YIELD(goto Exit); // Return FALSE
1219 }
1220 _SEH2_END
1221
1223 {
1224 ERR("NtUserGetScrollInfo Bad window\n");
1225 goto Exit; // Return FALSE
1226 }
1227
1228 UserRefObjectCo(Window, &Ref);
1229 Ret = co_IntGetScrollInfo(Window, fnBar, &SBDataSafe, &psi);
1231
1232 _SEH2_TRY
1233 {
1234 RtlCopyMemory(lpsi, &psi, sizeof(SCROLLINFO));
1235 }
1237 {
1238 ERR("NtUserGetScrollInfo Failed copy to user\n");
1240 Ret = FALSE;
1241 _SEH2_YIELD(goto Exit);
1242 }
1243 _SEH2_END
1244
1245Exit:
1246 TRACE("Leave NtUserGetScrollInfo, ret=%i\n", Ret);
1247 UserLeave();
1248 return Ret;
1249}
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
static BOOL FASTCALL co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
Definition: scrollbar.c:264
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184

Referenced by RealGetScrollInfo(), and ScrollBarWndProc_common().

◆ NtUserSetScrollBarInfo()

BOOL APIENTRY NtUserSetScrollBarInfo ( HWND  hWnd,
LONG  idObject,
SETSCROLLBARINFO info 
)

Definition at line 1408 of file scrollbar.c.

1412{
1413 PWND Window = NULL;
1414 SETSCROLLBARINFO Safeinfo;
1415 PSCROLLBARINFO sbi;
1416 LPSCROLLINFO psi;
1418 LONG Obj;
1419 BOOL Ret = FALSE;
1421
1422 TRACE("Enter NtUserSetScrollBarInfo\n");
1424
1426 goto Cleanup; // Return FALSE
1427
1428 UserRefObjectCo(Window, &Ref);
1429
1430 Obj = SBOBJ_TO_SBID(idObject);
1431 if(!SBID_IS_VALID(Obj))
1432 {
1434 ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", Obj);
1435 goto Cleanup; // Return FALSE
1436 }
1437
1439 goto Cleanup; // Return FALSE
1440
1441 Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
1442 if(!NT_SUCCESS(Status))
1443 {
1445 goto Cleanup; // Return FALSE
1446 }
1447
1450
1451 psi->nTrackPos = Safeinfo.nTrackPos;
1452 sbi->reserved = Safeinfo.reserved;
1453 RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate));
1454
1455 Ret = TRUE;
1456
1457Cleanup:
1458 if (Window)
1460
1461 TRACE("Leave NtUserSetScrollBarInfo, ret=%i\n", Ret);
1462 UserLeave();
1463 return Ret;
1464}
long LONG
Definition: pedump.c:60

Referenced by IntScrollHandleScrollEvent(), and IntUpdateScrollArrows().

◆ NtUserSetScrollInfo()

DWORD APIENTRY NtUserSetScrollInfo ( HWND  hWnd,
int  fnBar,
LPCSCROLLINFO  lpsi,
BOOL  bRedraw 
)

Definition at line 1342 of file scrollbar.c.

1347{
1348 PWND Window = NULL;
1350 SCROLLINFO ScrollInfo;
1351 DWORD Ret = 0;
1353
1354 TRACE("Enter NtUserSetScrollInfo\n");
1356
1358 goto Cleanup; // Return 0
1359
1360 UserRefObjectCo(Window, &Ref);
1361
1362 Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos));
1363 if(!NT_SUCCESS(Status))
1364 {
1366 goto Cleanup; // Return 0
1367 }
1368
1369 Ret = co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw);
1370
1371Cleanup:
1372 if (Window)
1374
1375 TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", Ret);
1376 UserLeave();
1377 return Ret;
1378}
static DWORD FASTCALL co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: scrollbar.c:455

Referenced by IntScrollCreateScrollBar(), IntSetScrollInfo(), and RealSetScrollInfo().

◆ NtUserShowScrollBar()

DWORD APIENTRY NtUserShowScrollBar ( HWND  hWnd,
int  nBar,
DWORD  bShow 
)

Definition at line 1381 of file scrollbar.c.

1382{
1383 PWND Window;
1384 DWORD ret = 0;
1386
1387 TRACE("Enter NtUserShowScrollBar\n");
1389
1391 if (Window)
1392 {
1393 UserRefObjectCo(Window, &Ref);
1394 ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow,
1395 (nBar == SB_HORZ) ? 0 : bShow);
1397 }
1398
1399 TRACE("Leave NtUserShowScrollBar, ret=%lu\n", ret);
1400 UserLeave();
1401 return ret;
1402}
return ret
Definition: mutex.c:146

Referenced by ShowScrollBar().

◆ ScrollBarWndProc()

LRESULT APIENTRY ScrollBarWndProc ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1134 of file scrollbar.c.

1135{
1136 LRESULT lResult = 0;
1137 PWND pWnd;
1138 pWnd = UserGetWindowObject(hWnd);
1139 if (!pWnd) return 0;
1140
1141 switch(Msg)
1142 {
1143 case WM_ENABLE:
1144 if (pWnd->pSBInfo)
1146 break;
1147 }
1148 return lResult;
1149}
WPARAM wParam
Definition: combotst.c:138
struct @1766 Msg[]
INT WSBflags
Definition: ntuser.h:513
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_ENABLE
Definition: winuser.h:1634

Referenced by NtUserMessageCall().