ReactOS  0.4.14-dev-845-g8381e29
scrollbar.c File Reference
#include <user32.h>
Include dependency graph for scrollbar.c:

Go to the source code of this file.

Macros

#define SCROLL_NOWHERE   0x00 /* Outside the scroll bar */
 
#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
 
#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
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (scrollbar)
 
HBRUSH DefWndControlColor (HDC hDC, UINT ctlType)
 
UINT_PTR WINAPI SetSystemTimer (HWND, UINT_PTR, UINT, TIMERPROC)
 
BOOL WINAPI KillSystemTimer (HWND, UINT_PTR)
 
static PSBDATA IntGetSBData (PWND pwnd, INT Bar)
 
static void IntDrawScrollInterior (HWND hWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINFO ScrollBarInfo)
 
static VOID FASTCALL IntDrawScrollArrows (HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
 
static VOID FASTCALL IntScrollDrawMovingThumb (HDC Dc, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
 
static LONG FASTCALL IntScrollGetObjectId (INT SBType)
 
static BOOL FASTCALL IntGetScrollBarInfo (HWND Wnd, INT Bar, PSCROLLBARINFO ScrollBarInfo)
 
void IntDrawScrollBar (HWND Wnd, HDC DC, INT Bar)
 
static BOOL FASTCALL IntScrollPtInRectEx (LPRECT Rect, POINT Pt, BOOL Vertical)
 
static DWORD FASTCALL IntScrollHitTest (PSCROLLBARINFO ScrollBarInfo, BOOL Vertical, POINT Pt, BOOL Dragging)
 
static BOOL FASTCALL IntScrollGetScrollBarRect (HWND Wnd, INT Bar, RECT *Rect, INT *ArrowSize, INT *ThumbSize, INT *ThumbPos)
 
static UINT FASTCALL IntScrollGetThumbVal (HWND Wnd, INT SBType, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical, INT Pos)
 
static POINT IntScrollClipPos (PRECT lpRect, POINT pt)
 
static void FASTCALL IntScrollDrawSizeGrip (HWND Wnd, HDC Dc)
 
static void SCROLL_RefreshScrollBar (HWND hwnd, INT nBar, BOOL arrows, BOOL interior)
 
static void FASTCALL IntScrollHandleKbdEvent (HWND Wnd, WPARAM wParam, LPARAM lParam)
 
static VOID FASTCALL IntScrollHandleScrollEvent (HWND Wnd, INT SBType, UINT Msg, POINT Pt)
 
static void IntScrollCreateScrollBar (HWND Wnd, LPCREATESTRUCTW lpCreate)
 
VOID FASTCALL ScrollTrackScrollBar (HWND Wnd, INT SBType, POINT Pt)
 
static DWORD FASTCALL IntSetScrollInfo (HWND Wnd, LPCSCROLLINFO Info, BOOL bRedraw)
 
LRESULT WINAPI ScrollBarWndProc_common (WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
LRESULT WINAPI ScrollBarWndProcW (HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI ScrollBarWndProcA (HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnableScrollBar (HWND hwnd, UINT nBar, UINT flags)
 
BOOL WINAPI RealGetScrollInfo (HWND Wnd, INT SBType, LPSCROLLINFO Info)
 
BOOL WINAPI GetScrollBarInfo (_In_ HWND hwnd, _In_ LONG idObject, _Inout_ LPSCROLLBARINFO info)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetScrollInfo (HWND Wnd, INT SBType, LPSCROLLINFO Info)
 
INT WINAPI DECLSPEC_HOTPATCH GetScrollPos (HWND Wnd, INT Bar)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetScrollRange (HWND Wnd, int Bar, LPINT MinPos, LPINT MaxPos)
 
INT WINAPI RealSetScrollInfo (HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
 
INT WINAPI DECLSPEC_HOTPATCH SetScrollInfo (HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
 
INT WINAPI DECLSPEC_HOTPATCH SetScrollPos (HWND hWnd, INT nBar, INT nPos, BOOL bRedraw)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetScrollRange (HWND hWnd, INT nBar, INT nMinPos, INT nMaxPos, BOOL bRedraw)
 

Variables

static HWND ScrollTrackingWin = 0
 
static INT ScrollTrackingBar = 0
 
static INT ScrollTrackingPos = 0
 
static INT ScrollTrackingVal = 0
 
static DWORD ScrollTrackHitTest = SCROLL_NOWHERE
 
static BOOL ScrollTrackVertical
 
static BOOL ScrollMovingThumb = FALSE
 
const struct builtin_class_descr SCROLL_builtin_class
 

Macro Definition Documentation

◆ SCROLL_ARROW_THUMB_OVERLAP

#define SCROLL_ARROW_THUMB_OVERLAP   0

Definition at line 54 of file scrollbar.c.

◆ SCROLL_BOTTOM_ARROW

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

Definition at line 39 of file scrollbar.c.

◆ SCROLL_BOTTOM_RECT

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

Definition at line 38 of file scrollbar.c.

◆ SCROLL_FIRST_DELAY

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

Definition at line 41 of file scrollbar.c.

◆ SCROLL_MIN_RECT

#define SCROLL_MIN_RECT   4

Definition at line 48 of file scrollbar.c.

◆ SCROLL_MIN_THUMB

#define SCROLL_MIN_THUMB   6

Definition at line 51 of file scrollbar.c.

◆ SCROLL_NOWHERE

#define SCROLL_NOWHERE   0x00 /* Outside the scroll bar */

Definition at line 34 of file scrollbar.c.

◆ SCROLL_REPEAT_DELAY

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

Definition at line 43 of file scrollbar.c.

◆ SCROLL_THUMB

#define SCROLL_THUMB   0x03 /* Thumb rectangle */

Definition at line 37 of file scrollbar.c.

◆ SCROLL_TIMER

#define SCROLL_TIMER   0 /* Scroll timer id */

Definition at line 45 of file scrollbar.c.

◆ SCROLL_TOP_ARROW

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

Definition at line 35 of file scrollbar.c.

◆ SCROLL_TOP_RECT

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

Definition at line 36 of file scrollbar.c.

Function Documentation

◆ DefWndControlColor()

HBRUSH DefWndControlColor ( HDC  hDC,
UINT  ctlType 
)

Definition at line 33 of file defwnd.c.

34 {
35  if (ctlType == CTLCOLOR_SCROLLBAR)
36  {
40  IntGdiSetBkColor(hDC, bk);
41 
42  /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
43  * we better use 0x55aa bitmap brush to make scrollbar's background
44  * look different from the window background.
45  */
46  if ( bk == IntGetSysColor(COLOR_WINDOW))
47  return gpsi->hbrGray;
48 
50  return hb;
51  }
52 
54 
55  if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
56  {
58  }
59  else
60  {
63  }
64 
66 }
#define COLOR_3DHILIGHT
Definition: winuser.h:927
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
COLORREF FASTCALL IntGdiSetBkColor(_In_ HDC hDC, _In_ COLORREF Color)
#define CTLCOLOR_SCROLLBAR
Definition: winuser.h:946
#define COLOR_WINDOW
Definition: winuser.h:908
PSERVERINFO gpsi
Definition: main.c:27
#define COLOR_3DFACE
Definition: winuser.h:919
#define COLOR_SCROLLBAR
Definition: winuser.h:902
COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color)
Definition: dcutil.c:172
__kernel_entry W32KAPI BOOL APIENTRY NtGdiUnrealizeObject(_In_ HANDLE h)
DWORD COLORREF
Definition: windef.h:300
#define COLOR_WINDOWTEXT
Definition: winuser.h:911
#define CTLCOLOR_EDIT
Definition: winuser.h:942
DWORD FASTCALL IntGetSysColor(INT nIndex)
Definition: stockobj.c:323
#define CTLCOLOR_LISTBOX
Definition: winuser.h:943
static HDC hDC
Definition: 3dtext.c:33

Referenced by IntDefWindowProc(), IntDrawScrollInterior(), and User32DefWindowProc().

◆ EnableScrollBar()

BOOL WINAPI DECLSPEC_HOTPATCH EnableScrollBar ( HWND  hwnd,
UINT  nBar,
UINT  flags 
)

Definition at line 1447 of file scrollbar.c.

1448 {
1449  BOOL Hook, Ret = FALSE;
1450 
1451  LoadUserApiHook();
1452 
1453  Hook = BeginIfHookedUserApiHook();
1454 
1455  /* Bypass SEH and go direct. */
1456  if (!Hook)
1457  {
1458  Ret = NtUserEnableScrollBar(hwnd, nBar, flags);
1459  if (!Ret) return Ret;
1461  return Ret;
1462  }
1463  _SEH2_TRY
1464  {
1465  Ret = guah.EnableScrollBar(hwnd, nBar, flags);
1466  }
1468  {
1469  ERR("Got exception in hooked EnableScrollBar!\n");
1470  }
1471  _SEH2_END;
1472 
1473  EndUserApiHook();
1474 
1475  return Ret;
1476 }
static void SCROLL_RefreshScrollBar(HWND hwnd, INT nBar, BOOL arrows, BOOL interior)
Definition: scrollbar.c:671
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL FASTCALL EndUserApiHook(VOID)
Definition: usrapihk.c:164
#define TRUE
Definition: types.h:120
USERAPIHOOK guah
Definition: usrapihk.c:344
_SEH2_TRY
Definition: create.c:4250
unsigned int BOOL
Definition: ntddk_ex.h:94
ENABLESCROLLBAR EnableScrollBar
Definition: undocuser.h:336
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
GLbitfield flags
Definition: glext.h:7161
#define ERR(fmt,...)
Definition: debug.h:109
_SEH2_END
Definition: create.c:4424
static __inline void LoadUserApiHook()
Definition: user_x.h:85
BOOL FASTCALL BeginIfHookedUserApiHook(VOID)
Definition: usrapihk.c:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
BOOL APIENTRY NtUserEnableScrollBar(HWND hWnd, UINT wSBflags, UINT wArrows)
Definition: scrollbar.c:1282

Referenced by ScrollBarWndProc_common().

◆ GetScrollBarInfo()

BOOL WINAPI GetScrollBarInfo ( _In_ HWND  hwnd,
_In_ LONG  idObject,
_Inout_ LPSCROLLBARINFO  info 
)

Definition at line 1509 of file scrollbar.c.

1510 {
1511  BOOL Ret;
1512  PWND pWnd = ValidateHwnd(hwnd);
1513  TRACE("hwnd=%p idObject=%d info=%p\n", hwnd, idObject, info);
1514  if (!pWnd) return FALSE;
1515  Ret = NtUserGetScrollBarInfo(hwnd, idObject, info); // This will be fixed once SB is server side.
1516  /* rcScrollBar needs to be in screen coordinates */
1517  OffsetRect( &(info->rcScrollBar), pWnd->rcWindow.left, pWnd->rcWindow.top );
1518  return Ret;
1519 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL APIENTRY NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
Definition: scrollbar.c:1172
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
RECT rcWindow
Definition: ntuser.h:680
Definition: ntuser.h:657

◆ GetScrollInfo()

BOOL WINAPI DECLSPEC_HOTPATCH GetScrollInfo ( HWND  Wnd,
INT  SBType,
LPSCROLLINFO  Info 
)

Definition at line 1527 of file scrollbar.c.

1528 {
1529  BOOL Hook, Ret = FALSE;
1530 
1531  LoadUserApiHook();
1532 
1533  Hook = BeginIfHookedUserApiHook();
1534 
1535  /* Bypass SEH and go direct. */
1536  if (!Hook) return RealGetScrollInfo(Wnd, SBType, Info);
1537 
1538  _SEH2_TRY
1539  {
1540  Ret = guah.GetScrollInfo(Wnd, SBType, Info);
1541  }
1543  {
1544  ERR("Got exception in hooked GetScrollInfo!\n");
1545  }
1546  _SEH2_END;
1547 
1548  EndUserApiHook();
1549 
1550  return Ret;
1551 }
BOOL FASTCALL EndUserApiHook(VOID)
Definition: usrapihk.c:164
USERAPIHOOK guah
Definition: usrapihk.c:344
struct TraceInfo Info
_SEH2_TRY
Definition: create.c:4250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
GETSCROLLINFO GetScrollInfo
Definition: undocuser.h:334
#define ERR(fmt,...)
Definition: debug.h:109
_SEH2_END
Definition: create.c:4424
BOOL WINAPI RealGetScrollInfo(HWND Wnd, INT SBType, LPSCROLLINFO Info)
Definition: scrollbar.c:1479
static __inline void LoadUserApiHook()
Definition: user_x.h:85
BOOL FASTCALL BeginIfHookedUserApiHook(VOID)
Definition: usrapihk.c:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

◆ GetScrollPos()

INT WINAPI DECLSPEC_HOTPATCH GetScrollPos ( HWND  Wnd,
INT  Bar 
)

Definition at line 1559 of file scrollbar.c.

1560 {
1561  PWND pwnd;
1562  PSBDATA pSBData;
1563 
1564  TRACE("Wnd=%p Bar=%d\n", Wnd, Bar);
1565 
1566  /* Refer SB_CTL requests to the window */
1567  if (SB_CTL == Bar)
1568  {
1569  return SendMessageW(Wnd, SBM_GETPOS, (WPARAM) 0, (LPARAM) 0);
1570  }
1571  else if (Bar == SB_HORZ || Bar == SB_VERT )
1572  {
1573  pwnd = ValidateHwnd(Wnd);
1574  if (!pwnd) return 0;
1575 
1576  if (pwnd->pSBInfo)
1577  {
1578  pSBData = IntGetSBData(pwnd, Bar);
1579  return pSBData->pos;
1580  }
1581 
1583  TRACE("GetScrollPos No Scroll Info\n");
1584  return 0;
1585  }
1587  return 0;
1588 }
PSBDATA FASTCALL IntGetSBData(PWND pwnd, INT Bar)
Definition: scrollbar.c:80
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define SB_CTL
Definition: winuser.h:554
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
INT pos
Definition: ntuser.h:476
PSBINFO pSBInfo
Definition: ntuser.h:690
UINT_PTR WPARAM
Definition: windef.h:207
#define SBM_GETPOS
Definition: winuser.h:2060
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NO_SCROLLBARS
Definition: winerror.h:928
#define SetLastError(x)
Definition: compat.h:417
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ GetScrollRange()

BOOL WINAPI DECLSPEC_HOTPATCH GetScrollRange ( HWND  Wnd,
int  Bar,
LPINT  MinPos,
LPINT  MaxPos 
)

Definition at line 1596 of file scrollbar.c.

1597 {
1598  PWND pwnd;
1599  PSBDATA pSBData;
1600 
1601  TRACE("Wnd=%x Bar=%d Min=%p Max=%p\n", Wnd, Bar, MinPos, MaxPos);
1602 
1603  /* Refer SB_CTL requests to the window */
1604  if (SB_CTL == Bar)
1605  {
1606  return SendMessageW(Wnd, SBM_GETRANGE, (WPARAM) MinPos, (LPARAM) MaxPos);
1607  }
1608  else if (Bar == SB_HORZ || Bar == SB_VERT )
1609  {
1610  pwnd = ValidateHwnd(Wnd);
1611  if (!pwnd) return FALSE;
1612 
1613  if (pwnd->pSBInfo)
1614  {
1615  pSBData = IntGetSBData(pwnd, Bar);
1616  *MinPos = pSBData->posMin;
1617  *MaxPos = pSBData->posMax;
1618  }
1619  else
1620  {
1622  *MinPos = 0;
1623  *MaxPos = 0;
1624  }
1625  return TRUE;
1626  }
1628  return FALSE;
1629 }
PSBDATA FASTCALL IntGetSBData(PWND pwnd, INT Bar)
Definition: scrollbar.c:80
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define SB_CTL
Definition: winuser.h:554
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
PSBINFO pSBInfo
Definition: ntuser.h:690
UINT_PTR WPARAM
Definition: windef.h:207
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NO_SCROLLBARS
Definition: winerror.h:928
#define SetLastError(x)
Definition: compat.h:417
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
#define SBM_GETRANGE
Definition: winuser.h:2061
INT posMin
Definition: ntuser.h:473
Definition: ntuser.h:657
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
INT posMax
Definition: ntuser.h:474

◆ IntDrawScrollArrows()

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

Definition at line 232 of file scrollbar.c.

233 {
234  RECT RectLT, RectRB;
235  INT ScrollDirFlagLT, ScrollDirFlagRB;
236 
237  RectLT = RectRB = ScrollBarInfo->rcScrollBar;
238  if (Vertical)
239  {
240  ScrollDirFlagLT = DFCS_SCROLLUP;
241  ScrollDirFlagRB = DFCS_SCROLLDOWN;
242  RectLT.bottom = RectLT.top + ScrollBarInfo->dxyLineButton;
243  RectRB.top = RectRB.bottom - ScrollBarInfo->dxyLineButton;
244  }
245  else
246  {
247  ScrollDirFlagLT = DFCS_SCROLLLEFT;
248  ScrollDirFlagRB = DFCS_SCROLLRIGHT;
249  RectLT.right = RectLT.left + ScrollBarInfo->dxyLineButton;
250  RectRB.left = RectRB.right - ScrollBarInfo->dxyLineButton;
251  }
252 
253  if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_PRESSED)
254  {
255  ScrollDirFlagLT |= DFCS_PUSHED | DFCS_FLAT;
256  }
257  if (ScrollBarInfo->rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_UNAVAILABLE)
258  {
259  ScrollDirFlagLT |= DFCS_INACTIVE;
260  }
261  if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_PRESSED)
262  {
263  ScrollDirFlagRB |= DFCS_PUSHED | DFCS_FLAT;
264  }
266  {
267  ScrollDirFlagRB |= DFCS_INACTIVE;
268  }
269 
270  DrawFrameControl(hDC, &RectLT, DFC_SCROLL, ScrollDirFlagLT);
271  DrawFrameControl(hDC, &RectRB, DFC_SCROLL, ScrollDirFlagRB);
272 }
#define DFCS_FLAT
Definition: winuser.h:510
#define STATE_SYSTEM_UNAVAILABLE
Definition: winuser.h:2837
#define DFCS_INACTIVE
Definition: winuser.h:502
LONG top
Definition: windef.h:307
#define SCROLL_BOTTOM_ARROW
Definition: scrollbar.c:39
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:56
#define DFCS_PUSHED
Definition: winuser.h:503
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2840
#define DFCS_SCROLLDOWN
Definition: winuser.h:490
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3729
#define SCROLL_TOP_ARROW
Definition: scrollbar.c:35
#define DFCS_SCROLLRIGHT
Definition: winuser.h:492
#define DFCS_SCROLLUP
Definition: winuser.h:489
static HDC hDC
Definition: 3dtext.c:33
#define DFC_SCROLL
Definition: winuser.h:475
LONG bottom
Definition: windef.h:309
#define DFCS_SCROLLLEFT
Definition: winuser.h:491

Referenced by IntDrawScrollBar(), and IntScrollHandleScrollEvent().

◆ IntDrawScrollBar()

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

Definition at line 322 of file scrollbar.c.

323 {
324  //PSBWND pSBWnd;
325  //INT ThumbSize;
327  BOOL Vertical;
328 
329  /*
330  * Get scroll bar info.
331  */
332  switch (Bar)
333  {
334  case SB_HORZ:
335  Vertical = FALSE;
336  break;
337 
338  case SB_VERT:
339  Vertical = TRUE;
340  break;
341 
342  case SB_CTL:
343  Vertical = (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_VERT) != 0;
344  break;
345 
346  default:
347  return;
348  }
349  if (!IntGetScrollBarInfo(Wnd, Bar, &Info))
350  {
351  return;
352  }
353 
354  if (IsRectEmpty(&Info.rcScrollBar))
355  {
356  return;
357  }
358 
359  //ThumbSize = pSBWnd->pSBCalc->pxThumbBottom - pSBWnd->pSBCalc->pxThumbTop;
360 
361  /*
362  * Draw the arrows.
363  */
364  if (Info.dxyLineButton)
365  {
366  IntDrawScrollArrows(DC, &Info, Vertical);
367  }
368 
369  /*
370  * Draw the interior.
371  */
372  IntDrawScrollInterior(Wnd, DC, Bar, Vertical, &Info);
373 
374  /*
375  * If scroll bar has focus, reposition the caret.
376  */
377  if (Wnd == GetFocus() && SB_CTL == Bar)
378  {
379  if (Vertical)
380  {
381  SetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1);
382  }
383  else
384  {
385  SetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1);
386  }
387  }
388 }
static BOOL FASTCALL IntGetScrollBarInfo(HWND Wnd, INT Bar, PSCROLLBARINFO ScrollBarInfo)
Definition: scrollbar.c:314
#define TRUE
Definition: types.h:120
#define SB_CTL
Definition: winuser.h:554
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
#define GetWindowLongPtrW
Definition: winuser.h:4804
struct TraceInfo Info
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define SBS_VERT
Definition: winuser.h:334
Definition: polytest.cpp:40
static void IntDrawScrollInterior(HWND hWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINFO ScrollBarInfo)
Definition: scrollbar.c:117
#define GWL_STYLE
Definition: winuser.h:846
HWND WINAPI GetFocus(void)
Definition: window.c:1905
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
static VOID FASTCALL IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
Definition: scrollbar.c:232

◆ IntDrawScrollInterior()

static void IntDrawScrollInterior ( HWND  hWnd,
HDC  hDC,
INT  nBar,
BOOL  Vertical,
PSCROLLBARINFO  ScrollBarInfo 
)
static

Definition at line 117 of file scrollbar.c.

119 {
120  INT ThumbSize = ScrollBarInfo->xyThumbBottom - ScrollBarInfo->xyThumbTop;
121  INT ThumbTop = ScrollBarInfo->xyThumbTop;
122  RECT Rect;
123  HBRUSH hSaveBrush, hBrush;
124  BOOL TopSelected = FALSE, BottomSelected = FALSE;
125 
126  if (ScrollBarInfo->rgstate[SCROLL_TOP_RECT] & STATE_SYSTEM_PRESSED)
127  TopSelected = TRUE;
128  if (ScrollBarInfo->rgstate[SCROLL_BOTTOM_RECT] & STATE_SYSTEM_PRESSED)
129  BottomSelected = TRUE;
130 
131  /*
132  * Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
133  * The window-owned scrollbars need to call DefWndControlColor
134  * to correctly setup default scrollbar colors
135  */
136  if (nBar == SB_CTL)
137  {
139  if (!hBrush)
141  }
142  else
143  {
145  }
146 
147  hSaveBrush = SelectObject(hDC, hBrush);
148 
149  /* Calculate the scroll rectangle */
150  if (Vertical)
151  {
152  Rect.top = ScrollBarInfo->rcScrollBar.top + ScrollBarInfo->dxyLineButton;
153  Rect.bottom = ScrollBarInfo->rcScrollBar.bottom - ScrollBarInfo->dxyLineButton;
154  Rect.left = ScrollBarInfo->rcScrollBar.left;
155  Rect.right = ScrollBarInfo->rcScrollBar.right;
156  }
157  else
158  {
159  Rect.top = ScrollBarInfo->rcScrollBar.top;
160  Rect.bottom = ScrollBarInfo->rcScrollBar.bottom;
161  Rect.left = ScrollBarInfo->rcScrollBar.left + ScrollBarInfo->dxyLineButton;
162  Rect.right = ScrollBarInfo->rcScrollBar.right - ScrollBarInfo->dxyLineButton;
163  }
164 
165  /* Draw the scroll rectangles and thumb */
166  if (!ScrollBarInfo->xyThumbBottom)
167  {
168  PatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
169  Rect.bottom - Rect.top, PATCOPY);
170 
171  /* Cleanup and return */
172  SelectObject(hDC, hSaveBrush);
173  return;
174  }
175 
176  ThumbTop -= ScrollBarInfo->dxyLineButton;
177 
178  if (ScrollBarInfo->dxyLineButton)
179  {
180  if (Vertical)
181  {
182  if (ThumbSize)
183  {
184  PatBlt(hDC, Rect.left, Rect.top, Rect.right - Rect.left,
185  ThumbTop, TopSelected ? BLACKNESS : PATCOPY);
186  Rect.top += ThumbTop;
187  PatBlt(hDC, Rect.left, Rect.top + ThumbSize, Rect.right - Rect.left,
188  Rect.bottom - Rect.top - ThumbSize, BottomSelected ? BLACKNESS : PATCOPY);
189  Rect.bottom = Rect.top + ThumbSize;
190  }
191  else
192  {
193  if (ThumbTop)
194  {
195  PatBlt(hDC, Rect.left, ScrollBarInfo->dxyLineButton,
196  Rect.right - Rect.left, Rect.bottom - Rect.top, PATCOPY);
197  }
198  }
199  }
200  else
201  {
202  if (ThumbSize)
203  {
204  PatBlt(hDC, Rect.left, Rect.top, ThumbTop,
205  Rect.bottom - Rect.top, TopSelected ? BLACKNESS : PATCOPY);
206  Rect.left += ThumbTop;
207  PatBlt(hDC, Rect.left + ThumbSize, Rect.top,
208  Rect.right - Rect.left - ThumbSize, Rect.bottom - Rect.top,
209  BottomSelected ? BLACKNESS : PATCOPY);
210  Rect.right = Rect.left + ThumbSize;
211  }
212  else
213  {
214  if (ThumbTop)
215  {
216  PatBlt(hDC, ScrollBarInfo->dxyLineButton, Rect.top,
217  Rect.right - Rect.left, Rect.bottom - Rect.top, PATCOPY);
218  }
219  }
220  }
221  }
222 
223  /* Draw the thumb */
224  if (ThumbSize)
226 
227  /* Cleanup */
228  SelectObject(hDC, hSaveBrush);
229 }
#define BF_MIDDLE
Definition: winuser.h:468
#define TRUE
Definition: types.h:120
#define SB_CTL
Definition: winuser.h:554
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
#define CTLCOLOR_SCROLLBAR
Definition: winuser.h:946
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define BF_RECT
Definition: winuser.h:462
unsigned int BOOL
Definition: ntddk_ex.h:94
#define COLOR_SCROLLBAR
Definition: winuser.h:902
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define WM_CTLCOLORSCROLLBAR
Definition: winuser.h:1753
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2840
#define SCROLL_BOTTOM_RECT
Definition: scrollbar.c:38
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3729
HBRUSH DefWndControlColor(HDC hDC, UINT ctlType)
Definition: defwnd.c:33
#define SCROLL_TOP_RECT
Definition: scrollbar.c:36
#define PATCOPY
Definition: wingdi.h:334
#define EDGE_RAISED
Definition: winuser.h:450
static HDC hDC
Definition: 3dtext.c:33
#define BLACKNESS
Definition: wingdi.h:322
LONG bottom
Definition: windef.h:309
HBRUSH WINAPI GetSysColorBrush(_In_ int)
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:171
struct Rect Rect

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

◆ IntGetSBData()

static PSBDATA IntGetSBData ( PWND  pwnd,
INT  Bar 
)
static

Definition at line 90 of file scrollbar.c.

91 {
92  PSBWND pSBWnd;
93  PSBINFO pSBInfo;
94 
95  pSBInfo = DesktopPtrToUser(pwnd->pSBInfo);
96  switch (Bar)
97  {
98  case SB_HORZ:
99  return &pSBInfo->Horz;
100  case SB_VERT:
101  return &pSBInfo->Vert;
102  case SB_CTL:
103  if ( pwnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND)) )
104  {
105  ERR("IntGetSBData Wrong Extra bytes for CTL Scrollbar!\n");
106  return 0;
107  }
108  pSBWnd = (PSBWND)pwnd;
109  return (PSBDATA)&pSBWnd->SBCalc;
110  default:
111  ERR("IntGetSBData Bad Bar!\n");
112  }
113  return NULL;
114 }
#define SB_CTL
Definition: winuser.h:554
#define SB_VERT
Definition: winuser.h:553
SBDATA Vert
Definition: ntuser.h:483
#define SB_HORZ
Definition: winuser.h:552
PSBINFO pSBInfo
Definition: ntuser.h:690
SBCALC SBCalc
Definition: ntuser.h:738
ULONG cbwndExtra
Definition: ntuser.h:702
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
smooth NULL
Definition: ftsmooth.c:416
struct _SBWND * PSBWND
Definition: ntuser.h:733
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
SBDATA Horz
Definition: ntuser.h:482

