4 * Copyright 1993 Martin Ayotte
5 * Copyright 1994, 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "wine/winuser16.h"
30 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(scroll
);
38 INT curVal
; /* Current scroll-bar value */
39 INT minVal
; /* Minimum scroll-bar value */
40 INT maxVal
; /* Maximum scroll-bar value */
41 INT page
; /* Page size of scroll bar (Win32) */
42 UINT flags
; /* EnableScrollBar flags */
43 } SCROLLBAR_INFO
, *LPSCROLLBAR_INFO
;
46 static HBITMAP hUpArrow
;
47 static HBITMAP hDnArrow
;
48 static HBITMAP hLfArrow
;
49 static HBITMAP hRgArrow
;
50 static HBITMAP hUpArrowD
;
51 static HBITMAP hDnArrowD
;
52 static HBITMAP hLfArrowD
;
53 static HBITMAP hRgArrowD
;
54 static HBITMAP hUpArrowI
;
55 static HBITMAP hDnArrowI
;
56 static HBITMAP hLfArrowI
;
57 static HBITMAP hRgArrowI
;
59 #define TOP_ARROW(flags,pressed) \
60 (((flags)&ESB_DISABLE_UP) ? hUpArrowI : ((pressed) ? hUpArrowD:hUpArrow))
61 #define BOTTOM_ARROW(flags,pressed) \
62 (((flags)&ESB_DISABLE_DOWN) ? hDnArrowI : ((pressed) ? hDnArrowD:hDnArrow))
63 #define LEFT_ARROW(flags,pressed) \
64 (((flags)&ESB_DISABLE_LEFT) ? hLfArrowI : ((pressed) ? hLfArrowD:hLfArrow))
65 #define RIGHT_ARROW(flags,pressed) \
66 (((flags)&ESB_DISABLE_RIGHT) ? hRgArrowI : ((pressed) ? hRgArrowD:hRgArrow))
69 /* Minimum size of the rectangle between the arrows */
70 #define SCROLL_MIN_RECT 4
72 /* Minimum size of the thumb in pixels */
73 #define SCROLL_MIN_THUMB 6
75 /* Overlap between arrows and thumb */
76 #define SCROLL_ARROW_THUMB_OVERLAP 0
78 /* Delay (in ms) before first repetition when holding the button down */
79 #define SCROLL_FIRST_DELAY 200
81 /* Delay (in ms) between scroll repetitions */
82 #define SCROLL_REPEAT_DELAY 50
85 #define SCROLL_TIMER 0
87 /* Scroll-bar hit testing */
90 SCROLL_NOWHERE
, /* Outside the scroll bar */
91 SCROLL_TOP_ARROW
, /* Top or left arrow */
92 SCROLL_TOP_RECT
, /* Rectangle between the top arrow and the thumb */
93 SCROLL_THUMB
, /* Thumb rectangle */
94 SCROLL_BOTTOM_RECT
, /* Rectangle between the thumb and the bottom arrow */
95 SCROLL_BOTTOM_ARROW
/* Bottom or right arrow */
98 /* What to do after SCROLL_SetScrollInfo() */
99 #define SA_SSI_HIDE 0x0001
100 #define SA_SSI_SHOW 0x0002
101 #define SA_SSI_REFRESH 0x0004
102 #define SA_SSI_REPAINT_ARROWS 0x0008
104 /* Thumb-tracking info */
105 static HWND SCROLL_TrackingWin
= 0;
106 static INT SCROLL_TrackingBar
= 0;
107 static INT SCROLL_TrackingPos
= 0;
108 static INT SCROLL_TrackingVal
= 0;
109 /* Hit test code of the last button-down event */
110 static enum SCROLL_HITTEST SCROLL_trackHitTest
;
111 static BOOL SCROLL_trackVertical
;
113 /* Is the moving thumb being displayed? */
114 static BOOL SCROLL_MovingThumb
= FALSE
;
116 /* Local functions */
117 static BOOL
SCROLL_ShowScrollBar( HWND hwnd
, INT nBar
,
118 BOOL fShowH
, BOOL fShowV
);
119 static INT
SCROLL_SetScrollInfo( HWND hwnd
, INT nBar
,
120 const SCROLLINFO
*info
, INT
*action
);
121 static void SCROLL_DrawInterior_9x( HWND hwnd
, HDC hdc
, INT nBar
,
122 RECT
*rect
, INT arrowSize
,
123 INT thumbSize
, INT thumbPos
,
124 UINT flags
, BOOL vertical
,
125 BOOL top_selected
, BOOL bottom_selected
);
126 static LRESULT WINAPI
ScrollBarWndProc( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
129 /*********************************************************************
130 * scrollbar class descriptor
132 const struct builtin_class_descr SCROLL_builtin_class
=
134 "ScrollBar", /* name */
135 CS_DBLCLKS
| CS_VREDRAW
| CS_HREDRAW
| CS_PARENTDC
, /* style */
136 NULL
, /* procA (winproc is Unicode only) */
137 ScrollBarWndProc
, /* procW */
138 sizeof(SCROLLBAR_INFO
), /* extra */
139 IDC_ARROW
, /* cursor */
143 /***********************************************************************
144 * SCROLL_ScrollInfoValid
146 * Determine if the supplied SCROLLINFO struct is valid.
148 inline static BOOL
SCROLL_ScrollInfoValid(
149 LPSCROLLINFO info
/* [in] The SCROLLINFO struct to be tested */)
151 return !(info
->fMask
& ~(SIF_ALL
| SIF_DISABLENOSCROLL
)
152 || (info
->cbSize
!= sizeof(*info
)
153 && info
->cbSize
!= sizeof(*info
) - sizeof(info
->nTrackPos
)));
157 /***********************************************************************
160 static void SCROLL_LoadBitmaps(void)
162 hUpArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROW
) );
163 hDnArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROW
) );
164 hLfArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROW
) );
165 hRgArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROW
) );
166 hUpArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWD
) );
167 hDnArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWD
) );
168 hLfArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWD
) );
169 hRgArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWD
) );
170 hUpArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWI
) );
171 hDnArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWI
) );
172 hLfArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWI
) );
173 hRgArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWI
) );
177 /***********************************************************************
178 * SCROLL_GetScrollBarInfo
180 static SCROLLBAR_INFO
*SCROLL_GetScrollBarInfo( HWND hwnd
, INT nBar
)
182 SCROLLBAR_INFO
*infoPtr
;
183 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
185 if (!wndPtr
) return NULL
;
188 case SB_HORZ
: infoPtr
= (SCROLLBAR_INFO
*)wndPtr
->pHScroll
; break;
189 case SB_VERT
: infoPtr
= (SCROLLBAR_INFO
*)wndPtr
->pVScroll
; break;
190 case SB_CTL
: infoPtr
= (SCROLLBAR_INFO
*)wndPtr
->wExtra
; break;
192 WIN_ReleaseWndPtr( wndPtr
);
196 if (!infoPtr
) /* Create the info structure if needed */
198 if ((infoPtr
= HeapAlloc( GetProcessHeap(), 0, sizeof(SCROLLBAR_INFO
) )))
200 infoPtr
->minVal
= infoPtr
->curVal
= infoPtr
->page
= 0;
201 infoPtr
->maxVal
= 100;
202 infoPtr
->flags
= ESB_ENABLE_BOTH
;
203 if (nBar
== SB_HORZ
) wndPtr
->pHScroll
= infoPtr
;
204 else wndPtr
->pVScroll
= infoPtr
;
206 if (!hUpArrow
) SCROLL_LoadBitmaps();
208 WIN_ReleaseWndPtr( wndPtr
);
213 /***********************************************************************
214 * SCROLL_GetScrollBarRect
216 * Compute the scroll bar rectangle, in drawing coordinates (i.e. client
217 * coords for SB_CTL, window coords for SB_VERT and SB_HORZ).
218 * 'arrowSize' returns the width or height of an arrow (depending on
219 * the orientation of the scrollbar), 'thumbSize' returns the size of
220 * the thumb, and 'thumbPos' returns the position of the thumb
221 * relative to the left or to the top.
222 * Return TRUE if the scrollbar is vertical, FALSE if horizontal.
224 static BOOL
SCROLL_GetScrollBarRect( HWND hwnd
, INT nBar
, RECT
*lprect
,
225 INT
*arrowSize
, INT
*thumbSize
,
230 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
235 lprect
->left
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
236 lprect
->top
= wndPtr
->rectClient
.bottom
- wndPtr
->rectWindow
.top
;
237 lprect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectWindow
.left
;
238 lprect
->bottom
= lprect
->top
+ GetSystemMetrics(SM_CYHSCROLL
);
239 if(wndPtr
->dwStyle
& WS_BORDER
) {
242 } else if(wndPtr
->dwStyle
& WS_VSCROLL
)
248 if((wndPtr
->dwExStyle
& WS_EX_LEFTSCROLLBAR
) != 0)
249 lprect
->left
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
- GetSystemMetrics(SM_CXVSCROLL
);
251 lprect
->left
= wndPtr
->rectClient
.right
- wndPtr
->rectWindow
.left
;
252 lprect
->top
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
253 lprect
->right
= lprect
->left
+ GetSystemMetrics(SM_CXVSCROLL
);
254 lprect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectWindow
.top
;
255 if(wndPtr
->dwStyle
& WS_BORDER
) {
258 } else if(wndPtr
->dwStyle
& WS_HSCROLL
)
264 GetClientRect( hwnd
, lprect
);
265 vertical
= ((wndPtr
->dwStyle
& SBS_VERT
) != 0);
269 WIN_ReleaseWndPtr(wndPtr
);
273 if (vertical
) pixels
= lprect
->bottom
- lprect
->top
;
274 else pixels
= lprect
->right
- lprect
->left
;
276 if (pixels
<= 2*GetSystemMetrics(SM_CXVSCROLL
) + SCROLL_MIN_RECT
)
278 if (pixels
> SCROLL_MIN_RECT
)
279 *arrowSize
= (pixels
- SCROLL_MIN_RECT
) / 2;
282 *thumbPos
= *thumbSize
= 0;
286 SCROLLBAR_INFO
*info
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
288 *arrowSize
= GetSystemMetrics(SM_CXVSCROLL
);
289 pixels
-= (2 * (GetSystemMetrics(SM_CXVSCROLL
) - SCROLL_ARROW_THUMB_OVERLAP
));
293 *thumbSize
= MulDiv(pixels
,info
->page
,(info
->maxVal
-info
->minVal
+1));
294 if (*thumbSize
< SCROLL_MIN_THUMB
) *thumbSize
= SCROLL_MIN_THUMB
;
296 else *thumbSize
= GetSystemMetrics(SM_CXVSCROLL
);
298 if (((pixels
-= *thumbSize
) < 0) ||
299 ((info
->flags
& ESB_DISABLE_BOTH
) == ESB_DISABLE_BOTH
))
301 /* Rectangle too small or scrollbar disabled -> no thumb */
302 *thumbPos
= *thumbSize
= 0;
306 INT max
= info
->maxVal
- max( info
->page
-1, 0 );
307 if (info
->minVal
>= max
)
308 *thumbPos
= *arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
310 *thumbPos
= *arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
311 + MulDiv(pixels
, (info
->curVal
-info
->minVal
),(max
- info
->minVal
));
314 WIN_ReleaseWndPtr(wndPtr
);
319 /***********************************************************************
322 * Compute the current scroll position based on the thumb position in pixels
323 * from the top of the scroll-bar.
325 static UINT
SCROLL_GetThumbVal( SCROLLBAR_INFO
*infoPtr
, RECT
*rect
,
326 BOOL vertical
, INT pos
)
329 INT pixels
= vertical
? rect
->bottom
-rect
->top
: rect
->right
-rect
->left
;
331 if ((pixels
-= 2*(GetSystemMetrics(SM_CXVSCROLL
) - SCROLL_ARROW_THUMB_OVERLAP
)) <= 0)
332 return infoPtr
->minVal
;
336 thumbSize
= MulDiv(pixels
,infoPtr
->page
,(infoPtr
->maxVal
-infoPtr
->minVal
+1));
337 if (thumbSize
< SCROLL_MIN_THUMB
) thumbSize
= SCROLL_MIN_THUMB
;
339 else thumbSize
= GetSystemMetrics(SM_CXVSCROLL
);
341 if ((pixels
-= thumbSize
) <= 0) return infoPtr
->minVal
;
343 pos
= max( 0, pos
- (GetSystemMetrics(SM_CXVSCROLL
) - SCROLL_ARROW_THUMB_OVERLAP
) );
344 if (pos
> pixels
) pos
= pixels
;
346 if (!infoPtr
->page
) pos
*= infoPtr
->maxVal
- infoPtr
->minVal
;
347 else pos
*= infoPtr
->maxVal
- infoPtr
->minVal
- infoPtr
->page
+ 1;
348 return infoPtr
->minVal
+ ((pos
+ pixels
/ 2) / pixels
);
351 /***********************************************************************
354 static BOOL
SCROLL_PtInRectEx( LPRECT lpRect
, POINT pt
, BOOL vertical
)
360 rect
.left
-= lpRect
->right
- lpRect
->left
;
361 rect
.right
+= lpRect
->right
- lpRect
->left
;
365 rect
.top
-= lpRect
->bottom
- lpRect
->top
;
366 rect
.bottom
+= lpRect
->bottom
- lpRect
->top
;
368 return PtInRect( &rect
, pt
);
371 /***********************************************************************
374 static POINT
SCROLL_ClipPos( LPRECT lpRect
, POINT pt
)
376 if( pt
.x
< lpRect
->left
)
379 if( pt
.x
> lpRect
->right
)
380 pt
.x
= lpRect
->right
;
382 if( pt
.y
< lpRect
->top
)
385 if( pt
.y
> lpRect
->bottom
)
386 pt
.y
= lpRect
->bottom
;
392 /***********************************************************************
395 * Scroll-bar hit testing (don't confuse this with WM_NCHITTEST!).
397 static enum SCROLL_HITTEST
SCROLL_HitTest( HWND hwnd
, INT nBar
,
398 POINT pt
, BOOL bDragging
)
400 INT arrowSize
, thumbSize
, thumbPos
;
403 BOOL vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
404 &arrowSize
, &thumbSize
, &thumbPos
);
406 if ( (bDragging
&& !SCROLL_PtInRectEx( &rect
, pt
, vertical
)) ||
407 (!PtInRect( &rect
, pt
)) ) return SCROLL_NOWHERE
;
411 if (pt
.y
< rect
.top
+ arrowSize
) return SCROLL_TOP_ARROW
;
412 if (pt
.y
>= rect
.bottom
- arrowSize
) return SCROLL_BOTTOM_ARROW
;
413 if (!thumbPos
) return SCROLL_TOP_RECT
;
415 if (pt
.y
< thumbPos
) return SCROLL_TOP_RECT
;
416 if (pt
.y
>= thumbPos
+ thumbSize
) return SCROLL_BOTTOM_RECT
;
418 else /* horizontal */
420 if (pt
.x
< rect
.left
+ arrowSize
) return SCROLL_TOP_ARROW
;
421 if (pt
.x
>= rect
.right
- arrowSize
) return SCROLL_BOTTOM_ARROW
;
422 if (!thumbPos
) return SCROLL_TOP_RECT
;
424 if (pt
.x
< thumbPos
) return SCROLL_TOP_RECT
;
425 if (pt
.x
>= thumbPos
+ thumbSize
) return SCROLL_BOTTOM_RECT
;
431 /***********************************************************************
434 * Draw the scroll bar arrows.
436 static void SCROLL_DrawArrows( HDC hdc
, SCROLLBAR_INFO
*infoPtr
,
437 RECT
*rect
, INT arrowSize
, BOOL vertical
,
438 BOOL top_pressed
, BOOL bottom_pressed
)
444 r
.bottom
= r
.top
+ arrowSize
;
446 r
.right
= r
.left
+ arrowSize
;
448 DrawFrameControl( hdc
, &r
, DFC_SCROLL
,
449 (vertical
? DFCS_SCROLLUP
: DFCS_SCROLLLEFT
)
450 | (top_pressed
? (DFCS_PUSHED
| DFCS_FLAT
) : 0 )
451 | (infoPtr
->flags
&ESB_DISABLE_LTUP
? DFCS_INACTIVE
: 0 ) );
455 r
.top
= r
.bottom
-arrowSize
;
457 r
.left
= r
.right
-arrowSize
;
459 DrawFrameControl( hdc
, &r
, DFC_SCROLL
,
460 (vertical
? DFCS_SCROLLDOWN
: DFCS_SCROLLRIGHT
)
461 | (bottom_pressed
? (DFCS_PUSHED
| DFCS_FLAT
) : 0 )
462 | (infoPtr
->flags
&ESB_DISABLE_RTDN
? DFCS_INACTIVE
: 0) );
465 static void SCROLL_DrawMovingThumb( HDC hdc
, RECT
*rect
, BOOL vertical
,
466 INT arrowSize
, INT thumbSize
)
468 INT pos
= SCROLL_TrackingPos
;
472 max_size
= rect
->bottom
- rect
->top
;
474 max_size
= rect
->right
- rect
->left
;
476 max_size
-= (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
) + thumbSize
;
478 if( pos
< (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
) )
479 pos
= (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
);
480 else if( pos
> max_size
)
483 SCROLL_DrawInterior_9x( SCROLL_TrackingWin
, hdc
, SCROLL_TrackingBar
,
484 rect
, arrowSize
, thumbSize
, pos
,
485 0, vertical
, FALSE
, FALSE
);
487 SCROLL_MovingThumb
= !SCROLL_MovingThumb
;
490 /***********************************************************************
491 * SCROLL_DrawInterior
493 * Draw the scroll bar interior (everything except the arrows).
495 static void SCROLL_DrawInterior_9x( HWND hwnd
, HDC hdc
, INT nBar
,
496 RECT
*rect
, INT arrowSize
,
497 INT thumbSize
, INT thumbPos
,
498 UINT flags
, BOOL vertical
,
499 BOOL top_selected
, BOOL bottom_selected
)
503 HBRUSH hSaveBrush
,hBrush
;
505 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
506 * The window-owned scrollbars need to call DEFWND_ControlColor
507 * to correctly setup default scrollbar colors
511 hBrush
= (HBRUSH
)SendMessageA( GetParent(hwnd
), WM_CTLCOLORSCROLLBAR
,
512 (WPARAM
)hdc
,(LPARAM
)hwnd
);
516 hBrush
= DEFWND_ControlColor( hdc
, CTLCOLOR_SCROLLBAR
);
519 hSavePen
= SelectObject( hdc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
520 hSaveBrush
= SelectObject( hdc
, hBrush
);
522 /* Calculate the scroll rectangle */
526 r
.top
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
527 r
.bottom
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
531 r
.left
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
532 r
.right
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
535 /* Draw the scroll rectangles and thumb */
536 if (!thumbPos
) /* No thumb to draw */
538 PatBlt( hdc
, r
.left
, r
.top
,
539 r
.right
- r
.left
, r
.bottom
- r
.top
,
542 /* cleanup and return */
543 SelectObject( hdc
, hSavePen
);
544 SelectObject( hdc
, hSaveBrush
);
550 PatBlt( hdc
, r
.left
, r
.top
,
552 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
553 top_selected
? 0x0f0000 : PATCOPY
);
554 r
.top
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
555 PatBlt( hdc
, r
.left
, r
.top
+ thumbSize
,
557 r
.bottom
- r
.top
- thumbSize
,
558 bottom_selected
? 0x0f0000 : PATCOPY
);
559 r
.bottom
= r
.top
+ thumbSize
;
561 else /* horizontal */
563 PatBlt( hdc
, r
.left
, r
.top
,
564 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
566 top_selected
? 0x0f0000 : PATCOPY
);
567 r
.left
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
568 PatBlt( hdc
, r
.left
+ thumbSize
, r
.top
,
569 r
.right
- r
.left
- thumbSize
,
571 bottom_selected
? 0x0f0000 : PATCOPY
);
572 r
.right
= r
.left
+ thumbSize
;
576 DrawEdge( hdc
, &r
, EDGE_RAISED
, BF_RECT
| BF_MIDDLE
);
579 SelectObject( hdc
, hSavePen
);
580 SelectObject( hdc
, hSaveBrush
);
584 static void SCROLL_DrawInterior( HWND hwnd
, HDC hdc
, INT nBar
,
585 RECT
*rect
, INT arrowSize
,
586 INT thumbSize
, INT thumbPos
,
587 UINT flags
, BOOL vertical
,
588 BOOL top_selected
, BOOL bottom_selected
)
592 HBRUSH hSaveBrush
,hBrush
;
593 BOOL Save_SCROLL_MovingThumb
= SCROLL_MovingThumb
;
595 if (Save_SCROLL_MovingThumb
&&
596 (SCROLL_TrackingWin
== hwnd
) &&
597 (SCROLL_TrackingBar
== nBar
))
598 SCROLL_DrawMovingThumb( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
600 /* Select the correct brush and pen */
602 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
603 * The window-owned scrollbars need to call DEFWND_ControlColor
604 * to correctly setup default scrollbar colors
606 if (nBar
== SB_CTL
) {
607 hBrush
= (HBRUSH
)SendMessageA( GetParent(hwnd
), WM_CTLCOLORSCROLLBAR
,
608 (WPARAM
)hdc
,(LPARAM
)hwnd
);
610 hBrush
= DEFWND_ControlColor( hdc
, CTLCOLOR_SCROLLBAR
);
612 hSavePen
= SelectObject( hdc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
613 hSaveBrush
= SelectObject( hdc
, hBrush
);
615 /* Calculate the scroll rectangle */
620 r
.top
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
621 r
.bottom
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
625 r
.left
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
626 r
.right
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
629 /* Draw the scroll bar frame */
631 /* Draw the scroll rectangles and thumb */
633 if (!thumbPos
) /* No thumb to draw */
635 PatBlt( hdc
, r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
, PATCOPY
);
637 /* cleanup and return */
638 SelectObject( hdc
, hSavePen
);
639 SelectObject( hdc
, hSaveBrush
);
645 PatBlt( hdc
, r
.left
, r
.top
, r
.right
- r
.left
,
646 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
647 top_selected
? 0x0f0000 : PATCOPY
);
648 r
.top
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
649 PatBlt( hdc
, r
.left
, r
.top
+ thumbSize
, r
.right
- r
.left
,
650 r
.bottom
- r
.top
- thumbSize
,
651 bottom_selected
? 0x0f0000 : PATCOPY
);
652 r
.bottom
= r
.top
+ thumbSize
;
654 else /* horizontal */
656 PatBlt( hdc
, r
.left
, r
.top
,
657 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
658 r
.bottom
- r
.top
, top_selected
? 0x0f0000 : PATCOPY
);
659 r
.left
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
660 PatBlt( hdc
, r
.left
+ thumbSize
, r
.top
, r
.right
- r
.left
- thumbSize
,
661 r
.bottom
- r
.top
, bottom_selected
? 0x0f0000 : PATCOPY
);
662 r
.right
= r
.left
+ thumbSize
;
667 SelectObject( hdc
, GetSysColorBrush(COLOR_BTNFACE
) );
668 Rectangle( hdc
, r
.left
+1, r
.top
+1, r
.right
-1, r
.bottom
-1 );
669 DrawEdge( hdc
, &r
, EDGE_RAISED
, BF_RECT
);
671 if (Save_SCROLL_MovingThumb
&&
672 (SCROLL_TrackingWin
== hwnd
) &&
673 (SCROLL_TrackingBar
== nBar
))
674 SCROLL_DrawMovingThumb( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
677 SelectObject( hdc
, hSavePen
);
678 SelectObject( hdc
, hSaveBrush
);
682 /***********************************************************************
683 * SCROLL_DrawScrollBar
685 * Redraw the whole scrollbar.
687 void SCROLL_DrawScrollBar( HWND hwnd
, HDC hdc
, INT nBar
,
688 BOOL arrows
, BOOL interior
)
690 INT arrowSize
, thumbSize
, thumbPos
;
693 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
694 SCROLLBAR_INFO
*infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
695 BOOL Save_SCROLL_MovingThumb
= SCROLL_MovingThumb
;
697 if (!wndPtr
|| !infoPtr
||
698 ((nBar
== SB_VERT
) && !(wndPtr
->dwStyle
& WS_VSCROLL
)) ||
699 ((nBar
== SB_HORZ
) && !(wndPtr
->dwStyle
& WS_HSCROLL
))) goto END
;
700 if (!WIN_IsWindowDrawable( hwnd
, FALSE
)) goto END
;
701 hwnd
= wndPtr
->hwndSelf
; /* make it a full handle */
703 vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
704 &arrowSize
, &thumbSize
, &thumbPos
);
706 /* do not draw if the scrollbar rectangle is empty */
707 if(IsRectEmpty(&rect
))
710 if (Save_SCROLL_MovingThumb
&&
711 (SCROLL_TrackingWin
== hwnd
) &&
712 (SCROLL_TrackingBar
== nBar
))
713 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
715 /* Draw the arrows */
717 if (arrows
&& arrowSize
)
719 if( vertical
== SCROLL_trackVertical
&& GetCapture() == hwnd
)
720 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
721 (SCROLL_trackHitTest
== SCROLL_TOP_ARROW
),
722 (SCROLL_trackHitTest
== SCROLL_BOTTOM_ARROW
) );
724 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
728 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
729 thumbPos
, infoPtr
->flags
, vertical
, FALSE
, FALSE
);
731 if (Save_SCROLL_MovingThumb
&&
732 (SCROLL_TrackingWin
== hwnd
) &&
733 (SCROLL_TrackingBar
== nBar
))
734 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
736 /* if scroll bar has focus, reposition the caret */
737 if(hwnd
==GetFocus() && (nBar
==SB_CTL
))
741 SetCaretPos(thumbPos
+1, rect
.top
+1);
745 SetCaretPos(rect
.top
+1, thumbPos
+1);
750 WIN_ReleaseWndPtr(wndPtr
);
753 /***********************************************************************
754 * SCROLL_DrawSizeGrip
756 * Draw the size grip.
758 static void SCROLL_DrawSizeGrip( HWND hwnd
, HDC hdc
)
762 GetClientRect( hwnd
, &rc
);
763 FillRect( hdc
, &rc
, GetSysColorBrush(COLOR_SCROLLBAR
) );
764 rc
.left
= max( rc
.left
, rc
.right
- GetSystemMetrics(SM_CXVSCROLL
) - 1 );
765 rc
.top
= max( rc
.top
, rc
.bottom
- GetSystemMetrics(SM_CYHSCROLL
) - 1 );
766 DrawFrameControl( hdc
, &rc
, DFC_SCROLL
, DFCS_SCROLLSIZEGRIP
);
770 /***********************************************************************
771 * SCROLL_RefreshScrollBar
773 * Repaint the scroll bar interior after a SetScrollRange() or
774 * SetScrollPos() call.
776 static void SCROLL_RefreshScrollBar( HWND hwnd
, INT nBar
,
777 BOOL arrows
, BOOL interior
)
779 HDC hdc
= GetDCEx( hwnd
, 0,
780 DCX_CACHE
| ((nBar
== SB_CTL
) ? 0 : DCX_WINDOW
) );
783 SCROLL_DrawScrollBar( hwnd
, hdc
, nBar
, arrows
, interior
);
784 ReleaseDC( hwnd
, hdc
);
788 /***********************************************************************
789 * SCROLL_HandleKbdEvent
791 * Handle a keyboard event (only for SB_CTL scrollbars with focus).
793 static void SCROLL_HandleKbdEvent(
794 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
795 WPARAM wParam
/* [in] Variable input including enable state */,
796 LPARAM lParam
/* [in] Variable input including input point */)
798 TRACE("hwnd=%p wParam=%d lParam=%ld\n", hwnd
, wParam
, lParam
);
800 /* hide caret on first KEYDOWN to prevent flicker */
801 if ((lParam
& PFD_DOUBLEBUFFER_DONTCARE
) == 0)
806 case VK_PRIOR
: wParam
= SB_PAGEUP
; break;
807 case VK_NEXT
: wParam
= SB_PAGEDOWN
; break;
808 case VK_HOME
: wParam
= SB_TOP
; break;
809 case VK_END
: wParam
= SB_BOTTOM
; break;
810 case VK_UP
: wParam
= SB_LINEUP
; break;
811 case VK_DOWN
: wParam
= SB_LINEDOWN
; break;
814 SendMessageW(GetParent(hwnd
),
815 ((GetWindowLongA( hwnd
, GWL_STYLE
) & SBS_VERT
) ?
816 WM_VSCROLL
: WM_HSCROLL
), wParam
, (LPARAM
)hwnd
);
820 /***********************************************************************
821 * SCROLL_HandleScrollEvent
823 * Handle a mouse or timer event for the scrollbar.
824 * 'pt' is the location of the mouse event in client (for SB_CTL) or
825 * windows coordinates.
827 static void SCROLL_HandleScrollEvent( HWND hwnd
, INT nBar
, UINT msg
, POINT pt
)
829 /* Previous mouse position for timer events */
831 /* Thumb position when tracking started. */
832 static UINT trackThumbPos
;
833 /* Position in the scroll-bar of the last button-down event. */
834 static INT lastClickPos
;
835 /* Position in the scroll-bar of the last mouse event. */
836 static INT lastMousePos
;
838 enum SCROLL_HITTEST hittest
;
839 HWND hwndOwner
, hwndCtl
;
841 INT arrowSize
, thumbSize
, thumbPos
;
845 SCROLLBAR_INFO
*infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
846 if (!infoPtr
) return;
847 if ((SCROLL_trackHitTest
== SCROLL_NOWHERE
) && (msg
!= WM_LBUTTONDOWN
))
850 if (nBar
== SB_CTL
&& (GetWindowLongW( hwnd
, GWL_STYLE
) & (SBS_SIZEGRIP
| SBS_SIZEBOX
)))
854 case WM_LBUTTONDOWN
: /* Initialise mouse tracking */
855 HideCaret(hwnd
); /* hide caret while holding down LBUTTON */
858 SCROLL_trackHitTest
= hittest
= SCROLL_THUMB
;
861 GetClientRect(GetParent(GetParent(hwnd
)),&rect
);
866 SCROLL_trackHitTest
= hittest
= SCROLL_NOWHERE
;
867 if (hwnd
==GetFocus()) ShowCaret(hwnd
);
876 hdc
= GetDCEx( hwnd
, 0, DCX_CACHE
| ((nBar
== SB_CTL
) ? 0 : DCX_WINDOW
));
877 vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
878 &arrowSize
, &thumbSize
, &thumbPos
);
879 hwndOwner
= (nBar
== SB_CTL
) ? GetParent(hwnd
) : hwnd
;
880 hwndCtl
= (nBar
== SB_CTL
) ? hwnd
: 0;
884 case WM_LBUTTONDOWN
: /* Initialise mouse tracking */
885 HideCaret(hwnd
); /* hide caret while holding down LBUTTON */
886 SCROLL_trackVertical
= vertical
;
887 SCROLL_trackHitTest
= hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, FALSE
);
888 lastClickPos
= vertical
? (pt
.y
- rect
.top
) : (pt
.x
- rect
.left
);
889 lastMousePos
= lastClickPos
;
890 trackThumbPos
= thumbPos
;
892 if (nBar
== SB_CTL
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_TABSTOP
)) SetFocus( hwnd
);
897 hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, TRUE
);
902 hittest
= SCROLL_NOWHERE
;
904 /* if scrollbar has focus, show back caret */
905 if (hwnd
==GetFocus()) ShowCaret(hwnd
);
910 hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, FALSE
);
914 return; /* Should never happen */
917 TRACE("Event: hwnd=%p bar=%d msg=%s pt=%ld,%ld hit=%d\n",
918 hwnd
, nBar
, SPY_GetMsgName(msg
,hwnd
), pt
.x
, pt
.y
, hittest
);
920 switch(SCROLL_trackHitTest
)
922 case SCROLL_NOWHERE
: /* No tracking in progress */
925 case SCROLL_TOP_ARROW
:
926 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
927 (hittest
== SCROLL_trackHitTest
), FALSE
);
928 if (hittest
== SCROLL_trackHitTest
)
930 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
932 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
933 SB_LINEUP
, (LPARAM
)hwndCtl
);
936 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
937 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
940 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
943 case SCROLL_TOP_RECT
:
944 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
945 thumbPos
, infoPtr
->flags
, vertical
,
946 (hittest
== SCROLL_trackHitTest
), FALSE
);
947 if (hittest
== SCROLL_trackHitTest
)
949 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
951 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
952 SB_PAGEUP
, (LPARAM
)hwndCtl
);
954 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
955 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
958 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
962 if (msg
== WM_LBUTTONDOWN
)
964 SCROLL_TrackingWin
= hwnd
;
965 SCROLL_TrackingBar
= nBar
;
966 SCROLL_TrackingPos
= trackThumbPos
+ lastMousePos
- lastClickPos
;
967 SCROLL_TrackingVal
= SCROLL_GetThumbVal( infoPtr
, &rect
,
969 SCROLL_TrackingPos
);
970 if (!SCROLL_MovingThumb
)
971 SCROLL_DrawMovingThumb(hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
973 else if (msg
== WM_LBUTTONUP
)
975 if (SCROLL_MovingThumb
)
976 SCROLL_DrawMovingThumb(hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
977 SCROLL_TrackingWin
= 0;
978 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
979 thumbPos
, infoPtr
->flags
, vertical
,
982 else /* WM_MOUSEMOVE */
986 if (!SCROLL_PtInRectEx( &rect
, pt
, vertical
)) pos
= lastClickPos
;
989 pt
= SCROLL_ClipPos( &rect
, pt
);
990 pos
= vertical
? (pt
.y
- rect
.top
) : (pt
.x
- rect
.left
);
992 if ( (pos
!= lastMousePos
) || (!SCROLL_MovingThumb
) )
994 if (SCROLL_MovingThumb
)
995 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
,
996 arrowSize
, thumbSize
);
998 SCROLL_TrackingPos
= trackThumbPos
+ pos
- lastClickPos
;
999 SCROLL_TrackingVal
= SCROLL_GetThumbVal( infoPtr
, &rect
,
1001 SCROLL_TrackingPos
);
1002 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1003 MAKEWPARAM( SB_THUMBTRACK
, SCROLL_TrackingVal
),
1005 if (!SCROLL_MovingThumb
)
1006 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
,
1007 arrowSize
, thumbSize
);
1012 case SCROLL_BOTTOM_RECT
:
1013 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1014 thumbPos
, infoPtr
->flags
, vertical
,
1015 FALSE
, (hittest
== SCROLL_trackHitTest
) );
1016 if (hittest
== SCROLL_trackHitTest
)
1018 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1020 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1021 SB_PAGEDOWN
, (LPARAM
)hwndCtl
);
1023 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1024 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1027 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1030 case SCROLL_BOTTOM_ARROW
:
1031 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
1032 FALSE
, (hittest
== SCROLL_trackHitTest
) );
1033 if (hittest
== SCROLL_trackHitTest
)
1035 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1037 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1038 SB_LINEDOWN
, (LPARAM
)hwndCtl
);
1041 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1042 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1045 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1049 if (msg
== WM_LBUTTONDOWN
)
1052 if (hittest
== SCROLL_THUMB
)
1054 UINT val
= SCROLL_GetThumbVal( infoPtr
, &rect
, vertical
,
1055 trackThumbPos
+ lastMousePos
- lastClickPos
);
1056 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1057 MAKEWPARAM( SB_THUMBTRACK
, val
), (LPARAM
)hwndCtl
);
1061 if (msg
== WM_LBUTTONUP
)
1063 hittest
= SCROLL_trackHitTest
;
1064 SCROLL_trackHitTest
= SCROLL_NOWHERE
; /* Terminate tracking */
1066 if (hittest
== SCROLL_THUMB
)
1068 UINT val
= SCROLL_GetThumbVal( infoPtr
, &rect
, vertical
,
1069 trackThumbPos
+ lastMousePos
- lastClickPos
);
1070 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1071 MAKEWPARAM( SB_THUMBPOSITION
, val
), (LPARAM
)hwndCtl
);
1073 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1074 SB_ENDSCROLL
, (LPARAM
)hwndCtl
);
1077 ReleaseDC( hwnd
, hdc
);
1081 /***********************************************************************
1082 * SCROLL_TrackScrollBar
1084 * Track a mouse button press on a scroll-bar.
1085 * pt is in screen-coordinates for non-client scroll bars.
1087 void SCROLL_TrackScrollBar( HWND hwnd
, INT scrollbar
, POINT pt
)
1090 INT xoffset
= 0, yoffset
= 0;
1092 if (scrollbar
!= SB_CTL
)
1094 WND
*wndPtr
= WIN_GetPtr( hwnd
);
1095 if (!wndPtr
|| wndPtr
== WND_OTHER_PROCESS
) return;
1096 xoffset
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
1097 yoffset
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
1098 WIN_ReleasePtr( wndPtr
);
1099 ScreenToClient( hwnd
, &pt
);
1104 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1108 if (!GetMessageW( &msg
, 0, 0, 0 )) break;
1109 if (CallMsgFilterW( &msg
, MSGF_SCROLLBAR
)) continue;
1115 pt
.x
= (short)LOWORD(msg
.lParam
) + xoffset
;
1116 pt
.y
= (short)HIWORD(msg
.lParam
) + yoffset
;
1117 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
.message
, pt
);
1120 TranslateMessage( &msg
);
1121 DispatchMessageW( &msg
);
1124 if (!IsWindow( hwnd
))
1129 } while (msg
.message
!= WM_LBUTTONUP
);
1133 /***********************************************************************
1134 * SCROLL_CreateScrollBar
1136 * Create a scroll bar
1138 static void SCROLL_CreateScrollBar(
1139 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1140 LPCREATESTRUCTW lpCreate
/* [in] The style and place of the scroll bar */)
1142 LPSCROLLBAR_INFO info
= SCROLL_GetScrollBarInfo(hwnd
, SB_CTL
);
1145 TRACE("hwnd=%p lpCreate=%p\n", hwnd
, lpCreate
);
1147 if (lpCreate
->style
& WS_DISABLED
)
1149 info
->flags
= ESB_DISABLE_BOTH
;
1150 TRACE("Created WS_DISABLED scrollbar\n");
1154 if (lpCreate
->style
& (SBS_SIZEGRIP
| SBS_SIZEBOX
))
1156 if (lpCreate
->style
& SBS_SIZEBOXTOPLEFTALIGN
)
1157 MoveWindow( hwnd
, lpCreate
->x
, lpCreate
->y
, GetSystemMetrics(SM_CXVSCROLL
)+1,
1158 GetSystemMetrics(SM_CYHSCROLL
)+1, FALSE
);
1159 else if(lpCreate
->style
& SBS_SIZEBOXBOTTOMRIGHTALIGN
)
1160 MoveWindow( hwnd
, lpCreate
->x
+lpCreate
->cx
-GetSystemMetrics(SM_CXVSCROLL
)-1,
1161 lpCreate
->y
+lpCreate
->cy
-GetSystemMetrics(SM_CYHSCROLL
)-1,
1162 GetSystemMetrics(SM_CXVSCROLL
)+1,
1163 GetSystemMetrics(SM_CYHSCROLL
)+1, FALSE
);
1165 else if (lpCreate
->style
& SBS_VERT
)
1167 if (lpCreate
->style
& SBS_LEFTALIGN
)
1168 MoveWindow( hwnd
, lpCreate
->x
, lpCreate
->y
,
1169 GetSystemMetrics(SM_CXVSCROLL
)+1, lpCreate
->cy
, FALSE
);
1170 else if (lpCreate
->style
& SBS_RIGHTALIGN
)
1172 lpCreate
->x
+lpCreate
->cx
-GetSystemMetrics(SM_CXVSCROLL
)-1,
1174 GetSystemMetrics(SM_CXVSCROLL
)+1, lpCreate
->cy
, FALSE
);
1178 if (lpCreate
->style
& SBS_TOPALIGN
)
1179 MoveWindow( hwnd
, lpCreate
->x
, lpCreate
->y
,
1180 lpCreate
->cx
, GetSystemMetrics(SM_CYHSCROLL
)+1, FALSE
);
1181 else if (lpCreate
->style
& SBS_BOTTOMALIGN
)
1184 lpCreate
->y
+lpCreate
->cy
-GetSystemMetrics(SM_CYHSCROLL
)-1,
1185 lpCreate
->cx
, GetSystemMetrics(SM_CYHSCROLL
)+1, FALSE
);
1190 /*************************************************************************
1191 * SCROLL_GetScrollInfo
1193 * Internal helper for the API function
1195 static BOOL
SCROLL_GetScrollInfo(
1196 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1197 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1198 LPSCROLLINFO info
/* [in/out] (fMask specifies which values to retrieve) */)
1200 LPSCROLLBAR_INFO infoPtr
;
1202 /* handle invalid data structure */
1203 if (!SCROLL_ScrollInfoValid(info
)
1204 || !(infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
)))
1207 /* fill in the desired scroll info structure */
1208 if (info
->fMask
& SIF_PAGE
) info
->nPage
= infoPtr
->page
;
1209 if (info
->fMask
& SIF_POS
) info
->nPos
= infoPtr
->curVal
;
1210 if ((info
->fMask
& SIF_TRACKPOS
) && (info
->cbSize
== sizeof(*info
)))
1211 info
->nTrackPos
= (SCROLL_TrackingWin
== WIN_GetFullHandle(hwnd
)) ? SCROLL_TrackingVal
: infoPtr
->curVal
;
1212 if (info
->fMask
& SIF_RANGE
)
1214 info
->nMin
= infoPtr
->minVal
;
1215 info
->nMax
= infoPtr
->maxVal
;
1218 return (info
->fMask
& SIF_ALL
) != 0;
1222 /*************************************************************************
1223 * SCROLL_GetScrollPos
1225 * Internal helper for the API function
1227 static INT
SCROLL_GetScrollPos(
1228 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1229 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1231 LPSCROLLBAR_INFO infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
);
1232 return infoPtr
? infoPtr
->curVal
: 0;
1236 /*************************************************************************
1237 * SCROLL_GetScrollRange
1239 * Internal helper for the API function
1243 static BOOL
SCROLL_GetScrollRange(
1244 HWND hwnd
, /* [in] Handle of window */
1245 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1246 LPINT lpMin
, /* [out] Where to store minimum value */
1247 LPINT lpMax
/* [out] Where to store maximum value */)
1249 LPSCROLLBAR_INFO infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
);
1251 if (lpMin
) *lpMin
= infoPtr
? infoPtr
->minVal
: 0;
1252 if (lpMax
) *lpMax
= infoPtr
? infoPtr
->maxVal
: 0;
1254 return infoPtr
? TRUE
: FALSE
;
1259 /***********************************************************************
1262 static LRESULT WINAPI
ScrollBarWndProc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1264 if (!IsWindow( hwnd
)) return 0;
1269 SCROLL_CreateScrollBar(hwnd
, (LPCREATESTRUCTW
)lParam
);
1270 if (!hUpArrow
) SCROLL_LoadBitmaps();
1275 SCROLLBAR_INFO
*infoPtr
;
1276 if ((infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, SB_CTL
)))
1278 infoPtr
->flags
= wParam
? ESB_ENABLE_BOTH
: ESB_DISABLE_BOTH
;
1279 SCROLL_RefreshScrollBar(hwnd
, SB_CTL
, TRUE
, TRUE
);
1284 case WM_LBUTTONDBLCLK
:
1285 case WM_LBUTTONDOWN
:
1288 pt
.x
= (short)LOWORD(lParam
);
1289 pt
.y
= (short)HIWORD(lParam
);
1290 SCROLL_TrackScrollBar( hwnd
, SB_CTL
, pt
);
1298 pt
.x
= (short)LOWORD(lParam
);
1299 pt
.y
= (short)HIWORD(lParam
);
1300 SCROLL_HandleScrollEvent( hwnd
, SB_CTL
, message
, pt
);
1305 SCROLL_HandleKbdEvent(hwnd
, wParam
, lParam
);
1314 /* Create a caret when a ScrollBar get focus */
1316 int arrowSize
, thumbSize
, thumbPos
, vertical
;
1317 vertical
= SCROLL_GetScrollBarRect( hwnd
, SB_CTL
, &rect
,
1318 &arrowSize
, &thumbSize
, &thumbPos
);
1321 CreateCaret(hwnd
, (HBITMAP
)1, thumbSize
-2, rect
.bottom
-rect
.top
-2);
1322 SetCaretPos(thumbPos
+1, rect
.top
+1);
1326 CreateCaret(hwnd
, (HBITMAP
)1, rect
.right
-rect
.left
-2,thumbSize
-2);
1327 SetCaretPos(rect
.top
+1, thumbPos
+1);
1336 int arrowSize
, thumbSize
, thumbPos
, vertical
;
1337 vertical
= SCROLL_GetScrollBarRect( hwnd
, SB_CTL
, &rect
,&arrowSize
, &thumbSize
, &thumbPos
);
1339 rect
.left
=thumbPos
+1;
1340 rect
.right
=rect
.left
+thumbSize
;
1344 rect
.top
=thumbPos
+1;
1345 rect
.bottom
=rect
.top
+thumbSize
;
1348 InvalidateRect(hwnd
,&rect
,0);
1357 return DLGC_WANTARROWS
; /* Windows returns this value */
1362 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
1363 if (GetWindowLongW( hwnd
, GWL_STYLE
) & SBS_SIZEGRIP
)
1365 SCROLL_DrawSizeGrip( hwnd
, hdc
);
1367 else if (GetWindowLongW( hwnd
, GWL_STYLE
) & SBS_SIZEBOX
)
1370 GetClientRect( hwnd
, &rc
);
1371 FillRect( hdc
, &rc
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1374 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_CTL
, TRUE
, TRUE
);
1375 if (!wParam
) EndPaint(hwnd
, &ps
);
1381 return SetScrollPos( hwnd
, SB_CTL
, wParam
, (BOOL
)lParam
);
1385 return SCROLL_GetScrollPos(hwnd
, SB_CTL
);
1387 case SBM_SETRANGE16
:
1388 SetScrollRange( hwnd
, SB_CTL
, LOWORD(lParam
), HIWORD(lParam
),
1389 wParam
/* FIXME: Is this correct? */ );
1394 INT oldPos
= SCROLL_GetScrollPos( hwnd
, SB_CTL
);
1395 SetScrollRange( hwnd
, SB_CTL
, wParam
, lParam
, FALSE
);
1396 if (oldPos
!= SCROLL_GetScrollPos( hwnd
, SB_CTL
)) return oldPos
;
1400 case SBM_GETRANGE16
:
1401 FIXME("don't know how to handle SBM_GETRANGE16 (wp=%04x,lp=%08lx)\n", wParam
, lParam
);
1405 return SCROLL_GetScrollRange(hwnd
, SB_CTL
, (LPINT
)wParam
, (LPINT
)lParam
);
1407 case SBM_ENABLE_ARROWS16
:
1408 case SBM_ENABLE_ARROWS
:
1409 return EnableScrollBar( hwnd
, SB_CTL
, wParam
);
1411 case SBM_SETRANGEREDRAW
:
1413 INT oldPos
= SCROLL_GetScrollPos( hwnd
, SB_CTL
);
1414 SetScrollRange( hwnd
, SB_CTL
, wParam
, lParam
, TRUE
);
1415 if (oldPos
!= SCROLL_GetScrollPos( hwnd
, SB_CTL
)) return oldPos
;
1419 case SBM_SETSCROLLINFO
:
1420 return SetScrollInfo( hwnd
, SB_CTL
, (SCROLLINFO
*)lParam
, wParam
);
1422 case SBM_GETSCROLLINFO
:
1423 return SCROLL_GetScrollInfo(hwnd
, SB_CTL
, (SCROLLINFO
*)lParam
);
1433 ERR("unknown Win32 msg %04x wp=%08x lp=%08lx\n",
1434 message
, wParam
, lParam
);
1438 if (message
>= WM_USER
)
1439 WARN("unknown msg %04x wp=%04x lp=%08lx\n",
1440 message
, wParam
, lParam
);
1441 return DefWindowProcW( hwnd
, message
, wParam
, lParam
);
1447 /*************************************************************************
1448 * SetScrollInfo (USER32.@)
1449 * SetScrollInfo can be used to set the position, upper bound,
1450 * lower bound, and page size of a scrollbar control.
1453 * Scrollbar position
1456 * For 100 lines of text to be displayed in a window of 25 lines,
1457 * one would for instance use info->nMin=0, info->nMax=75
1458 * (corresponding to the 76 different positions of the window on
1459 * the text), and info->nPage=25.
1461 INT WINAPI
SetScrollInfo(
1462 HWND hwnd
/* [in] Handle of window whose scrollbar will be affected */,
1463 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1464 const SCROLLINFO
*info
/* [in] Specifies what to change and new values */,
1465 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */)
1468 INT retVal
= SCROLL_SetScrollInfo( hwnd
, nBar
, info
, &action
);
1470 if( action
& SA_SSI_HIDE
)
1471 SCROLL_ShowScrollBar( hwnd
, nBar
, FALSE
, FALSE
);
1474 if( action
& SA_SSI_SHOW
)
1475 if( SCROLL_ShowScrollBar( hwnd
, nBar
, TRUE
, TRUE
) )
1476 return retVal
; /* SetWindowPos() already did the painting */
1479 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, TRUE
);
1480 else if( action
& SA_SSI_REPAINT_ARROWS
)
1481 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, FALSE
);
1486 INT
SCROLL_SetScrollInfo( HWND hwnd
, INT nBar
,
1487 const SCROLLINFO
*info
, INT
*action
)
1489 /* Update the scrollbar state and set action flags according to
1490 * what has to be done graphics wise. */
1492 SCROLLBAR_INFO
*infoPtr
;
1494 BOOL bChangeParams
= FALSE
; /* don't show/hide scrollbar if params don't change */
1498 if (!(infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
))) return 0;
1499 if (info
->fMask
& ~(SIF_ALL
| SIF_DISABLENOSCROLL
)) return 0;
1500 if ((info
->cbSize
!= sizeof(*info
)) &&
1501 (info
->cbSize
!= sizeof(*info
)-sizeof(info
->nTrackPos
))) return 0;
1503 if (TRACE_ON(scroll
))
1505 TRACE("hwnd=%p bar=%d", hwnd
, nBar
);
1506 if (info
->fMask
& SIF_PAGE
) TRACE( " page=%d", info
->nPage
);
1507 if (info
->fMask
& SIF_POS
) TRACE( " pos=%d", info
->nPos
);
1508 if (info
->fMask
& SIF_RANGE
) TRACE( " min=%d max=%d", info
->nMin
, info
->nMax
);
1512 /* Set the page size */
1514 if (info
->fMask
& SIF_PAGE
)
1516 if( infoPtr
->page
!= info
->nPage
)
1518 infoPtr
->page
= info
->nPage
;
1519 *action
|= SA_SSI_REFRESH
;
1520 bChangeParams
= TRUE
;
1524 /* Set the scroll pos */
1526 if (info
->fMask
& SIF_POS
)
1528 if( infoPtr
->curVal
!= info
->nPos
)
1530 infoPtr
->curVal
= info
->nPos
;
1531 *action
|= SA_SSI_REFRESH
;
1535 /* Set the scroll range */
1537 if (info
->fMask
& SIF_RANGE
)
1539 /* Invalid range -> range is set to (0,0) */
1540 if ((info
->nMin
> info
->nMax
) ||
1541 ((UINT
)(info
->nMax
- info
->nMin
) >= 0x80000000))
1543 infoPtr
->minVal
= 0;
1544 infoPtr
->maxVal
= 0;
1545 bChangeParams
= TRUE
;
1549 if( infoPtr
->minVal
!= info
->nMin
||
1550 infoPtr
->maxVal
!= info
->nMax
)
1552 *action
|= SA_SSI_REFRESH
;
1553 infoPtr
->minVal
= info
->nMin
;
1554 infoPtr
->maxVal
= info
->nMax
;
1555 bChangeParams
= TRUE
;
1560 /* Make sure the page size is valid */
1562 if (infoPtr
->page
< 0) infoPtr
->page
= 0;
1563 else if (infoPtr
->page
> infoPtr
->maxVal
- infoPtr
->minVal
+ 1 )
1564 infoPtr
->page
= infoPtr
->maxVal
- infoPtr
->minVal
+ 1;
1566 /* Make sure the pos is inside the range */
1568 if (infoPtr
->curVal
< infoPtr
->minVal
)
1569 infoPtr
->curVal
= infoPtr
->minVal
;
1570 else if (infoPtr
->curVal
> infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 ))
1571 infoPtr
->curVal
= infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 );
1573 TRACE(" new values: page=%d pos=%d min=%d max=%d\n",
1574 infoPtr
->page
, infoPtr
->curVal
,
1575 infoPtr
->minVal
, infoPtr
->maxVal
);
1577 /* don't change the scrollbar state if SetScrollInfo
1578 * is just called with SIF_DISABLENOSCROLL
1580 if(!(info
->fMask
& SIF_ALL
)) goto done
;
1582 /* Check if the scrollbar should be hidden or disabled */
1584 if (info
->fMask
& (SIF_RANGE
| SIF_PAGE
| SIF_DISABLENOSCROLL
))
1586 new_flags
= infoPtr
->flags
;
1587 if (infoPtr
->minVal
>= infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 ))
1589 /* Hide or disable scroll-bar */
1590 if (info
->fMask
& SIF_DISABLENOSCROLL
)
1592 new_flags
= ESB_DISABLE_BOTH
;
1593 *action
|= SA_SSI_REFRESH
;
1595 else if ((nBar
!= SB_CTL
) && bChangeParams
)
1597 *action
= SA_SSI_HIDE
;
1601 else /* Show and enable scroll-bar */
1604 if ((nBar
!= SB_CTL
) && bChangeParams
)
1605 *action
|= SA_SSI_SHOW
;
1608 if (infoPtr
->flags
!= new_flags
) /* check arrow flags */
1610 infoPtr
->flags
= new_flags
;
1611 *action
|= SA_SSI_REPAINT_ARROWS
;
1616 /* Return current position */
1618 return infoPtr
->curVal
;
1622 /*************************************************************************
1623 * GetScrollInfo (USER32.@)
1625 * GetScrollInfo can be used to retrieve the position, upper bound,
1626 * lower bound, and page size of a scrollbar control.
1630 BOOL WINAPI
GetScrollInfo(
1631 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1632 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1633 LPSCROLLINFO info
/* [in/out] (fMask specifies which values to retrieve) */)
1635 TRACE("hwnd=%p nBar=%d info=%p\n", hwnd
, nBar
, info
);
1637 /* Refer SB_CTL requests to the window */
1639 return SendMessageA(hwnd
, SBM_GETSCROLLINFO
, (WPARAM
)0, (LPARAM
)info
);
1641 return SCROLL_GetScrollInfo(hwnd
, nBar
, info
);
1645 /*************************************************************************
1646 * SetScrollPos (USER32.@)
1649 * Success: Scrollbar position
1653 * Note the ambiguity when 0 is returned. Use GetLastError
1654 * to make sure there was an error (and to know which one).
1656 INT WINAPI
SetScrollPos(
1657 HWND hwnd
/* [in] Handle of window whose scrollbar will be affected */,
1658 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1659 INT nPos
/* [in] New value */,
1660 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */ )
1663 SCROLLBAR_INFO
*infoPtr
;
1666 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
))) return 0;
1667 oldPos
= infoPtr
->curVal
;
1668 info
.cbSize
= sizeof(info
);
1670 info
.fMask
= SIF_POS
;
1671 SetScrollInfo( hwnd
, nBar
, &info
, bRedraw
);
1676 /*************************************************************************
1677 * GetScrollPos (USER32.@)
1680 * Success: Current position
1684 * There is ambiguity when 0 is returned. Use GetLastError
1685 * to make sure there was an error (and to know which one).
1687 INT WINAPI
GetScrollPos(
1688 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1689 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1691 TRACE("hwnd=%p nBar=%d\n", hwnd
, nBar
);
1693 /* Refer SB_CTL requests to the window */
1695 return SendMessageA(hwnd
, SBM_GETPOS
, (WPARAM
)0, (LPARAM
)0);
1697 return SCROLL_GetScrollPos(hwnd
, nBar
);
1701 /*************************************************************************
1702 * SetScrollRange (USER32.@)
1706 BOOL WINAPI
SetScrollRange(
1707 HWND hwnd
, /* [in] Handle of window whose scrollbar will be affected */
1708 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1709 INT minVal
, /* [in] New minimum value */
1710 INT maxVal
, /* [in] New maximum value */
1711 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */)
1715 info
.cbSize
= sizeof(info
);
1718 info
.fMask
= SIF_RANGE
;
1719 SetScrollInfo( hwnd
, nBar
, &info
, bRedraw
);
1724 /*************************************************************************
1725 * SCROLL_SetNCSbState
1727 * Updates both scrollbars at the same time. Used by MDI CalcChildScroll().
1729 INT
SCROLL_SetNCSbState(HWND hwnd
, int vMin
, int vMax
, int vPos
,
1730 int hMin
, int hMax
, int hPos
)
1733 SCROLLINFO vInfo
, hInfo
;
1735 vInfo
.cbSize
= hInfo
.cbSize
= sizeof(SCROLLINFO
);
1742 vInfo
.fMask
= hInfo
.fMask
= SIF_RANGE
| SIF_POS
;
1744 SCROLL_SetScrollInfo( hwnd
, SB_VERT
, &vInfo
, &vA
);
1745 SCROLL_SetScrollInfo( hwnd
, SB_HORZ
, &hInfo
, &hA
);
1747 if( !SCROLL_ShowScrollBar( hwnd
, SB_BOTH
,
1748 (hA
& SA_SSI_SHOW
),(vA
& SA_SSI_SHOW
) ) )
1750 /* SetWindowPos() wasn't called, just redraw the scrollbars if needed */
1751 if( vA
& SA_SSI_REFRESH
)
1752 SCROLL_RefreshScrollBar( hwnd
, SB_VERT
, FALSE
, TRUE
);
1754 if( hA
& SA_SSI_REFRESH
)
1755 SCROLL_RefreshScrollBar( hwnd
, SB_HORZ
, FALSE
, TRUE
);
1761 /*************************************************************************
1762 * GetScrollRange (USER32.@)
1766 BOOL WINAPI
GetScrollRange(
1767 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1768 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1769 LPINT lpMin
/* [out] Where to store minimum value */,
1770 LPINT lpMax
/* [out] Where to store maximum value */)
1772 TRACE("hwnd=%p nBar=%d lpMin=%p lpMax=%p\n", hwnd
, nBar
, lpMin
, lpMax
);
1774 /* Refer SB_CTL requests to the window */
1776 return SendMessageA(hwnd
, SBM_GETRANGE
, (WPARAM
)lpMin
, (LPARAM
)lpMax
);
1778 return SCROLL_GetScrollRange(hwnd
, nBar
, lpMin
, lpMax
);
1782 /*************************************************************************
1783 * SCROLL_ShowScrollBar()
1785 * Back-end for ShowScrollBar(). Returns FALSE if no action was taken.
1787 BOOL
SCROLL_ShowScrollBar( HWND hwnd
, INT nBar
,
1788 BOOL fShowH
, BOOL fShowV
)
1790 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1792 TRACE("hwnd=%p bar=%d horz=%d, vert=%d\n", hwnd
, nBar
, fShowH
, fShowV
);
1797 ShowWindow( hwnd
, fShowH
? SW_SHOW
: SW_HIDE
);
1804 fShowH
= !(style
& WS_HSCROLL
);
1805 style
|= WS_HSCROLL
;
1809 fShowH
= (style
& WS_HSCROLL
);
1810 style
&= ~WS_HSCROLL
;
1812 if( nBar
== SB_HORZ
) {
1821 fShowV
= !(style
& WS_VSCROLL
);
1822 style
|= WS_VSCROLL
;
1826 fShowV
= (style
& WS_VSCROLL
);
1827 style
&= ~WS_VSCROLL
;
1829 if ( nBar
== SB_VERT
)
1834 return FALSE
; /* Nothing to do! */
1837 if( fShowH
|| fShowV
) /* frame has been changed, let the window redraw itself */
1839 WIN_SetStyle( hwnd
, style
);
1840 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
1841 | SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
1844 return FALSE
; /* no frame changes */
1848 /*************************************************************************
1849 * ShowScrollBar (USER32.@)
1853 BOOL WINAPI
ShowScrollBar(
1854 HWND hwnd
, /* [in] Handle of window whose scrollbar(s) will be affected */
1855 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */
1856 BOOL fShow
/* [in] TRUE = show, FALSE = hide */)
1858 SCROLL_ShowScrollBar( hwnd
, nBar
, (nBar
== SB_VERT
) ? 0 : fShow
,
1859 (nBar
== SB_HORZ
) ? 0 : fShow
);
1864 /*************************************************************************
1865 * EnableScrollBar (USER32.@)
1867 BOOL WINAPI
EnableScrollBar( HWND hwnd
, INT nBar
, UINT flags
)
1870 SCROLLBAR_INFO
*infoPtr
;
1872 TRACE("%p %d %d\n", hwnd
, nBar
, flags
);
1874 flags
&= ESB_DISABLE_BOTH
;
1876 if (nBar
== SB_BOTH
)
1878 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, SB_VERT
))) return FALSE
;
1879 if (!(bFineWithMe
= (infoPtr
->flags
== flags
)) )
1881 infoPtr
->flags
= flags
;
1882 SCROLL_RefreshScrollBar( hwnd
, SB_VERT
, TRUE
, TRUE
);
1889 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
))) return FALSE
;
1890 if (bFineWithMe
&& infoPtr
->flags
== flags
) return FALSE
;
1891 infoPtr
->flags
= flags
;
1893 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, TRUE
);