◆ IntGetScrollBarInfo()

static BOOL FASTCALL IntGetScrollBarInfo ( HWND  Wnd,
INT  Bar,
PSCROLLBARINFO  ScrollBarInfo 
)
static

Definition at line 314 of file scrollbar.c.

315 {
316  ScrollBarInfo->cbSize = sizeof(SCROLLBARINFO);
317 
318  return NtUserGetScrollBarInfo(Wnd, IntScrollGetObjectId(Bar), ScrollBarInfo);
319 }
static LONG FASTCALL IntScrollGetObjectId(INT SBType)
Definition: scrollbar.c:304
BOOL APIENTRY NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
Definition: scrollbar.c:1172
struct tagSCROLLBARINFO SCROLLBARINFO

Referenced by IntDrawScrollBar(), and IntScrollHandleScrollEvent().

◆ IntScrollClipPos()

static POINT IntScrollClipPos ( PRECT  lpRect,
POINT  pt 
)
static

Definition at line 631 of file scrollbar.c.

632 {
633  if( pt.x < lpRect->left )
634  pt.x = lpRect->left;
635  else
636  if( pt.x > lpRect->right )
637  pt.x = lpRect->right;
638 
639  if( pt.y < lpRect->top )
640  pt.y = lpRect->top;
641  else
642  if( pt.y > lpRect->bottom )
643  pt.y = lpRect->bottom;
644 
645  return pt;
646 }
#define pt(x, y)
Definition: drawing.c:79
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309

Referenced by IntScrollHandleScrollEvent().

◆ IntScrollCreateScrollBar()

static void IntScrollCreateScrollBar ( HWND  Wnd,
LPCREATESTRUCTW  lpCreate 
)
static

Definition at line 1040 of file scrollbar.c.

1043 {
1044  SCROLLINFO Info;
1045 
1046  Info.cbSize = sizeof(SCROLLINFO);
1047  Info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
1048  Info.nMin = 0;
1049  Info.nMax = 0;
1050  Info.nPage = 0;
1051  Info.nPos = 0;
1052  Info.nTrackPos = 0;
1054 
1055  TRACE("hwnd=%p lpCreate=%p\n", Wnd, lpCreate);
1056 
1057 #if 0 /* FIXME */
1058  if (lpCreate->style & WS_DISABLED)
1059  {
1060  // info->flags = ESB_DISABLE_BOTH;
1061  //NtUserEnableScrollBar(Wnd,SB_CTL,(wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH));
1063  ERR("Created WS_DISABLED scrollbar\n");
1064  }
1065 #endif
1066  if (0 != (lpCreate->style & (SBS_SIZEGRIP | SBS_SIZEBOX)))
1067  {
1068  if (0 != (lpCreate->style & SBS_SIZEBOXTOPLEFTALIGN))
1069  {
1070  MoveWindow(Wnd, lpCreate->x, lpCreate->y, GetSystemMetrics(SM_CXVSCROLL) + 1,
1072  }
1073  else if (0 != (lpCreate->style & SBS_SIZEBOXBOTTOMRIGHTALIGN))
1074  {
1075  MoveWindow(Wnd, lpCreate->x + lpCreate->cx - GetSystemMetrics(SM_CXVSCROLL) - 1,
1076  lpCreate->y + lpCreate->cy - GetSystemMetrics(SM_CYHSCROLL) - 1,
1079  }
1080  }
1081  else if (0 != (lpCreate->style & SBS_VERT))
1082  {
1083  if (0 != (lpCreate->style & SBS_LEFTALIGN))
1084  {
1085  MoveWindow(Wnd, lpCreate->x, lpCreate->y,
1086  GetSystemMetrics(SM_CXVSCROLL) + 1, lpCreate->cy, FALSE);
1087  }
1088  else if (0 != (lpCreate->style & SBS_RIGHTALIGN))
1089  {
1090  MoveWindow(Wnd,
1091  lpCreate->x + lpCreate->cx - GetSystemMetrics(SM_CXVSCROLL) - 1,
1092  lpCreate->y,
1093  GetSystemMetrics(SM_CXVSCROLL) + 1, lpCreate->cy, FALSE);
1094  }
1095  }
1096  else /* SBS_HORZ */
1097  {
1098  if (0 != (lpCreate->style & SBS_TOPALIGN))
1099  {
1100  MoveWindow(Wnd, lpCreate->x, lpCreate->y,
1101  lpCreate->cx, GetSystemMetrics(SM_CYHSCROLL) + 1, FALSE);
1102  }
1103  else if (0 != (lpCreate->style & SBS_BOTTOMALIGN))
1104  {
1105  MoveWindow(Wnd,
1106  lpCreate->x,
1107  lpCreate->y + lpCreate->cy - GetSystemMetrics(SM_CYHSCROLL) - 1,
1108  lpCreate->cx, GetSystemMetrics(SM_CYHSCROLL) + 1, FALSE);
1109  }
1110  }
1111 }
#define SBS_SIZEBOXTOPLEFTALIGN
Definition: winuser.h:331
#define WS_DISABLED
Definition: pedump.c:621
#define SM_CYHSCROLL
Definition: winuser.h:952
#define SIF_RANGE
Definition: winuser.h:1221
#define SBS_SIZEBOX
Definition: winuser.h:329
#define SB_CTL
Definition: winuser.h:554
#define SIF_PAGE
Definition: winuser.h:1219
struct TraceInfo Info
#define WM_ENABLE
Definition: winuser.h:1597
DWORD APIENTRY NtUserSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: scrollbar.c:1367
#define SBS_BOTTOMALIGN
Definition: winuser.h:325
#define SBS_LEFTALIGN
Definition: winuser.h:327
#define SBS_VERT
Definition: winuser.h:334
struct tagSCROLLINFO SCROLLINFO
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define TRACE(s)
Definition: solgame.cpp:4
#define SBS_SIZEBOXBOTTOMRIGHTALIGN
Definition: winuser.h:330
#define SBS_TOPALIGN
Definition: winuser.h:333
int WINAPI GetSystemMetrics(_In_ int)
BOOL NTAPI NtUserMessageCall(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ResultInfo, DWORD dwType, BOOL Ansi)
Definition: message.c:2324
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define SIF_POS
Definition: winuser.h:1220
#define ERR(fmt,...)
Definition: debug.h:109
#define FNID_SCROLLBAR
Definition: ntuser.h:821
#define SBS_RIGHTALIGN
Definition: winuser.h:328
#define SM_CXVSCROLL
Definition: winuser.h:951

Referenced by ScrollBarWndProc_common().

◆ IntScrollDrawMovingThumb()

static VOID FASTCALL IntScrollDrawMovingThumb ( HDC  Dc,
PSCROLLBARINFO  ScrollBarInfo,
BOOL  Vertical 
)
static

Definition at line 275 of file scrollbar.c.

276 {
278  INT MaxSize;
279  INT OldTop;
280 
281  if (Vertical)
282  MaxSize = ScrollBarInfo->rcScrollBar.bottom - ScrollBarInfo->rcScrollBar.top;
283  else
284  MaxSize = ScrollBarInfo->rcScrollBar.right - ScrollBarInfo->rcScrollBar.left;
285 
286  MaxSize -= ScrollBarInfo->dxyLineButton + ScrollBarInfo->xyThumbBottom - ScrollBarInfo->xyThumbTop;
287 
288  if (Pos < ScrollBarInfo->dxyLineButton)
289  Pos = ScrollBarInfo->dxyLineButton;
290  else if (MaxSize < Pos)
291  Pos = MaxSize;
292 
293  OldTop = ScrollBarInfo->xyThumbTop;
294  ScrollBarInfo->xyThumbBottom = Pos + ScrollBarInfo->xyThumbBottom - ScrollBarInfo->xyThumbTop;
295  ScrollBarInfo->xyThumbTop = Pos;
296  IntDrawScrollInterior(ScrollTrackingWin, Dc, ScrollTrackingBar, Vertical, ScrollBarInfo);
297  ScrollBarInfo->xyThumbBottom = OldTop + ScrollBarInfo->xyThumbBottom - ScrollBarInfo->xyThumbTop;
298  ScrollBarInfo->xyThumbTop = OldTop;
299 
301 }
static INT ScrollTrackingPos
Definition: scrollbar.c:59
ush Pos
Definition: deflate.h:92
LONG top
Definition: windef.h:307
static INT ScrollTrackingBar
Definition: scrollbar.c:58
LONG left
Definition: windef.h:306
static BOOL ScrollMovingThumb
Definition: scrollbar.c:66
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:56
static HWND ScrollTrackingWin
Definition: scrollbar.c:57
static void IntDrawScrollInterior(HWND hWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINFO ScrollBarInfo)
Definition: scrollbar.c:117
LONG bottom
Definition: windef.h:309

Referenced by IntScrollHandleScrollEvent().

◆ IntScrollDrawSizeGrip()

static void FASTCALL IntScrollDrawSizeGrip ( HWND  Wnd,
HDC  Dc 
)
static

Definition at line 654 of file scrollbar.c.

655 {
656  RECT Rect;
657 
658  GetClientRect(Wnd, &Rect);
660  Rect.left = max(Rect.left, Rect.right - GetSystemMetrics(SM_CXVSCROLL) - 1);
661  Rect.top = max(Rect.top, Rect.bottom - GetSystemMetrics(SM_CYHSCROLL) - 1);
663 }
#define max(a, b)
Definition: svc.c:63
#define SM_CYHSCROLL
Definition: winuser.h:952
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define COLOR_SCROLLBAR
Definition: winuser.h:902
#define DFCS_SCROLLSIZEGRIP
Definition: winuser.h:494
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXVSCROLL
Definition: winuser.h:951
#define DFC_SCROLL
Definition: winuser.h:475
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
struct Rect Rect

Referenced by ScrollBarWndProc_common().

◆ IntScrollGetObjectId()

static LONG FASTCALL IntScrollGetObjectId ( INT  SBType)
static

Definition at line 304 of file scrollbar.c.

305 {
306  if (SBType == SB_VERT)
307  return OBJID_VSCROLL;
308  if (SBType == SB_HORZ)
309  return OBJID_HSCROLL;
310  return OBJID_CLIENT;
311 }
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
#define OBJID_CLIENT
Definition: winable.h:19
#define OBJID_HSCROLL
Definition: winable.h:21
#define OBJID_VSCROLL
Definition: winable.h:20

Referenced by IntGetScrollBarInfo(), and IntScrollHandleScrollEvent().

◆ IntScrollGetScrollBarRect()

static BOOL FASTCALL IntScrollGetScrollBarRect ( HWND  Wnd,
INT  Bar,
RECT Rect,
INT ArrowSize,
INT ThumbSize,
INT ThumbPos 
)
static

Definition at line 465 of file scrollbar.c.

468 {
469  INT Pixels;
470  BOOL Vertical;
471  PWND pWnd;
472  PSBINFO pSBInfo;
473  PSBDATA pSBData;
474  PSBWND pSBWnd;
475 
476  pWnd = ValidateHwnd( Wnd );
477  if (!pWnd) return FALSE;
478  pSBInfo = DesktopPtrToUser(pWnd->pSBInfo);
479 
480  *Rect = pWnd->rcClient;
481  OffsetRect( Rect, -pWnd->rcWindow.left, -pWnd->rcWindow.top );
482  if (pWnd->ExStyle & WS_EX_LAYOUTRTL)
483  mirror_rect( &pWnd->rcWindow, Rect );
484 
485  switch (Bar)
486  {
487  case SB_HORZ:
488 // WIN_GetRectangles( Wnd, COORDS_WINDOW, NULL, Rect );
489  Rect->top = Rect->bottom;
490  Rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
491  if (pWnd->style & WS_BORDER)
492  {
493  Rect->left--;
494  Rect->right++;
495  }
496  else if (pWnd->style & WS_VSCROLL)
497  {
498  Rect->right++;
499  }
500  Vertical = FALSE;
501  pSBData = &pSBInfo->Horz;
502  break;
503 
504  case SB_VERT:
505 // WIN_GetRectangles( Wnd, COORDS_WINDOW, NULL, Rect );
506  if (pWnd->ExStyle & WS_EX_LEFTSCROLLBAR)
507  {
508  Rect->right = Rect->left;
510  }
511  else
512  {
513  Rect->left = Rect->right;
515  }
516  if (pWnd->style & WS_BORDER)
517  {
518  Rect->top--;
519  Rect->bottom++;
520  }
521  else if (pWnd->style & WS_HSCROLL)
522  {
523  Rect->bottom++;
524  }
525  Vertical = TRUE;
526  pSBData = &pSBInfo->Vert;
527  break;
528 
529  case SB_CTL:
530  GetClientRect( Wnd, Rect );
531  Vertical = (pWnd->style & SBS_VERT);
532  pSBWnd = (PSBWND)pWnd;
533  pSBData = (PSBDATA)&pSBWnd->SBCalc;
534  break;
535 
536  default:
537  return FALSE;
538  }
539 
540  if (Vertical) Pixels = Rect->bottom - Rect->top;
541  else Pixels = Rect->right - Rect->left;
542 
543  if (Pixels <= 2 * GetSystemMetrics(SM_CXVSCROLL) + SCROLL_MIN_RECT)
544  {
545  if (SCROLL_MIN_RECT < Pixels)
546  *ArrowSize = (Pixels - SCROLL_MIN_RECT) / 2;
547  else
548  *ArrowSize = 0;
549  *ThumbPos = *ThumbSize = 0;
550  }
551  else
552  {
553  *ArrowSize = GetSystemMetrics(SM_CXVSCROLL);
555  if (pSBData->page)
556  {
557  *ThumbSize = MulDiv(Pixels, pSBData->page, (pSBData->posMax - pSBData->posMin + 1));
558  if (*ThumbSize < SCROLL_MIN_THUMB) *ThumbSize = SCROLL_MIN_THUMB;
559  }
560  else *ThumbSize = GetSystemMetrics(SM_CXVSCROLL);
561 
562  if (((Pixels -= *ThumbSize ) < 0) ||
563  (( pSBInfo->WSBflags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH))
564  {
565  /* Rectangle too small or scrollbar disabled -> no thumb */
566  *ThumbPos = *ThumbSize = 0;
567  }
568  else
569  {
570  INT Max = pSBData->posMax - max(pSBData->page - 1, 0);
571  if (pSBData->posMin >= Max)
572  *ThumbPos = *ArrowSize - SCROLL_ARROW_THUMB_OVERLAP;
573  else
574  *ThumbPos = *ArrowSize - SCROLL_ARROW_THUMB_OVERLAP
575  + MulDiv(Pixels, (pSBData->pos - pSBData->posMin),(Max - pSBData->posMin));
576  }
577  }
578  return Vertical;
579 }
#define max(a, b)
Definition: svc.c:63
DWORD ExStyle
Definition: ntuser.h:668
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SCROLL_ARROW_THUMB_OVERLAP
Definition: scrollbar.c:54
#define SCROLL_MIN_RECT
Definition: scrollbar.c:48
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SB_CTL
Definition: winuser.h:554
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
#define SB_VERT
Definition: winuser.h:553
INT page
Definition: ntuser.h:475
SBDATA Vert
Definition: ntuser.h:483
#define SB_HORZ
Definition: winuser.h:552
LONG top
Definition: windef.h:307
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
INT pos
Definition: ntuser.h:476
PSBINFO pSBInfo
Definition: ntuser.h:690
RECT rcClient
Definition: ntuser.h:681
LONG left
Definition: windef.h:306
INT WSBflags
Definition: ntuser.h:481
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392
int32_t INT
Definition: typedefs.h:56
SBCALC SBCalc
Definition: ntuser.h:738
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SCROLL_MIN_THUMB
Definition: scrollbar.c:51
#define Max(a, b)
Definition: cdprocs.h:70
#define SBS_VERT
Definition: winuser.h:334
struct tagSBDATA * PSBDATA
static void mirror_rect(const RECT *window_rect, RECT *rect)
Definition: scrollbar.c:71
int WINAPI GetSystemMetrics(_In_ int)
#define WS_HSCROLL
Definition: pedump.c:628
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
INT posMin
Definition: ntuser.h:473
RECT rcWindow
Definition: ntuser.h:680
struct _SBWND * PSBWND
Definition: ntuser.h:733
Definition: ntuser.h:657
SBDATA Horz
Definition: ntuser.h:482
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WS_BORDER
Definition: pedump.c:625
#define WS_VSCROLL
Definition: pedump.c:627
#define SM_CXVSCROLL
Definition: winuser.h:951
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
INT posMax
Definition: ntuser.h:474
DWORD style
Definition: ntuser.h:670

Referenced by ScrollBarWndProc_common().

◆ IntScrollGetThumbVal()

static UINT FASTCALL IntScrollGetThumbVal ( HWND  Wnd,
INT  SBType,
PSCROLLBARINFO  ScrollBarInfo,
BOOL  Vertical,
INT  Pos 
)
static

Definition at line 588 of file scrollbar.c.

590 {
591  PWND pWnd;
592  PSBDATA pSBData;
593  INT Pixels = Vertical ? ScrollBarInfo->rcScrollBar.bottom
594  - ScrollBarInfo->rcScrollBar.top
595  : ScrollBarInfo->rcScrollBar.right
596  - ScrollBarInfo->rcScrollBar.left;
597 
598  pWnd = ValidateHwnd( Wnd );
599  if (!pWnd) return FALSE;
600 
601  pSBData = IntGetSBData(pWnd, SBType);
602 
603  if ((Pixels -= 2 * ScrollBarInfo->dxyLineButton) <= 0)
604  {
605  return pSBData->posMin;
606  }
607 
608  if ((Pixels -= (ScrollBarInfo->xyThumbBottom - ScrollBarInfo->xyThumbTop)) <= 0)
609  {
610  return pSBData->posMin;
611  }
612 
613  Pos = Pos - ScrollBarInfo->dxyLineButton;
614  if (Pos < 0)
615  {
616  Pos = 0;
617  }
618  if (Pos > Pixels) Pos = Pixels;
619 
620  if (!pSBData->page)
621  Pos *= pSBData->posMax - pSBData->posMin;
622  else
623  Pos *= pSBData->posMax - pSBData->posMin - pSBData->page + 1;
624 
625  return pSBData->posMin + ((Pos + Pixels / 2) / Pixels);
626 }
PSBDATA FASTCALL IntGetSBData(PWND pwnd, INT Bar)
Definition: scrollbar.c:80
INT page
Definition: ntuser.h:475
ush Pos
Definition: deflate.h:92
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:56
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
INT posMin
Definition: ntuser.h:473
Definition: ntuser.h:657
LONG bottom
Definition: windef.h:309
INT posMax
Definition: ntuser.h:474

Referenced by IntScrollHandleScrollEvent().

◆ IntScrollHandleKbdEvent()

static void FASTCALL IntScrollHandleKbdEvent ( HWND  Wnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 689 of file scrollbar.c.

693 {
694  TRACE("Wnd=%p wParam=%ld lParam=%ld\n", Wnd, wParam, lParam);
695 
696  /* hide caret on first KEYDOWN to prevent flicker */
697  if (0 == (lParam & PFD_DOUBLEBUFFER_DONTCARE))
698  {
699  HideCaret(Wnd);
700  }
701 
702  switch(wParam)
703  {
704  case VK_PRIOR:
705  wParam = SB_PAGEUP;
706  break;
707 
708  case VK_NEXT:
710  break;
711 
712  case VK_HOME:
713  wParam = SB_TOP;
714  break;
715 
716  case VK_END:
717  wParam = SB_BOTTOM;
718  break;
719 
720  case VK_UP:
721  wParam = SB_LINEUP;
722  break;
723 
724  case VK_DOWN:
726  break;
727 
728  default:
729  return;
730  }
731 
732  SendMessageW(GetParent(Wnd),
733  (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE ) & SBS_VERT) ?
734  WM_VSCROLL : WM_HSCROLL), wParam, (LPARAM) Wnd);
735 }
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define VK_DOWN
Definition: winuser.h:2202
#define VK_PRIOR
Definition: winuser.h:2195
#define GetWindowLongPtrW
Definition: winuser.h:4804
WPARAM wParam
Definition: combotst.c:138
#define VK_NEXT
Definition: winuser.h:2196
#define VK_HOME
Definition: winuser.h:2198
#define VK_UP
Definition: winuser.h:2200
BOOL WINAPI HideCaret(_In_opt_ HWND)
LONG_PTR LPARAM
Definition: windef.h:208
#define SBS_VERT
Definition: winuser.h:334
#define TRACE(s)
Definition: solgame.cpp:4
#define PFD_DOUBLEBUFFER_DONTCARE
Definition: wingdi.h:315
#define GWL_STYLE
Definition: winuser.h:846
HWND WINAPI GetParent(_In_ HWND)
#define SB_TOP
Definition: winuser.h:578
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_LINEDOWN
Definition: winuser.h:565
#define WM_HSCROLL
Definition: winuser.h:1725
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
LPARAM lParam
Definition: combotst.c:139
#define VK_END
Definition: winuser.h:2197
#define WM_VSCROLL
Definition: winuser.h:1726

Referenced by ScrollBarWndProc_common().

◆ IntScrollHandleScrollEvent()

static VOID FASTCALL IntScrollHandleScrollEvent ( HWND  Wnd,
INT  SBType,
UINT  Msg,
POINT  Pt 
)
static

Definition at line 744 of file scrollbar.c.

745 {
746  static POINT PrevPt; /* Previous mouse position for timer events */
747  static UINT TrackThumbPos; /* Thumb position when tracking started. */
748  static INT LastClickPos; /* Position in the scroll-bar of the last
749  button-down event. */
750  static INT LastMousePos; /* Position in the scroll-bar of the last
751  mouse event. */
752 
753  DWORD HitTest;
754  HWND WndOwner, WndCtl;
755  BOOL Vertical;
756  HDC Dc;
757  SCROLLBARINFO ScrollBarInfo;
758  SETSCROLLBARINFO NewInfo;
759 
760  if (! IntGetScrollBarInfo(Wnd, SBType, &ScrollBarInfo))
761  {
762  return;
763  }
765  {
767  if (Wnd == GetCapture())
768  {
769  ReleaseCapture();
770  }
772  return;
773  }
774 
775  NewInfo.nTrackPos = ScrollTrackingVal;
776  NewInfo.reserved = ScrollBarInfo.reserved;
777  memcpy(NewInfo.rgstate, ScrollBarInfo.rgstate, (CCHILDREN_SCROLLBAR + 1) * sizeof(DWORD));
778 
779  if (SBType == SB_CTL && (GetWindowLongPtrW(Wnd, GWL_STYLE) & (SBS_SIZEGRIP | SBS_SIZEBOX)))
780  {
781  switch(Msg)
782  {
783  case WM_LBUTTONDOWN: /* Initialise mouse tracking */
784  HideCaret(Wnd); /* hide caret while holding down LBUTTON */
785  SetCapture(Wnd);
786  PrevPt = Pt;
787  ScrollTrackHitTest = HitTest = SCROLL_THUMB;
788  break;
789  case WM_MOUSEMOVE:
790  GetClientRect(GetParent(GetParent(Wnd)), &ScrollBarInfo.rcScrollBar);
791  PrevPt = Pt;
792  break;
793  case WM_LBUTTONUP:
794  ReleaseCapture();
796  if (Wnd == GetFocus()) ShowCaret(Wnd);
797  break;
798  case WM_SYSTIMER:
799  Pt = PrevPt;
800  break;
801  }
802  return;
803  }
804 
805  Dc = GetDCEx(Wnd, 0, DCX_CACHE | ((SB_CTL == SBType) ? 0 : DCX_WINDOW));
806  if (SB_VERT == SBType)
807  {
808  Vertical = TRUE;
809  }
810  else if (SB_HORZ == SBType)
811  {
812  Vertical = FALSE;
813  }
814  else
815  {
816  Vertical = (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_VERT));
817  }
818  WndOwner = (SB_CTL == SBType) ? GetParent(Wnd) : Wnd;
819  WndCtl = (SB_CTL == SBType) ? Wnd : NULL;
820 
821  switch (Msg)
822  {
823  case WM_LBUTTONDOWN: /* Initialise mouse tracking */
824  HideCaret(Wnd); /* hide caret while holding down LBUTTON */
825  ScrollTrackVertical = Vertical;
826  ScrollTrackHitTest = HitTest = IntScrollHitTest(&ScrollBarInfo, Vertical, Pt, FALSE );
827  LastClickPos = Vertical ? (Pt.y - ScrollBarInfo.rcScrollBar.top)
828  : (Pt.x - ScrollBarInfo.rcScrollBar.left);
829  LastMousePos = LastClickPos;
830  TrackThumbPos = ScrollBarInfo.xyThumbTop;
831  PrevPt = Pt;
832  if (SBType == SB_CTL && (GetWindowLongPtrW(Wnd, GWL_STYLE) & WS_TABSTOP)) SetFocus(Wnd);
833  SetCapture(Wnd);
834  /* Don't update scrollbar if disabled. */
836  {
838  NewInfo.rgstate[ScrollTrackHitTest] = ScrollBarInfo.rgstate[ScrollTrackHitTest];
839  NtUserSetScrollBarInfo(Wnd, IntScrollGetObjectId(SBType), &NewInfo);
840  }
841  break;
842 
843  case WM_MOUSEMOVE:
844  HitTest = IntScrollHitTest(&ScrollBarInfo, Vertical, Pt, TRUE);
845  PrevPt = Pt;
846  break;
847 
848  case WM_LBUTTONUP:
849  HitTest = SCROLL_NOWHERE;
850  ReleaseCapture();
851  /* if scrollbar has focus, show back caret */
852  if (Wnd == GetFocus()) ShowCaret(Wnd);
853  /* Don't update scrollbar if disabled. */
855  {
857  NewInfo.rgstate[ScrollTrackHitTest] = ScrollBarInfo.rgstate[ScrollTrackHitTest];
858  NtUserSetScrollBarInfo(Wnd, IntScrollGetObjectId(SBType), &NewInfo);
859 
860  IntDrawScrollInterior(Wnd,Dc,SBType,Vertical,&ScrollBarInfo);
861  IntDrawScrollArrows(Dc, &ScrollBarInfo, Vertical);
862  }
863  break;
864 
865  case WM_SYSTIMER:
866  Pt = PrevPt;
867  HitTest = IntScrollHitTest(&ScrollBarInfo, Vertical, Pt, FALSE);
868  break;
869 
870  default:
871  return; /* Should never happen */
872  }
873 
874  TRACE("Event: hwnd=%p bar=%d msg=%s pt=%d,%d hit=%d\n",
875  Wnd, SBType, SPY_GetMsgName(Msg,Wnd), Pt.x, Pt.y, HitTest );
876 
877  switch (ScrollTrackHitTest)
878  {
879  case SCROLL_NOWHERE: /* No tracking in progress */
880  break;
881 
882  case SCROLL_TOP_ARROW:
883  if (HitTest == ScrollTrackHitTest)
884  {
885  if ((WM_LBUTTONDOWN == Msg) || (WM_SYSTIMER == Msg))
886  {
887  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
888  SB_LINEUP, (LPARAM) WndCtl);
889  }
892  (TIMERPROC) NULL);
893  }
894  else
895  {
897  }
898  break;
899 
900  case SCROLL_TOP_RECT:
901  if (HitTest == ScrollTrackHitTest)
902  {
903  if ((WM_LBUTTONDOWN == Msg) || (WM_SYSTIMER == Msg))
904  {
905  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
906  SB_PAGEUP, (LPARAM) WndCtl);
907  }
910  (TIMERPROC) NULL);
911  }
912  else
913  {
915  }
916  break;
917 
918  case SCROLL_THUMB:
919  if (Msg == WM_LBUTTONDOWN)
920  {
921  ScrollTrackingWin = Wnd;
922  ScrollTrackingBar = SBType;
923  ScrollTrackingPos = TrackThumbPos + LastMousePos - LastClickPos;
924  ScrollTrackingVal = IntScrollGetThumbVal(Wnd, SBType, &ScrollBarInfo,
925  Vertical, ScrollTrackingPos);
926  NewInfo.nTrackPos = ScrollTrackingVal;
927  NtUserSetScrollBarInfo(Wnd, IntScrollGetObjectId(SBType), &NewInfo);
928  IntScrollDrawMovingThumb(Dc, &ScrollBarInfo, Vertical);
929  }
930  else if (Msg == WM_LBUTTONUP)
931  {
932  ScrollTrackingWin = 0;
933  ScrollTrackingVal = 0;
934  IntDrawScrollInterior(Wnd, Dc, SBType, Vertical, &ScrollBarInfo);
935  }
936  else /* WM_MOUSEMOVE */
937  {
938  UINT Pos;
939 
940  if (! IntScrollPtInRectEx(&ScrollBarInfo.rcScrollBar, Pt, Vertical))
941  {
942  Pos = LastClickPos;
943  }
944  else
945  {
946  Pt = IntScrollClipPos(&ScrollBarInfo.rcScrollBar, Pt);
947  Pos = Vertical ? (Pt.y - ScrollBarInfo.rcScrollBar.top)
948  : (Pt.x - ScrollBarInfo.rcScrollBar.left);
949  }
950  if (Pos != LastMousePos || ! ScrollMovingThumb)
951  {
952  LastMousePos = Pos;
953  ScrollTrackingPos = TrackThumbPos + Pos - LastClickPos;
954  ScrollTrackingVal = IntScrollGetThumbVal(Wnd, SBType, &ScrollBarInfo,
955  Vertical, ScrollTrackingPos);
956  NewInfo.nTrackPos = ScrollTrackingVal;
957  NtUserSetScrollBarInfo(Wnd, IntScrollGetObjectId(SBType), &NewInfo);
958  IntScrollDrawMovingThumb(Dc, &ScrollBarInfo, Vertical);
959  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
961  (LPARAM) WndCtl);
962  }
963  }
964  break;
965 
966  case SCROLL_BOTTOM_RECT:
967  if (HitTest == ScrollTrackHitTest)
968  {
969  if ((Msg == WM_LBUTTONDOWN) || (Msg == WM_SYSTIMER))
970  {
971  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
972  SB_PAGEDOWN, (LPARAM) WndCtl);
973  }
976  (TIMERPROC) NULL);
977  }
978  else
979  {
981  }
982  break;
983 
984  case SCROLL_BOTTOM_ARROW:
985  if (HitTest == ScrollTrackHitTest)
986  {
987  if ((Msg == WM_LBUTTONDOWN) || (Msg == WM_SYSTIMER))
988  {
989  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
990  SB_LINEDOWN, (LPARAM) WndCtl);
991  }
994  (TIMERPROC) NULL);
995  }
996  else KillSystemTimer(Wnd, SCROLL_TIMER);
997  break;
998  }
999 
1000  if (Msg == WM_LBUTTONDOWN)
1001  {
1002  if (SCROLL_THUMB == HitTest)
1003  {
1004  UINT Val = IntScrollGetThumbVal(Wnd, SBType, &ScrollBarInfo, Vertical,
1005  TrackThumbPos + LastMousePos - LastClickPos);
1006  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
1007  MAKEWPARAM(SB_THUMBTRACK, Val), (LPARAM) WndCtl);
1008  }
1009  }
1010 
1011  if (Msg == WM_LBUTTONUP)
1012  {
1013  HitTest = ScrollTrackHitTest;
1014  ScrollTrackHitTest = SCROLL_NOWHERE; /* Terminate tracking */
1015 
1016  if (SCROLL_THUMB == HitTest)
1017  {
1018  UINT Val = IntScrollGetThumbVal(Wnd, SBType, &ScrollBarInfo, Vertical,
1019  TrackThumbPos + LastMousePos - LastClickPos);
1020  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
1021  MAKEWPARAM(SB_THUMBPOSITION, Val), (LPARAM) WndCtl);
1022  }
1023  /* SB_ENDSCROLL doesn't report thumb position */
1024  SendMessageW(WndOwner, Vertical ? WM_VSCROLL : WM_HSCROLL,
1025  SB_ENDSCROLL, (LPARAM) WndCtl);
1026 
1027  /* Terminate tracking */
1028  ScrollTrackingWin = 0;
1029  }
1030 
1031  ReleaseDC(Wnd, Dc);
1032 }
static INT ScrollTrackingPos
Definition: scrollbar.c:59
static BOOL FASTCALL IntGetScrollBarInfo(HWND Wnd, INT Bar, PSCROLLBARINFO ScrollBarInfo)
Definition: scrollbar.c:314
#define SB_PAGEDOWN
Definition: winuser.h:569
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define SB_PAGEUP
Definition: winuser.h:568
#define STATE_SYSTEM_UNAVAILABLE
Definition: winuser.h:2837
static LONG FASTCALL IntScrollGetObjectId(INT SBType)
Definition: scrollbar.c:304
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
static BOOL FASTCALL IntScrollPtInRectEx(LPRECT Rect, POINT Pt, BOOL Vertical)
Definition: scrollbar.c:391
long y
Definition: polytest.cpp:48
#define SBS_SIZEBOX
Definition: winuser.h:329
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
static POINT IntScrollClipPos(PRECT lpRect, POINT pt)
Definition: scrollbar.c:631
#define WM_SYSTIMER
Definition: comctl32.h:112
#define SB_CTL
Definition: winuser.h:554
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
static DWORD ScrollTrackHitTest
Definition: scrollbar.c:62
static HDC
Definition: imagelist.c:92
ush Pos
Definition: deflate.h:92
#define CCHILDREN_SCROLLBAR
Definition: winuser.h:3720
LONG top
Definition: windef.h:307
static DWORD FASTCALL IntScrollHitTest(PSCROLLBARINFO ScrollBarInfo, BOOL Vertical, POINT Pt, BOOL Dragging)
Definition: scrollbar.c:419
HWND WINAPI SetFocus(_In_opt_ HWND)
static INT ScrollTrackingBar
Definition: scrollbar.c:58
#define SCROLL_BOTTOM_ARROW
Definition: scrollbar.c:39
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
static BOOL ScrollTrackVertical
Definition: scrollbar.c:63
static BOOL ScrollMovingThumb
Definition: scrollbar.c:66
int32_t INT
Definition: typedefs.h:56
VOID(CALLBACK * TIMERPROC)(HWND, UINT, UINT_PTR, DWORD)
Definition: winuser.h:2872
#define DCX_WINDOW
Definition: winuser.h:2095
const char * SPY_GetMsgName(UINT msg, HWND hWnd)
Definition: spy.c:2218
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
BOOL WINAPI HideCaret(_In_opt_ HWND)
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetCapture(void)
Definition: message.c:2879
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: ntuser.h:3584
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2840
smooth NULL
Definition: ftsmooth.c:416
#define SB_THUMBPOSITION
Definition: winuser.h:572
LONG_PTR LPARAM
Definition: windef.h:208
#define SB_ENDSCROLL
Definition: winuser.h:574
#define SBS_VERT
Definition: winuser.h:334
#define SCROLL_BOTTOM_RECT
Definition: scrollbar.c:38
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3729
UINT_PTR WINAPI SetSystemTimer(HWND, UINT_PTR, UINT, TIMERPROC)
Definition: ntwrapper.h:106
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define TRACE(s)
Definition: solgame.cpp:4
BOOL APIENTRY NtUserSetScrollBarInfo(HWND hWnd, LONG idObject, SETSCROLLBARINFO *info)
Definition: scrollbar.c:1443
#define SCROLL_FIRST_DELAY
Definition: scrollbar.c:41
#define SB_THUMBTRACK
Definition: winuser.h:573
static HWND ScrollTrackingWin
Definition: scrollbar.c:57
#define SCROLL_TOP_ARROW
Definition: scrollbar.c:35
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SCROLL_TOP_RECT
Definition: scrollbar.c:36
static void IntDrawScrollInterior(HWND hWnd, HDC hDC, INT nBar, BOOL Vertical, PSCROLLBARINFO ScrollBarInfo)
Definition: scrollbar.c:117
static INT ScrollTrackingVal
Definition: scrollbar.c:60
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WS_TABSTOP
Definition: pedump.c:634
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DCX_CACHE
Definition: winuser.h:2096
HWND WINAPI GetParent(_In_ HWND)
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define SCROLL_THUMB
Definition: scrollbar.c:37
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1759
unsigned int UINT
Definition: ndis.h:50
#define SB_LINEDOWN
Definition: winuser.h:565
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define WM_HSCROLL
Definition: winuser.h:1725
#define SB_LINEUP
Definition: winuser.h:564
static UINT FASTCALL IntScrollGetThumbVal(HWND Wnd, INT SBType, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical, INT Pos)
Definition: scrollbar.c:588
HWND WINAPI GetFocus(void)
Definition: window.c:1905
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
struct @1587 Msg[]
static VOID FASTCALL IntScrollDrawMovingThumb(HDC Dc, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
Definition: scrollbar.c:275
#define SCROLL_REPEAT_DELAY
Definition: scrollbar.c:43
BOOL WINAPI ShowCaret(_In_opt_ HWND)
static VOID FASTCALL IntDrawScrollArrows(HDC hDC, PSCROLLBARINFO ScrollBarInfo, BOOL Vertical)
Definition: scrollbar.c:232
#define WM_VSCROLL
Definition: winuser.h:1726
#define SCROLL_NOWHERE
Definition: scrollbar.c:34
#define SCROLL_TIMER
Definition: scrollbar.c:45

Referenced by ScrollBarWndProc_common(), and ScrollTrackScrollBar().

◆ IntScrollHitTest()

static DWORD FASTCALL IntScrollHitTest ( PSCROLLBARINFO  ScrollBarInfo,
BOOL  Vertical,
POINT  Pt,
BOOL  Dragging 
)
static

Definition at line 419 of file scrollbar.c.

420 {
421  INT ArrowSize, ThumbSize, ThumbPos;
422 
423  if ((Dragging && ! IntScrollPtInRectEx(&ScrollBarInfo->rcScrollBar, Pt, Vertical)) ||
424  ! PtInRect(&ScrollBarInfo->rcScrollBar, Pt)) return SCROLL_NOWHERE;
425 
426  ThumbPos = ScrollBarInfo->xyThumbTop;
427  ThumbSize = ScrollBarInfo->xyThumbBottom - ThumbPos;
428  ArrowSize = ScrollBarInfo->dxyLineButton;
429 
430  if (Vertical)
431  {
432  if (Pt.y < ScrollBarInfo->rcScrollBar.top + ArrowSize) return SCROLL_TOP_ARROW;
433  if (Pt.y >= ScrollBarInfo->rcScrollBar.bottom - ArrowSize) return SCROLL_BOTTOM_ARROW;
434  if (!ThumbPos) return SCROLL_TOP_RECT;
435  Pt.y -= ScrollBarInfo->rcScrollBar.top;
436  if (Pt.y < ThumbPos) return SCROLL_TOP_RECT;
437  if (Pt.y >= ThumbPos + ThumbSize) return SCROLL_BOTTOM_RECT;
438  }
439  else
440  {
441  if (Pt.x < ScrollBarInfo->rcScrollBar.left + ArrowSize) return SCROLL_TOP_ARROW;
442  if (Pt.x >= ScrollBarInfo->rcScrollBar.right - ArrowSize) return SCROLL_BOTTOM_ARROW;
443  if (!ThumbPos) return SCROLL_TOP_RECT;
444  Pt.x -= ScrollBarInfo->rcScrollBar.left;
445  if (Pt.x < ThumbPos) return SCROLL_TOP_RECT;
446  if (Pt.x >= ThumbPos + ThumbSize) return SCROLL_BOTTOM_RECT;
447  }
448 
449  return SCROLL_THUMB;
450 }
static BOOL FASTCALL IntScrollPtInRectEx(LPRECT Rect, POINT Pt, BOOL Vertical)
Definition: scrollbar.c:391
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:307
#define SCROLL_BOTTOM_ARROW
Definition: scrollbar.c:39
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:56
#define SCROLL_BOTTOM_RECT
Definition: scrollbar.c:38
#define SCROLL_TOP_ARROW
Definition: scrollbar.c:35
#define SCROLL_TOP_RECT
Definition: scrollbar.c:36
#define SCROLL_THUMB
Definition: scrollbar.c:37
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
LONG bottom
Definition: windef.h:309
#define SCROLL_NOWHERE
Definition: scrollbar.c:34

Referenced by IntScrollHandleScrollEvent().

◆ IntScrollPtInRectEx()

static BOOL FASTCALL IntScrollPtInRectEx ( LPRECT  Rect,
POINT  Pt,
BOOL  Vertical 
)
static

Definition at line 391 of file scrollbar.c.

392 {
393  RECT TempRect = *Rect;
394  int scrollbarWidth;
395 
396  /* Pad hit rect to allow mouse to be dragged outside of scrollbar and
397  * still be considered in the scrollbar. */
398  if (Vertical)
399  {
400  scrollbarWidth = Rect->right - Rect->left;
401  TempRect.left -= scrollbarWidth*8;
402  TempRect.right += scrollbarWidth*8;
403  TempRect.top -= scrollbarWidth*2;
404  TempRect.bottom += scrollbarWidth*2;
405  }
406  else
407  {
408  scrollbarWidth = Rect->bottom - Rect->top;
409  TempRect.left -= scrollbarWidth*2;
410  TempRect.right += scrollbarWidth*2;
411  TempRect.top -= scrollbarWidth*8;
412  TempRect.bottom += scrollbarWidth*8;
413  }
414 
415  return PtInRect(&TempRect, Pt);
416 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
LONG bottom
Definition: windef.h:309
struct Rect Rect

Referenced by IntScrollHandleScrollEvent(), and IntScrollHitTest().

◆ IntSetScrollInfo()

static DWORD FASTCALL IntSetScrollInfo ( HWND  Wnd,
LPCSCROLLINFO  Info,
BOOL  bRedraw 
)
static

Definition at line 1171 of file scrollbar.c.

1172 {
1173  DWORD Ret = NtUserSetScrollInfo(Wnd, SB_CTL, Info, bRedraw);
1174  if (Ret) IntNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, Wnd, OBJID_CLIENT, CHILDID_SELF, WEF_SETBYWNDPTI);
1175  return Ret;
1176 }
#define SB_CTL
Definition: winuser.h:554
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
struct TraceInfo Info
DWORD APIENTRY NtUserSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: scrollbar.c:1367
#define CHILDID_SELF
Definition: winable.h:14
#define WEF_SETBYWNDPTI
Definition: ntuser.h:213
#define OBJID_CLIENT
Definition: winable.h:19
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by ScrollBarWndProc_common().

◆ KillSystemTimer()

BOOL WINAPI KillSystemTimer ( HWND  ,
UINT_PTR   
)

Definition at line 35 of file timer.c.

36 {
37  return NtUserxKillSystemTimer(hWnd, IDEvent);
38 }
HWND hWnd
Definition: settings.c:17
EXTINLINE BOOL NtUserxKillSystemTimer(HWND hWnd, UINT_PTR IDEvent)
Definition: ntwrapper.h:711

Referenced by IntScrollHandleScrollEvent().

◆ RealGetScrollInfo()

BOOL WINAPI RealGetScrollInfo ( HWND  Wnd,
INT  SBType,
LPSCROLLINFO  Info 
)

Definition at line 1479 of file scrollbar.c.

1480 {
1481  PWND pWnd;
1482  PSBDATA pSBData;
1483 
1484  if (SB_CTL == SBType)
1485  {
1486  return SendMessageW(Wnd, SBM_GETSCROLLINFO, 0, (LPARAM) Info);
1487  }
1488 
1489  pWnd = ValidateHwnd(Wnd);
1490  if (!pWnd) return FALSE;
1491 
1492  if (SBType < SB_HORZ || SBType > SB_VERT)
1493  {
1495  return FALSE;
1496  }
1497  if (!pWnd->pSBInfo)
1498  {
1500  return FALSE;
1501  }
1502  pSBData = IntGetSBData(pWnd, SBType);
1503  return NtUserSBGetParms(Wnd, SBType, pSBData, Info);
1504 }
PSBDATA FASTCALL IntGetSBData(PWND pwnd, INT Bar)
Definition: scrollbar.c:80
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define SB_CTL
Definition: winuser.h:554
#define SB_VERT
Definition: winuser.h:553
PSBINFO pSBInfo
Definition: ntuser.h:690
struct TraceInfo Info
LONG_PTR LPARAM
Definition: windef.h:208
BOOL APIENTRY NtUserSBGetParms(HWND hWnd, int fnBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
Definition: scrollbar.c:1218
#define ERROR_NO_SCROLLBARS
Definition: winerror.h:928
#define SetLastError(x)
Definition: compat.h:417
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by GetScrollInfo(), and ResetUserApiHook().

◆ RealSetScrollInfo()

INT WINAPI RealSetScrollInfo ( HWND  Wnd,
int  SBType,
LPCSCROLLINFO  Info,
BOOL  bRedraw 
)

Definition at line 1632 of file scrollbar.c.

1633 {
1634  if (SB_CTL == SBType)
1635  {
1636  return SendMessageW(Wnd, SBM_SETSCROLLINFO, (WPARAM) bRedraw, (LPARAM) Info);
1637  }
1638  else
1639  {
1640  return NtUserSetScrollInfo(Wnd, SBType, Info, bRedraw);
1641  }
1642 }
#define SB_CTL
Definition: winuser.h:554
UINT_PTR WPARAM
Definition: windef.h:207
struct TraceInfo Info
DWORD APIENTRY NtUserSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: scrollbar.c:1367
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ResetUserApiHook(), SetScrollInfo(), and SetScrollPos().

◆ SCROLL_RefreshScrollBar()

static void SCROLL_RefreshScrollBar ( HWND  hwnd,
INT  nBar,
BOOL  arrows,
BOOL  interior 
)
static

Definition at line 671 of file scrollbar.c.

673 {
674  HDC hdc = GetDCEx( hwnd, 0,
675  DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) );
676  if (!hdc) return;
677 
678  IntDrawScrollBar( hwnd, hdc, nBar);//, arrows, interior );
679  ReleaseDC( hwnd, hdc );
680 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define SB_CTL
Definition: winuser.h:554
static HDC
Definition: imagelist.c:92
#define DCX_WINDOW
Definition: winuser.h:2095
void IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar)
Definition: scrollbar.c:1073
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
#define DCX_CACHE
Definition: winuser.h:2096

Referenced by EnableScrollBar().

◆ ScrollBarWndProc_common()

LRESULT WINAPI ScrollBarWndProc_common ( WNDPROC  DefWindowProc,
HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 1183 of file scrollbar.c.

1184 {
1185 #ifdef __REACTOS__ // Do this now, remove after Server side is fixed.
1186  PWND pWnd;
1187  PSBWND pSBWnd;
1188  SCROLLINFO ScrollInfo;
1189 
1190  pWnd = ValidateHwnd(Wnd);
1191  if (pWnd)
1192  {
1193  if (!pWnd->fnid)
1194  {
1195  TRACE("ScrollBar CTL size %d\n", (sizeof(SBWND)-sizeof(WND)));
1196  if ( pWnd->cbwndExtra < (sizeof(SBWND)-sizeof(WND)) )
1197  {
1198  ERR("Wrong Extra bytes for Scrollbar!\n");
1199  return 0;
1200  }
1201 
1202  if (Msg != WM_CREATE)
1203  {
1204  return DefWindowProc(Wnd, Msg, wParam, lParam);
1205  }
1207  }
1208  else
1209  {
1210  if (pWnd->fnid != FNID_SCROLLBAR)
1211  {
1212  ERR("Wrong window class for Scrollbar!\n");
1213  return 0;
1214  }
1215  }
1216  }
1217 #endif
1218 
1219  if (! IsWindow(Wnd))
1220  {
1221  return 0;
1222  }
1223 
1224  // Must be a scroll bar control!
1225  pSBWnd = (PSBWND)pWnd;
1226 
1227  switch (Msg)
1228  {
1229  case WM_CREATE:
1231  break;
1232 
1233  case WM_ENABLE:
1234  {
1236  }
1237 
1238  case WM_LBUTTONDBLCLK:
1239  case WM_LBUTTONDOWN:
1240  if (GetWindowLongW( Wnd, GWL_STYLE ) & SBS_SIZEGRIP)
1241  {
1245  }
1246  else
1247  {
1248  POINT Pt;
1249  Pt.x = (short)LOWORD(lParam);
1250  Pt.y = (short)HIWORD(lParam);
1251  ScrollTrackScrollBar(Wnd, SB_CTL, Pt);
1252  }
1253  break;
1254 
1255  case WM_LBUTTONUP:
1256  case WM_MOUSEMOVE:
1257  case WM_SYSTIMER:
1258  {
1259  POINT Pt;
1260  Pt.x = (short)LOWORD(lParam);
1261  Pt.y = (short)HIWORD(lParam);
1263  }
1264  break;
1265 
1266  case WM_KEYDOWN:
1268  break;
1269 
1270  case WM_KEYUP:
1271  ShowCaret(Wnd);
1272  break;
1273 
1274  case WM_SETFOCUS:
1275  {
1276  /* Create a caret when a ScrollBar get focus */
1277  RECT Rect;
1278  int ArrowSize, ThumbSize, ThumbPos, Vertical;
1279 
1280  Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect,
1281  &ArrowSize, &ThumbSize, &ThumbPos);
1282  if (! Vertical)
1283  {
1284  CreateCaret(Wnd, (HBITMAP) 1, ThumbSize - 2, Rect.bottom - Rect.top - 2);
1285  SetCaretPos(ThumbPos + 1, Rect.top + 1);
1286  }
1287  else
1288  {
1289  CreateCaret(Wnd, (HBITMAP) 1, Rect.right - Rect.left - 2, ThumbSize - 2);
1290  SetCaretPos(Rect.top + 1, ThumbPos + 1);
1291  }
1292  ShowCaret(Wnd);
1293  }
1294  break;
1295 
1296  case WM_KILLFOCUS:
1297  {
1298  RECT Rect;
1299  int ArrowSize, ThumbSize, ThumbPos, Vertical;
1300 
1301  Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect,
1302  &ArrowSize, &ThumbSize, &ThumbPos);
1303  if (! Vertical)
1304  {
1305  Rect.left = ThumbPos + 1;
1306  Rect.right = Rect.left + ThumbSize;
1307  }
1308  else
1309  {
1310  Rect.top = ThumbPos + 1;
1311  Rect.bottom = Rect.top + ThumbSize;
1312  }
1313  HideCaret(Wnd);
1314  InvalidateRect(Wnd, &Rect, FALSE);
1315  DestroyCaret();
1316  }
1317  break;
1318 
1319  case WM_ERASEBKGND:
1320  return 1;
1321 
1322  case WM_GETDLGCODE:
1323  return DLGC_WANTARROWS; /* Windows returns this value */
1324 
1325  case WM_PAINT:
1326  {
1327  PAINTSTRUCT Ps;
1328  HDC Dc;
1329 
1330  Dc = (0 != wParam ? (HDC) wParam : BeginPaint(Wnd, &Ps));
1331 
1333  {
1334  IntScrollDrawSizeGrip(Wnd, Dc);
1335  }
1336  else if (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEBOX))
1337  {
1338  RECT Rect;
1339  GetClientRect(Wnd, &Rect);
1341  }
1342  else
1343  {
1344  IntDrawScrollBar(Wnd, Dc, SB_CTL/*, TRUE, TRUE*/);
1345  }
1346 
1347  if (0 == wParam)
1348  {
1349  EndPaint(Wnd, &Ps);
1350  }
1351  }
1352  break;
1353 
1354  case SBM_GETPOS:
1355  return pSBWnd->SBCalc.pos;
1356 
1357  case SBM_GETRANGE:
1358  *(LPINT)wParam = pSBWnd->SBCalc.posMin;
1359  *(LPINT)lParam = pSBWnd->SBCalc.posMax;
1360  // This message does not return a value.
1361  return 0;
1362 
1363  case SBM_ENABLE_ARROWS:
1364  return EnableScrollBar( Wnd, SB_CTL, wParam );
1365 
1366  case SBM_SETPOS:
1367  {
1368  ScrollInfo.cbSize = sizeof(SCROLLINFO);
1369  ScrollInfo.fMask = SIF_POS|SIF_PREVIOUSPOS;
1370  ScrollInfo.nPos = wParam;
1371  return IntSetScrollInfo(Wnd, &ScrollInfo, lParam);
1372  }
1373 
1374  case SBM_SETRANGEREDRAW:
1375  case SBM_SETRANGE:
1376  {
1377  ScrollInfo.cbSize = sizeof(SCROLLINFO);
1378  ScrollInfo.fMask = SIF_RANGE|SIF_PREVIOUSPOS;
1379  ScrollInfo.nMin = wParam;
1380  ScrollInfo.nMax = lParam;
1381  return IntSetScrollInfo(Wnd, &ScrollInfo, Msg == SBM_SETRANGEREDRAW ? TRUE : FALSE);
1382  }
1383 
1384  case SBM_SETSCROLLINFO:
1386 
1387  case SBM_GETSCROLLINFO:
1388  {
1389  PSBDATA pSBData = (PSBDATA)&pSBWnd->SBCalc;
1390  DWORD ret = NtUserSBGetParms(Wnd, SB_CTL, pSBData, (SCROLLINFO *) lParam);
1391  if (!ret)
1392  {
1393  ERR("SBM_GETSCROLLINFO No ScrollInfo\n");
1394  }
1395  return ret;
1396  }
1397  case SBM_GETSCROLLBARINFO:
1398  ((PSCROLLBARINFO)lParam)->cbSize = sizeof(SCROLLBARINFO);
1400 
1401  case 0x00e5:
1402  case 0x00e7:
1403  case 0x00e8:
1404  case 0x00ec:
1405  case 0x00ed:
1406  case 0x00ee:
1407  case 0x00ef:
1408  WARN("unknown Win32 msg %04x wp=%08lx lp=%08lx\n",
1409  Msg, wParam, lParam );
1410  break;
1411 
1412  default:
1413  if (WM_USER <= Msg)
1414  {
1415  WARN("unknown msg %04x wp=%04lx lp=%08lx\n", Msg, wParam, lParam);
1416  }
1417  if (unicode)
1418  return DefWindowProcW( Wnd, Msg, wParam, lParam );
1419  else
1420  return DefWindowProcA( Wnd, Msg, wParam, lParam );
1421  }
1422 
1423  return 0;
1424 }
#define WMSZ_BOTTOMRIGHT
Definition: winuser.h:2446
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
long y
Definition: polytest.cpp:48
#define SBS_SIZEBOX
Definition: winuser.h:329
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_SYSTIMER
Definition: comctl32.h:112
#define SB_CTL
Definition: winuser.h:554
long x
Definition: polytest.cpp:48
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
static void IntScrollCreateScrollBar(HWND Wnd, LPCREATESTRUCTW lpCreate)
Definition: scrollbar.c:1040
#define WARN(fmt,...)
Definition: debug.h:111
static HDC
Definition: imagelist.c:92
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define GWL_EXSTYLE
Definition: winuser.h:845
#define SBM_SETRANGE
Definition: winuser.h:2063
static void FASTCALL IntScrollDrawSizeGrip(HWND Wnd, HDC Dc)
Definition: scrollbar.c:654
BOOL WINAPI DECLSPEC_HOTPATCH EnableScrollBar(HWND hwnd, UINT nBar, UINT flags)
Definition: scrollbar.c:1447
#define GetWindowLongPtrW
Definition: winuser.h:4804
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WPARAM wParam
Definition: combotst.c:138
#define WM_ENABLE
Definition: winuser.h:1597
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SBCALC SBCalc
Definition: ntuser.h:738
struct tagSCROLLBARINFO * PSCROLLBARINFO
#define SBM_GETPOS
Definition: winuser.h:2060
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
ULONG cbwndExtra
Definition: ntuser.h:702
BOOL APIENTRY NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
Definition: scrollbar.c:1172
BOOL WINAPI HideCaret(_In_opt_ HWND)
DWORD fnid
Definition: ntuser.h:673
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
#define COLOR_SCROLLBAR
Definition: winuser.h:902
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
void IntDrawScrollBar(PWND Wnd, HDC DC, INT Bar)
Definition: scrollbar.c:1073
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define WM_KEYDOWN
Definition: winuser.h:1697
BOOL APIENTRY NtUserSBGetParms(HWND hWnd, int fnBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
Definition: scrollbar.c:1218
#define SBM_ENABLE_ARROWS
Definition: winuser.h:2059
INT posMax
Definition: ntuser.h:489
#define DefWindowProc
Definition: ros2win.h:31
VOID FASTCALL ScrollTrackScrollBar(HWND Wnd, INT SBType, POINT Pt)
Definition: scrollbar.c:1122
struct tagSCROLLINFO SCROLLINFO
struct tagSBDATA * PSBDATA
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define OBJID_CLIENT
Definition: winable.h:19
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_KILLFOCUS
Definition: winuser.h:1596
INT posMin
Definition: ntuser.h:488
static DWORD FASTCALL IntSetScrollInfo(HWND Wnd, LPCSCROLLINFO Info, BOOL bRedraw)
Definition: scrollbar.c:1171
#define WM_KEYUP
Definition: winuser.h:1698
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_PAINT
Definition: winuser.h:1602
int ret
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
#define SBM_GETRANGE
Definition: winuser.h:2061
INT pos
Definition: ntuser.h:491
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct _SBWND * PSBWND
#define WM_USER
Definition: winuser.h:1877
Definition: ntuser.h:733
#define SIF_POS
Definition: winuser.h:1220
#define ERR(fmt,...)
Definition: debug.h:109
#define GWL_STYLE
Definition: winuser.h:846
Definition: ntuser.h:657
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SIF_PREVIOUSPOS
Definition: undocuser.h:87
HWND WINAPI GetParent(_In_ HWND)
#define FNID_SCROLLBAR
Definition: ntuser.h:821
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define SC_SIZE
Definition: winuser.h:2559
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1759
struct tagSCROLLBARINFO SCROLLBARINFO
#define WM_MOUSEMOVE
Definition: winuser.h:1757
static BOOL FASTCALL IntScrollGetScrollBarRect(HWND Wnd, INT Bar, RECT *Rect, INT *ArrowSize, INT *ThumbSize, INT *ThumbPos)
Definition: scrollbar.c:465
struct @1587 Msg[]
#define WM_CREATE
Definition: winuser.h:1590
static VOID FASTCALL IntScrollHandleScrollEvent(HWND Wnd, INT SBType, UINT Msg, POINT Pt)
Definition: scrollbar.c:744
#define HIWORD(l)
Definition: typedefs.h:246
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4126
BOOL WINAPI ShowCaret(_In_opt_ HWND)
static HBITMAP
Definition: button.c:44
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WM_SETFOCUS
Definition: winuser.h:1595
static void FASTCALL IntScrollHandleKbdEvent(HWND Wnd, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:689
#define SBM_SETPOS
Definition: winuser.h:2062
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_SYSCOMMAND
Definition: winuser.h:1723
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
#define DLGC_WANTARROWS
Definition: winuser.h:2585
#define ESB_ENABLE_BOTH
Definition: winuser.h:563
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2445
struct Rect Rect
#define SBM_SETRANGEREDRAW
Definition: winuser.h:2064
int * LPINT
Definition: windef.h:178

Referenced by ScrollBarWndProcA(), and ScrollBarWndProcW().

◆ ScrollBarWndProcA()

LRESULT WINAPI ScrollBarWndProcA ( HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1433 of file scrollbar.c.

1434 {
1436 }
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI ScrollBarWndProc_common(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: scrollbar.c:1183
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct @1587 Msg[]
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ ScrollBarWndProcW()

LRESULT WINAPI ScrollBarWndProcW ( HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1427 of file scrollbar.c.

1428 {
1430 }
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI ScrollBarWndProc_common(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: scrollbar.c:1183
struct @1587 Msg[]
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ ScrollTrackScrollBar()

VOID FASTCALL ScrollTrackScrollBar ( HWND  Wnd,
INT  SBType,
POINT  Pt 
)

Definition at line 1122 of file scrollbar.c.

1123 {
1124  MSG Msg;
1125  UINT XOffset = 0, YOffset = 0;
1126 
1127  if (SBType != SB_CTL)
1128  { // Used with CMD mouse tracking.
1129  PWND pwnd = ValidateHwnd(Wnd);
1130  if (!pwnd) return;
1131  XOffset = pwnd->rcClient.left - pwnd->rcWindow.left;
1132  YOffset = pwnd->rcClient.top - pwnd->rcWindow.top;
1133 // RECT rect;
1134 // WIN_GetRectangles( Wnd, COORDS_CLIENT, &rect, NULL );
1135  ScreenToClient(Wnd, &Pt);
1136 // Pt.x -= rect.left;
1137 // Pt.y -= rect.top;
1138  Pt.x += XOffset;
1139  Pt.y += YOffset;
1140  }
1141 
1142  IntScrollHandleScrollEvent(Wnd, SBType, WM_LBUTTONDOWN, Pt);
1143 
1144  do
1145  {
1146  if (!GetMessageW(&Msg, 0, 0, 0)) break;
1147  if (CallMsgFilterW(&Msg, MSGF_SCROLLBAR)) continue;
1148  if ( Msg.message == WM_LBUTTONUP ||
1149  Msg.message == WM_MOUSEMOVE ||
1150  (Msg.message == WM_SYSTIMER && Msg.wParam == SCROLL_TIMER))
1151  {
1152  Pt.x = LOWORD(Msg.lParam) + XOffset;
1153  Pt.y = HIWORD(Msg.lParam) + YOffset;
1154  IntScrollHandleScrollEvent(Wnd, SBType, Msg.message, Pt);
1155  }
1156  else
1157  {
1160  }
1161  if (!IsWindow(Wnd))
1162  {
1163  ReleaseCapture();
1164  break;
1165  }
1166  } while (Msg.message != WM_LBUTTONUP && GetCapture() == Wnd);
1167 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_SYSTIMER
Definition: comctl32.h:112
#define SB_CTL
Definition: winuser.h:554
long x
Definition: polytest.cpp:48
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
LONG top
Definition: windef.h:307
RECT rcClient
Definition: ntuser.h:681
LONG left
Definition: windef.h:306
BOOL WINAPI CallMsgFilterW(_In_ LPMSG, _In_ INT)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HWND WINAPI GetCapture(void)
Definition: message.c:2879
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
RECT rcWindow
Definition: ntuser.h:680
Definition: ntuser.h:657
#define MSGF_SCROLLBAR
Definition: winuser.h:1164
#define WM_LBUTTONUP
Definition: winuser.h:1759
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1757
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
struct @1587 Msg[]
static VOID FASTCALL IntScrollHandleScrollEvent(HWND Wnd, INT SBType, UINT Msg, POINT Pt)
Definition: scrollbar.c:744
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
#define LOWORD(l)
Definition: pedump.c:82
#define SCROLL_TIMER
Definition: scrollbar.c:45

Referenced by DefWndTrackScrollBar(), and ScrollBarWndProc_common().

◆ SetScrollInfo()

INT WINAPI DECLSPEC_HOTPATCH SetScrollInfo ( HWND  Wnd,
int  SBType,
LPCSCROLLINFO  Info,
BOOL  bRedraw 
)

Definition at line 1650 of file scrollbar.c.

1651 {
1652  BOOL Hook;
1653  INT Ret = 0;
1654 
1655  LoadUserApiHook();
1656 
1657  Hook = BeginIfHookedUserApiHook();
1658 
1659  /* Bypass SEH and go direct. */
1660  if (!Hook) return RealSetScrollInfo(Wnd, SBType, Info, bRedraw);
1661 
1662  _SEH2_TRY
1663  {
1664  Ret = guah.SetScrollInfo(Wnd, SBType, Info, bRedraw);
1665  }
1667  {
1668  ERR("Got exception in hooked SetScrollInfo!\n");
1669  }
1670  _SEH2_END;
1671 
1672  EndUserApiHook();
1673 
1674  return Ret;
1675 
1676 }
BOOL FASTCALL EndUserApiHook(VOID)
Definition: usrapihk.c:164
USERAPIHOOK guah
Definition: usrapihk.c:344
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
_SEH2_TRY
Definition: create.c:4250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
INT WINAPI RealSetScrollInfo(HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
Definition: scrollbar.c:1632
#define ERR(fmt,...)
Definition: debug.h:109
_SEH2_END
Definition: create.c:4424
static __inline void LoadUserApiHook()
Definition: user_x.h:85
BOOL FASTCALL BeginIfHookedUserApiHook(VOID)
Definition: usrapihk.c:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
SETSCROLLINFO SetScrollInfo
Definition: undocuser.h:335

Referenced by SetScrollRange().

◆ SetScrollPos()

INT WINAPI DECLSPEC_HOTPATCH SetScrollPos ( HWND  hWnd,
INT  nBar,
INT  nPos,
BOOL  bRedraw 
)

Definition at line 1684 of file scrollbar.c.

1685 {
1686  SCROLLINFO ScrollInfo;
1687 
1688  ScrollInfo.cbSize = sizeof(SCROLLINFO);
1689  ScrollInfo.fMask = SIF_POS|SIF_PREVIOUSPOS;
1690  ScrollInfo.nPos = nPos;
1691 
1692  return RealSetScrollInfo(hWnd, nBar, &ScrollInfo, bRedraw);
1693 }
HWND hWnd
Definition: settings.c:17
INT WINAPI RealSetScrollInfo(HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
Definition: scrollbar.c:1632
struct tagSCROLLINFO SCROLLINFO
#define SIF_POS
Definition: winuser.h:1220
#define SIF_PREVIOUSPOS
Definition: undocuser.h:87

◆ SetScrollRange()

BOOL WINAPI DECLSPEC_HOTPATCH SetScrollRange ( HWND  hWnd,
INT  nBar,
INT  nMinPos,
INT  nMaxPos,
BOOL  bRedraw 
)

Definition at line 1701 of file scrollbar.c.

1702 {
1703  PWND pWnd;
1704  SCROLLINFO ScrollInfo;
1705 
1706  pWnd = ValidateHwnd(hWnd);
1707  if ( !pWnd ) return FALSE;
1708 
1709  if (((LONGLONG)nMaxPos - nMinPos) > MAXLONG)
1710  {
1712  return FALSE;
1713  }
1714 
1715  ScrollInfo.cbSize = sizeof(SCROLLINFO);
1716  ScrollInfo.fMask = SIF_RANGE;
1717  ScrollInfo.nMin = nMinPos;
1718  ScrollInfo.nMax = nMaxPos;
1719  SetScrollInfo(hWnd, nBar, &ScrollInfo, bRedraw); // do not bypass themes.
1720  return TRUE;
1721 }
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
#define MAXLONG
Definition: umtypes.h:116
HWND hWnd
Definition: settings.c:17
#define ERROR_INVALID_SCROLLBAR_RANGE
Definition: winerror.h:929
INT WINAPI DECLSPEC_HOTPATCH SetScrollInfo(HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
Definition: scrollbar.c:1650
struct tagSCROLLINFO SCROLLINFO
int64_t LONGLONG
Definition: typedefs.h:66
#define SetLastError(x)
Definition: compat.h:417
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657

◆ SetSystemTimer()

UINT_PTR WINAPI SetSystemTimer ( HWND  ,
UINT_PTR  ,
UINT  ,
TIMERPROC   
)

Definition at line 106 of file ntwrapper.h.

107 {
108  return NtUserSetSystemTimer(hWnd, IDEvent, Period, TimerFunc);
109 }
HWND hWnd
Definition: settings.c:17
_In_ LARGE_INTEGER _In_ ULONG Period
Definition: kefuncs.h:1255
UINT_PTR NTAPI NtUserSetSystemTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
Definition: timer.c:680

Referenced by IntScrollHandleScrollEvent().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( scrollbar  )

Variable Documentation

◆ SCROLL_builtin_class

const struct builtin_class_descr SCROLL_builtin_class
Initial value:
=
{
L"ScrollBar",
sizeof(SBWND)-sizeof(WND),
0
}
#define CS_HREDRAW
Definition: winuser.h:648
struct _SBWND SBWND
LRESULT WINAPI ScrollBarWndProcW(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1427
#define CS_VREDRAW
Definition: winuser.h:653
static const WCHAR L[]
Definition: oid.c:1250
#define CS_DBLCLKS
Definition: winuser.h:646
Definition: ntuser.h:657
#define IDC_ARROW
Definition: winuser.h:682
LRESULT WINAPI ScrollBarWndProcA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: scrollbar.c:1433
#define CS_PARENTDC
Definition: winuser.h:651

Definition at line 76 of file scrollbar.c.

◆ ScrollMovingThumb

BOOL ScrollMovingThumb = FALSE
static

Definition at line 66 of file scrollbar.c.

Referenced by IntScrollDrawMovingThumb(), and IntScrollHandleScrollEvent().

◆ ScrollTrackHitTest

DWORD ScrollTrackHitTest = SCROLL_NOWHERE
static

Definition at line 62 of file scrollbar.c.

Referenced by IntScrollHandleScrollEvent().

◆ ScrollTrackingBar

INT ScrollTrackingBar = 0
static

Definition at line 58 of file scrollbar.c.

Referenced by IntScrollDrawMovingThumb(), and IntScrollHandleScrollEvent().

◆ ScrollTrackingPos

INT ScrollTrackingPos = 0
static

Definition at line 59 of file scrollbar.c.

Referenced by IntScrollDrawMovingThumb(), and IntScrollHandleScrollEvent().

◆ ScrollTrackingVal

INT ScrollTrackingVal = 0
static

Definition at line 60 of file scrollbar.c.

Referenced by IntScrollHandleScrollEvent().

◆ ScrollTrackingWin

HWND ScrollTrackingWin = 0
static

Definition at line 57 of file scrollbar.c.

Referenced by IntScrollDrawMovingThumb(), and IntScrollHandleScrollEvent().

◆ ScrollTrackVertical

BOOL ScrollTrackVertical
static

Definition at line 63 of file scrollbar.c.

Referenced by IntScrollHandleScrollEvent().