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 ((TWEAK_WineLook == WIN31_LOOK) ? 1 : 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_GLOBALCLASS
| 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_9x( 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_DrawArrows_31( HDC hdc
, SCROLLBAR_INFO
*infoPtr
,
466 RECT
*rect
, INT arrowSize
, BOOL vertical
,
467 BOOL top_pressed
, BOOL bottom_pressed
)
469 HDC hdcMem
= CreateCompatibleDC( hdc
);
470 HBITMAP hbmpPrev
= SelectObject( hdcMem
, vertical
?
471 TOP_ARROW(infoPtr
->flags
, top_pressed
)
472 : LEFT_ARROW(infoPtr
->flags
, top_pressed
));
474 SetStretchBltMode( hdc
, STRETCH_DELETESCANS
);
475 StretchBlt( hdc
, rect
->left
, rect
->top
,
476 vertical
? rect
->right
-rect
->left
: arrowSize
,
477 vertical
? arrowSize
: rect
->bottom
-rect
->top
,
479 GetSystemMetrics(SM_CXVSCROLL
),GetSystemMetrics(SM_CYHSCROLL
),
482 SelectObject( hdcMem
, vertical
?
483 BOTTOM_ARROW( infoPtr
->flags
, bottom_pressed
)
484 : RIGHT_ARROW( infoPtr
->flags
, bottom_pressed
) );
486 StretchBlt( hdc
, rect
->left
, rect
->bottom
- arrowSize
,
487 rect
->right
- rect
->left
, arrowSize
,
489 GetSystemMetrics(SM_CXVSCROLL
),GetSystemMetrics(SM_CYHSCROLL
),
492 StretchBlt( hdc
, rect
->right
- arrowSize
, rect
->top
,
493 arrowSize
, rect
->bottom
- rect
->top
,
495 GetSystemMetrics(SM_CXVSCROLL
), GetSystemMetrics(SM_CYHSCROLL
),
497 SelectObject( hdcMem
, hbmpPrev
);
501 static void SCROLL_DrawArrows( HDC hdc
, SCROLLBAR_INFO
*infoPtr
,
502 RECT
*rect
, INT arrowSize
, BOOL vertical
,
503 BOOL top_pressed
, BOOL bottom_pressed
)
505 if( TWEAK_WineLook
== WIN31_LOOK
)
506 SCROLL_DrawArrows_31( hdc
, infoPtr
, rect
, arrowSize
,
507 vertical
, top_pressed
,bottom_pressed
);
509 SCROLL_DrawArrows_9x( hdc
, infoPtr
, rect
, arrowSize
,
510 vertical
, top_pressed
,bottom_pressed
);
514 /***********************************************************************
515 * SCROLL_DrawMovingThumb
517 * Draw the moving thumb rectangle.
519 static void SCROLL_DrawMovingThumb_31( HDC hdc
, RECT
*rect
, BOOL vertical
,
520 INT arrowSize
, INT thumbSize
)
525 r
.top
+= SCROLL_TrackingPos
;
526 if (r
.top
< rect
->top
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
527 r
.top
= rect
->top
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
528 if (r
.top
+ thumbSize
>
529 rect
->bottom
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
))
530 r
.top
= rect
->bottom
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
532 r
.bottom
= r
.top
+ thumbSize
;
536 r
.left
+= SCROLL_TrackingPos
;
537 if (r
.left
< rect
->left
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
538 r
.left
= rect
->left
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
539 if (r
.left
+ thumbSize
>
540 rect
->right
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
))
541 r
.left
= rect
->right
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
543 r
.right
= r
.left
+ thumbSize
;
546 DrawFocusRect( hdc
, &r
);
547 SCROLL_MovingThumb
= !SCROLL_MovingThumb
;
550 static void SCROLL_DrawMovingThumb_9x( HDC hdc
, RECT
*rect
, BOOL vertical
,
551 INT arrowSize
, INT thumbSize
)
553 INT pos
= SCROLL_TrackingPos
;
557 max_size
= rect
->bottom
- rect
->top
;
559 max_size
= rect
->right
- rect
->left
;
561 max_size
-= (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
) + thumbSize
;
563 if( pos
< (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
) )
564 pos
= (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
);
565 else if( pos
> max_size
)
568 SCROLL_DrawInterior_9x( SCROLL_TrackingWin
, hdc
, SCROLL_TrackingBar
,
569 rect
, arrowSize
, thumbSize
, pos
,
570 0, vertical
, FALSE
, FALSE
);
572 SCROLL_MovingThumb
= !SCROLL_MovingThumb
;
575 static void SCROLL_DrawMovingThumb( HDC hdc
, RECT
*rect
, BOOL vertical
,
576 INT arrowSize
, INT thumbSize
)
578 if( TWEAK_WineLook
== WIN31_LOOK
)
579 SCROLL_DrawMovingThumb_31( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
581 SCROLL_DrawMovingThumb_9x( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
584 /***********************************************************************
585 * SCROLL_DrawInterior
587 * Draw the scroll bar interior (everything except the arrows).
589 static void SCROLL_DrawInterior_9x( HWND hwnd
, HDC hdc
, INT nBar
,
590 RECT
*rect
, INT arrowSize
,
591 INT thumbSize
, INT thumbPos
,
592 UINT flags
, BOOL vertical
,
593 BOOL top_selected
, BOOL bottom_selected
)
597 HBRUSH hSaveBrush
,hBrush
;
599 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
600 * The window-owned scrollbars need to call DEFWND_ControlColor
601 * to correctly setup default scrollbar colors
605 hBrush
= (HBRUSH
)SendMessageA( GetParent(hwnd
), WM_CTLCOLORSCROLLBAR
,
606 (WPARAM
)hdc
,(LPARAM
)hwnd
);
610 hBrush
= DEFWND_ControlColor( hdc
, CTLCOLOR_SCROLLBAR
);
613 hSavePen
= SelectObject( hdc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
614 hSaveBrush
= SelectObject( hdc
, hBrush
);
616 /* 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 rectangles and thumb */
630 if (!thumbPos
) /* No thumb to draw */
632 PatBlt( hdc
, r
.left
, r
.top
,
633 r
.right
- r
.left
, r
.bottom
- r
.top
,
636 /* cleanup and return */
637 SelectObject( hdc
, hSavePen
);
638 SelectObject( hdc
, hSaveBrush
);
644 PatBlt( hdc
, r
.left
, r
.top
,
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
,
651 r
.bottom
- r
.top
- thumbSize
,
652 bottom_selected
? 0x0f0000 : PATCOPY
);
653 r
.bottom
= r
.top
+ thumbSize
;
655 else /* horizontal */
657 PatBlt( hdc
, r
.left
, r
.top
,
658 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
660 top_selected
? 0x0f0000 : PATCOPY
);
661 r
.left
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
662 PatBlt( hdc
, r
.left
+ thumbSize
, r
.top
,
663 r
.right
- r
.left
- thumbSize
,
665 bottom_selected
? 0x0f0000 : PATCOPY
);
666 r
.right
= r
.left
+ thumbSize
;
670 DrawEdge( hdc
, &r
, EDGE_RAISED
, BF_RECT
| BF_MIDDLE
);
673 SelectObject( hdc
, hSavePen
);
674 SelectObject( hdc
, hSaveBrush
);
678 static void SCROLL_DrawInterior( HWND hwnd
, HDC hdc
, INT nBar
,
679 RECT
*rect
, INT arrowSize
,
680 INT thumbSize
, INT thumbPos
,
681 UINT flags
, BOOL vertical
,
682 BOOL top_selected
, BOOL bottom_selected
)
686 HBRUSH hSaveBrush
,hBrush
;
687 BOOL Save_SCROLL_MovingThumb
= SCROLL_MovingThumb
;
689 if (Save_SCROLL_MovingThumb
&&
690 (SCROLL_TrackingWin
== hwnd
) &&
691 (SCROLL_TrackingBar
== nBar
))
692 SCROLL_DrawMovingThumb( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
694 /* Select the correct brush and pen */
696 if (TWEAK_WineLook
== WIN31_LOOK
&& (flags
& ESB_DISABLE_BOTH
) == ESB_DISABLE_BOTH
)
698 /* This ought to be the color of the parent window */
699 hBrush
= GetSysColorBrush(COLOR_WINDOW
);
703 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
704 * The window-owned scrollbars need to call DEFWND_ControlColor
705 * to correctly setup default scrollbar colors
707 if (nBar
== SB_CTL
) {
708 hBrush
= (HBRUSH
)SendMessageA( GetParent(hwnd
), WM_CTLCOLORSCROLLBAR
,
709 (WPARAM
)hdc
,(LPARAM
)hwnd
);
711 hBrush
= DEFWND_ControlColor( hdc
, CTLCOLOR_SCROLLBAR
);
714 hSavePen
= SelectObject( hdc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
715 hSaveBrush
= SelectObject( hdc
, hBrush
);
717 /* Calculate the scroll rectangle */
722 r
.top
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
723 r
.bottom
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
727 r
.left
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
728 r
.right
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
731 /* Draw the scroll bar frame */
733 /* Only draw outline if Win 3.1. Mar 24, 1999 - Ronald B. Cemer */
734 if (TWEAK_WineLook
== WIN31_LOOK
)
735 Rectangle( hdc
, r
.left
, r
.top
, r
.right
, r
.bottom
);
737 /* Draw the scroll rectangles and thumb */
739 if (!thumbPos
) /* No thumb to draw */
741 INT offset
= (TWEAK_WineLook
> WIN31_LOOK
) ? 0 : 1;
743 PatBlt( hdc
, r
.left
+offset
, r
.top
+offset
,
744 r
.right
- r
.left
- 2*offset
, r
.bottom
- r
.top
- 2*offset
,
747 /* cleanup and return */
748 SelectObject( hdc
, hSavePen
);
749 SelectObject( hdc
, hSaveBrush
);
755 INT offset
= (TWEAK_WineLook
== WIN31_LOOK
) ? 1 : 0;
757 PatBlt( hdc
, r
.left
+ offset
, r
.top
+ offset
,
758 r
.right
- r
.left
- offset
*2,
759 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
) - offset
,
760 top_selected
? 0x0f0000 : PATCOPY
);
761 r
.top
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
762 PatBlt( hdc
, r
.left
+ offset
, r
.top
+ thumbSize
,
763 r
.right
- r
.left
- offset
*2,
764 r
.bottom
- r
.top
- thumbSize
- offset
,
765 bottom_selected
? 0x0f0000 : PATCOPY
);
766 r
.bottom
= r
.top
+ thumbSize
;
768 else /* horizontal */
770 INT offset
= (TWEAK_WineLook
== WIN31_LOOK
) ? 1 : 0;
772 PatBlt( hdc
, r
.left
+ offset
, r
.top
+ offset
,
773 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
774 r
.bottom
- r
.top
- offset
*2,
775 top_selected
? 0x0f0000 : PATCOPY
);
776 r
.left
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
777 PatBlt( hdc
, r
.left
+ thumbSize
, r
.top
+ offset
,
778 r
.right
- r
.left
- thumbSize
- offset
,
779 r
.bottom
- r
.top
- offset
*2,
780 bottom_selected
? 0x0f0000 : PATCOPY
);
781 r
.right
= r
.left
+ thumbSize
;
786 SelectObject( hdc
, GetSysColorBrush(COLOR_BTNFACE
) );
787 if (TWEAK_WineLook
== WIN31_LOOK
)
789 Rectangle( hdc
, r
.left
, r
.top
, r
.right
, r
.bottom
);
794 Rectangle( hdc
, r
.left
+1, r
.top
+1, r
.right
-1, r
.bottom
-1 );
796 DrawEdge( hdc
, &r
, EDGE_RAISED
, BF_RECT
);
798 if (Save_SCROLL_MovingThumb
&&
799 (SCROLL_TrackingWin
== hwnd
) &&
800 (SCROLL_TrackingBar
== nBar
))
801 SCROLL_DrawMovingThumb( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
804 SelectObject( hdc
, hSavePen
);
805 SelectObject( hdc
, hSaveBrush
);
809 /***********************************************************************
810 * SCROLL_DrawScrollBar
812 * Redraw the whole scrollbar.
814 void SCROLL_DrawScrollBar( HWND hwnd
, HDC hdc
, INT nBar
,
815 BOOL arrows
, BOOL interior
)
817 INT arrowSize
, thumbSize
, thumbPos
;
820 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
821 SCROLLBAR_INFO
*infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
822 BOOL Save_SCROLL_MovingThumb
= SCROLL_MovingThumb
;
824 if (!wndPtr
|| !infoPtr
||
825 ((nBar
== SB_VERT
) && !(wndPtr
->dwStyle
& WS_VSCROLL
)) ||
826 ((nBar
== SB_HORZ
) && !(wndPtr
->dwStyle
& WS_HSCROLL
))) goto END
;
827 if (!WIN_IsWindowDrawable( hwnd
, FALSE
)) goto END
;
828 hwnd
= wndPtr
->hwndSelf
; /* make it a full handle */
830 vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
831 &arrowSize
, &thumbSize
, &thumbPos
);
833 /* do not draw if the scrollbar rectangle is empty */
834 if(IsRectEmpty(&rect
))
837 if (Save_SCROLL_MovingThumb
&&
838 (SCROLL_TrackingWin
== hwnd
) &&
839 (SCROLL_TrackingBar
== nBar
))
840 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
842 /* Draw the arrows */
844 if (arrows
&& arrowSize
)
846 if( vertical
== SCROLL_trackVertical
&& GetCapture() == hwnd
)
847 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
848 (SCROLL_trackHitTest
== SCROLL_TOP_ARROW
),
849 (SCROLL_trackHitTest
== SCROLL_BOTTOM_ARROW
) );
851 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
855 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
856 thumbPos
, infoPtr
->flags
, vertical
, FALSE
, FALSE
);
858 if (Save_SCROLL_MovingThumb
&&
859 (SCROLL_TrackingWin
== hwnd
) &&
860 (SCROLL_TrackingBar
== nBar
))
861 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
863 /* if scroll bar has focus, reposition the caret */
864 if(hwnd
==GetFocus() && (nBar
==SB_CTL
))
868 SetCaretPos(thumbPos
+1, rect
.top
+1);
872 SetCaretPos(rect
.top
+1, thumbPos
+1);
877 WIN_ReleaseWndPtr(wndPtr
);
881 /***********************************************************************
882 * SCROLL_RefreshScrollBar
884 * Repaint the scroll bar interior after a SetScrollRange() or
885 * SetScrollPos() call.
887 static void SCROLL_RefreshScrollBar( HWND hwnd
, INT nBar
,
888 BOOL arrows
, BOOL interior
)
890 HDC hdc
= GetDCEx( hwnd
, 0,
891 DCX_CACHE
| ((nBar
== SB_CTL
) ? 0 : DCX_WINDOW
) );
894 SCROLL_DrawScrollBar( hwnd
, hdc
, nBar
, arrows
, interior
);
895 ReleaseDC( hwnd
, hdc
);
899 /***********************************************************************
900 * SCROLL_HandleKbdEvent
902 * Handle a keyboard event (only for SB_CTL scrollbars with focus).
904 static void SCROLL_HandleKbdEvent(
905 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
906 WPARAM wParam
/* [in] Variable input including enable state */,
907 LPARAM lParam
/* [in] Variable input including input point */)
909 TRACE("hwnd=%p wParam=%d lParam=%ld\n", hwnd
, wParam
, lParam
);
911 /* hide caret on first KEYDOWN to prevent flicker */
912 if ((lParam
& PFD_DOUBLEBUFFER_DONTCARE
) == 0)
917 case VK_PRIOR
: wParam
= SB_PAGEUP
; break;
918 case VK_NEXT
: wParam
= SB_PAGEDOWN
; break;
919 case VK_HOME
: wParam
= SB_TOP
; break;
920 case VK_END
: wParam
= SB_BOTTOM
; break;
921 case VK_UP
: wParam
= SB_LINEUP
; break;
922 case VK_DOWN
: wParam
= SB_LINEDOWN
; break;
925 SendMessageW(GetParent(hwnd
),
926 ((GetWindowLongA( hwnd
, GWL_STYLE
) & SBS_VERT
) ?
927 WM_VSCROLL
: WM_HSCROLL
), wParam
, (LPARAM
)hwnd
);
931 /***********************************************************************
932 * SCROLL_HandleScrollEvent
934 * Handle a mouse or timer event for the scrollbar.
935 * 'pt' is the location of the mouse event in client (for SB_CTL) or
936 * windows coordinates.
938 static void SCROLL_HandleScrollEvent( HWND hwnd
, INT nBar
, UINT msg
, POINT pt
)
940 /* Previous mouse position for timer events */
942 /* Thumb position when tracking started. */
943 static UINT trackThumbPos
;
944 /* Position in the scroll-bar of the last button-down event. */
945 static INT lastClickPos
;
946 /* Position in the scroll-bar of the last mouse event. */
947 static INT lastMousePos
;
949 enum SCROLL_HITTEST hittest
;
950 HWND hwndOwner
, hwndCtl
;
952 INT arrowSize
, thumbSize
, thumbPos
;
956 SCROLLBAR_INFO
*infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
957 if (!infoPtr
) return;
958 if ((SCROLL_trackHitTest
== SCROLL_NOWHERE
) && (msg
!= WM_LBUTTONDOWN
))
961 hdc
= GetDCEx( hwnd
, 0, DCX_CACHE
| ((nBar
== SB_CTL
) ? 0 : DCX_WINDOW
));
962 vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
963 &arrowSize
, &thumbSize
, &thumbPos
);
964 hwndOwner
= (nBar
== SB_CTL
) ? GetParent(hwnd
) : hwnd
;
965 hwndCtl
= (nBar
== SB_CTL
) ? hwnd
: 0;
969 case WM_LBUTTONDOWN
: /* Initialise mouse tracking */
970 HideCaret(hwnd
); /* hide caret while holding down LBUTTON */
971 SCROLL_trackVertical
= vertical
;
972 SCROLL_trackHitTest
= hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, FALSE
);
973 lastClickPos
= vertical
? (pt
.y
- rect
.top
) : (pt
.x
- rect
.left
);
974 lastMousePos
= lastClickPos
;
975 trackThumbPos
= thumbPos
;
977 if (nBar
== SB_CTL
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_TABSTOP
)) SetFocus( hwnd
);
982 hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, TRUE
);
987 hittest
= SCROLL_NOWHERE
;
989 /* if scrollbar has focus, show back caret */
990 if (hwnd
==GetFocus()) ShowCaret(hwnd
);
995 hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, FALSE
);
999 return; /* Should never happen */
1002 TRACE("Event: hwnd=%p bar=%d msg=%s pt=%ld,%ld hit=%d\n",
1003 hwnd
, nBar
, SPY_GetMsgName(msg
,hwnd
), pt
.x
, pt
.y
, hittest
);
1005 switch(SCROLL_trackHitTest
)
1007 case SCROLL_NOWHERE
: /* No tracking in progress */
1010 case SCROLL_TOP_ARROW
:
1011 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
1012 (hittest
== SCROLL_trackHitTest
), FALSE
);
1013 if (hittest
== SCROLL_trackHitTest
)
1015 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1017 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1018 SB_LINEUP
, (LPARAM
)hwndCtl
);
1021 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1022 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1025 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1028 case SCROLL_TOP_RECT
:
1029 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1030 thumbPos
, infoPtr
->flags
, vertical
,
1031 (hittest
== SCROLL_trackHitTest
), FALSE
);
1032 if (hittest
== SCROLL_trackHitTest
)
1034 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1036 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1037 SB_PAGEUP
, (LPARAM
)hwndCtl
);
1039 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1040 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1043 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1047 if (msg
== WM_LBUTTONDOWN
)
1049 SCROLL_TrackingWin
= hwnd
;
1050 SCROLL_TrackingBar
= nBar
;
1051 SCROLL_TrackingPos
= trackThumbPos
+ lastMousePos
- lastClickPos
;
1052 SCROLL_TrackingVal
= SCROLL_GetThumbVal( infoPtr
, &rect
,
1054 SCROLL_TrackingPos
);
1055 if (!SCROLL_MovingThumb
)
1056 SCROLL_DrawMovingThumb(hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
1058 else if (msg
== WM_LBUTTONUP
)
1060 if (SCROLL_MovingThumb
)
1061 SCROLL_DrawMovingThumb(hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
1062 SCROLL_TrackingWin
= 0;
1063 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1064 thumbPos
, infoPtr
->flags
, vertical
,
1067 else /* WM_MOUSEMOVE */
1071 if (!SCROLL_PtInRectEx( &rect
, pt
, vertical
)) pos
= lastClickPos
;
1074 pt
= SCROLL_ClipPos( &rect
, pt
);
1075 pos
= vertical
? (pt
.y
- rect
.top
) : (pt
.x
- rect
.left
);
1077 if ( (pos
!= lastMousePos
) || (!SCROLL_MovingThumb
) )
1079 if (SCROLL_MovingThumb
)
1080 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
,
1081 arrowSize
, thumbSize
);
1083 SCROLL_TrackingPos
= trackThumbPos
+ pos
- lastClickPos
;
1084 SCROLL_TrackingVal
= SCROLL_GetThumbVal( infoPtr
, &rect
,
1086 SCROLL_TrackingPos
);
1087 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1088 MAKEWPARAM( SB_THUMBTRACK
, SCROLL_TrackingVal
),
1090 if (!SCROLL_MovingThumb
)
1091 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
,
1092 arrowSize
, thumbSize
);
1097 case SCROLL_BOTTOM_RECT
:
1098 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1099 thumbPos
, infoPtr
->flags
, vertical
,
1100 FALSE
, (hittest
== SCROLL_trackHitTest
) );
1101 if (hittest
== SCROLL_trackHitTest
)
1103 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1105 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1106 SB_PAGEDOWN
, (LPARAM
)hwndCtl
);
1108 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1109 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1112 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1115 case SCROLL_BOTTOM_ARROW
:
1116 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
1117 FALSE
, (hittest
== SCROLL_trackHitTest
) );
1118 if (hittest
== SCROLL_trackHitTest
)
1120 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1122 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1123 SB_LINEDOWN
, (LPARAM
)hwndCtl
);
1126 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1127 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1130 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1134 if (msg
== WM_LBUTTONDOWN
)
1137 if (hittest
== SCROLL_THUMB
)
1139 UINT val
= SCROLL_GetThumbVal( infoPtr
, &rect
, vertical
,
1140 trackThumbPos
+ lastMousePos
- lastClickPos
);
1141 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1142 MAKEWPARAM( SB_THUMBTRACK
, val
), (LPARAM
)hwndCtl
);
1146 if (msg
== WM_LBUTTONUP
)
1148 hittest
= SCROLL_trackHitTest
;
1149 SCROLL_trackHitTest
= SCROLL_NOWHERE
; /* Terminate tracking */
1151 if (hittest
== SCROLL_THUMB
)
1153 UINT val
= SCROLL_GetThumbVal( infoPtr
, &rect
, vertical
,
1154 trackThumbPos
+ lastMousePos
- lastClickPos
);
1155 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1156 MAKEWPARAM( SB_THUMBPOSITION
, val
), (LPARAM
)hwndCtl
);
1158 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1159 SB_ENDSCROLL
, (LPARAM
)hwndCtl
);
1162 ReleaseDC( hwnd
, hdc
);
1166 /***********************************************************************
1167 * SCROLL_TrackScrollBar
1169 * Track a mouse button press on a scroll-bar.
1170 * pt is in screen-coordinates for non-client scroll bars.
1172 void SCROLL_TrackScrollBar( HWND hwnd
, INT scrollbar
, POINT pt
)
1175 INT xoffset
= 0, yoffset
= 0;
1177 if (scrollbar
!= SB_CTL
)
1179 WND
*wndPtr
= WIN_GetPtr( hwnd
);
1180 if (!wndPtr
|| wndPtr
== WND_OTHER_PROCESS
) return;
1181 xoffset
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
1182 yoffset
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
1183 WIN_ReleasePtr( wndPtr
);
1184 ScreenToClient( hwnd
, &pt
);
1189 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1193 if (!GetMessageW( &msg
, 0, 0, 0 )) break;
1194 if (CallMsgFilterW( &msg
, MSGF_SCROLLBAR
)) continue;
1200 pt
.x
= LOWORD(msg
.lParam
) + xoffset
;
1201 pt
.y
= HIWORD(msg
.lParam
) + yoffset
;
1202 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
.message
, pt
);
1205 TranslateMessage( &msg
);
1206 DispatchMessageW( &msg
);
1209 if (!IsWindow( hwnd
))
1214 } while (msg
.message
!= WM_LBUTTONUP
);
1218 /***********************************************************************
1219 * SCROLL_CreateScrollBar
1221 * Create a scroll bar
1223 static void SCROLL_CreateScrollBar(
1224 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1225 LPCREATESTRUCTW lpCreate
/* [in] The style and place of the scroll bar */)
1227 LPSCROLLBAR_INFO info
= SCROLL_GetScrollBarInfo(hwnd
, SB_CTL
);
1230 TRACE("hwnd=%p lpCreate=%p\n", hwnd
, lpCreate
);
1232 if (lpCreate
->style
& WS_DISABLED
)
1234 info
->flags
= ESB_DISABLE_BOTH
;
1235 TRACE("Created WS_DISABLED scrollbar\n");
1238 if (lpCreate
->style
& SBS_VERT
)
1240 if (lpCreate
->style
& SBS_LEFTALIGN
)
1241 MoveWindow( hwnd
, lpCreate
->x
, lpCreate
->y
,
1242 GetSystemMetrics(SM_CXVSCROLL
)+1, lpCreate
->cy
, FALSE
);
1243 else if (lpCreate
->style
& SBS_RIGHTALIGN
)
1245 lpCreate
->x
+lpCreate
->cx
-GetSystemMetrics(SM_CXVSCROLL
)-1,
1247 GetSystemMetrics(SM_CXVSCROLL
)+1, lpCreate
->cy
, FALSE
);
1251 if (lpCreate
->style
& SBS_TOPALIGN
)
1252 MoveWindow( hwnd
, lpCreate
->x
, lpCreate
->y
,
1253 lpCreate
->cx
, GetSystemMetrics(SM_CYHSCROLL
)+1, FALSE
);
1254 else if (lpCreate
->style
& SBS_BOTTOMALIGN
)
1257 lpCreate
->y
+lpCreate
->cy
-GetSystemMetrics(SM_CYHSCROLL
)-1,
1258 lpCreate
->cx
, GetSystemMetrics(SM_CYHSCROLL
)+1, FALSE
);
1263 /*************************************************************************
1264 * SCROLL_GetScrollInfo
1266 * Internal helper for the API function
1268 static BOOL
SCROLL_GetScrollInfo(
1269 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1270 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1271 LPSCROLLINFO info
/* [in/out] (fMask specifies which values to retrieve) */)
1273 LPSCROLLBAR_INFO infoPtr
;
1275 /* handle invalid data structure */
1276 if (!SCROLL_ScrollInfoValid(info
)
1277 || !(infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
)))
1280 /* fill in the desired scroll info structure */
1281 if (info
->fMask
& SIF_PAGE
) info
->nPage
= infoPtr
->page
;
1282 if (info
->fMask
& SIF_POS
) info
->nPos
= infoPtr
->curVal
;
1283 if ((info
->fMask
& SIF_TRACKPOS
) && (info
->cbSize
== sizeof(*info
)))
1284 info
->nTrackPos
= (SCROLL_TrackingWin
== WIN_GetFullHandle(hwnd
)) ? SCROLL_TrackingVal
: infoPtr
->curVal
;
1285 if (info
->fMask
& SIF_RANGE
)
1287 info
->nMin
= infoPtr
->minVal
;
1288 info
->nMax
= infoPtr
->maxVal
;
1291 return (info
->fMask
& SIF_ALL
) != 0;
1295 /*************************************************************************
1296 * SCROLL_GetScrollPos
1298 * Internal helper for the API function
1300 static INT
SCROLL_GetScrollPos(
1301 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1302 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1304 LPSCROLLBAR_INFO infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
);
1305 return infoPtr
? infoPtr
->curVal
: 0;
1309 /*************************************************************************
1310 * SCROLL_GetScrollRange
1312 * Internal helper for the API function
1316 static BOOL
SCROLL_GetScrollRange(
1317 HWND hwnd
, /* [in] Handle of window */
1318 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1319 LPINT lpMin
, /* [out] Where to store minimum value */
1320 LPINT lpMax
/* [out] Where to store maximum value */)
1322 LPSCROLLBAR_INFO infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
);
1324 if (lpMin
) *lpMin
= infoPtr
? infoPtr
->minVal
: 0;
1325 if (lpMax
) *lpMax
= infoPtr
? infoPtr
->maxVal
: 0;
1327 return infoPtr
? TRUE
: FALSE
;
1332 /***********************************************************************
1335 static LRESULT WINAPI
ScrollBarWndProc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1337 if (!IsWindow( hwnd
)) return 0;
1342 SCROLL_CreateScrollBar(hwnd
, (LPCREATESTRUCTW
)lParam
);
1343 if (!hUpArrow
) SCROLL_LoadBitmaps();
1348 SCROLLBAR_INFO
*infoPtr
;
1349 if ((infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, SB_CTL
)))
1351 infoPtr
->flags
= wParam
? ESB_ENABLE_BOTH
: ESB_DISABLE_BOTH
;
1352 SCROLL_RefreshScrollBar(hwnd
, SB_CTL
, TRUE
, TRUE
);
1357 case WM_LBUTTONDOWN
:
1360 pt
.x
= (short)LOWORD(lParam
);
1361 pt
.y
= (short)HIWORD(lParam
);
1362 SCROLL_TrackScrollBar( hwnd
, SB_CTL
, pt
);
1370 pt
.x
= (short)LOWORD(lParam
);
1371 pt
.y
= (short)HIWORD(lParam
);
1372 SCROLL_HandleScrollEvent( hwnd
, SB_CTL
, message
, pt
);
1377 SCROLL_HandleKbdEvent(hwnd
, wParam
, lParam
);
1386 /* Create a caret when a ScrollBar get focus */
1388 int arrowSize
, thumbSize
, thumbPos
, vertical
;
1389 vertical
= SCROLL_GetScrollBarRect( hwnd
, SB_CTL
, &rect
,
1390 &arrowSize
, &thumbSize
, &thumbPos
);
1393 CreateCaret(hwnd
, (HBITMAP
)1, thumbSize
-2, rect
.bottom
-rect
.top
-2);
1394 SetCaretPos(thumbPos
+1, rect
.top
+1);
1398 CreateCaret(hwnd
, (HBITMAP
)1, rect
.right
-rect
.left
-2,thumbSize
-2);
1399 SetCaretPos(rect
.top
+1, thumbPos
+1);
1408 int arrowSize
, thumbSize
, thumbPos
, vertical
;
1409 vertical
= SCROLL_GetScrollBarRect( hwnd
, SB_CTL
, &rect
,&arrowSize
, &thumbSize
, &thumbPos
);
1411 rect
.left
=thumbPos
+1;
1412 rect
.right
=rect
.left
+thumbSize
;
1416 rect
.top
=thumbPos
+1;
1417 rect
.bottom
=rect
.top
+thumbSize
;
1420 InvalidateRect(hwnd
,&rect
,0);
1429 return DLGC_WANTARROWS
; /* Windows returns this value */
1434 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
1435 if (GetWindowLongW( hwnd
, GWL_STYLE
) & SBS_SIZEBOX
)
1438 GetClientRect( hwnd
, &rc
);
1439 FillRect( hdc
, &rc
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1442 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_CTL
, TRUE
, TRUE
);
1443 if (!wParam
) EndPaint(hwnd
, &ps
);
1449 return SetScrollPos( hwnd
, SB_CTL
, wParam
, (BOOL
)lParam
);
1453 return SCROLL_GetScrollPos(hwnd
, SB_CTL
);
1455 case SBM_SETRANGE16
:
1456 SetScrollRange( hwnd
, SB_CTL
, LOWORD(lParam
), HIWORD(lParam
),
1457 wParam
/* FIXME: Is this correct? */ );
1462 INT oldPos
= SCROLL_GetScrollPos( hwnd
, SB_CTL
);
1463 SetScrollRange( hwnd
, SB_CTL
, wParam
, lParam
, FALSE
);
1464 if (oldPos
!= SCROLL_GetScrollPos( hwnd
, SB_CTL
)) return oldPos
;
1468 case SBM_GETRANGE16
:
1469 FIXME("don't know how to handle SBM_GETRANGE16 (wp=%04x,lp=%08lx)\n", wParam
, lParam
);
1473 return SCROLL_GetScrollRange(hwnd
, SB_CTL
, (LPINT
)wParam
, (LPINT
)lParam
);
1475 case SBM_ENABLE_ARROWS16
:
1476 case SBM_ENABLE_ARROWS
:
1477 return EnableScrollBar( hwnd
, SB_CTL
, wParam
);
1479 case SBM_SETRANGEREDRAW
:
1481 INT oldPos
= SCROLL_GetScrollPos( hwnd
, SB_CTL
);
1482 SetScrollRange( hwnd
, SB_CTL
, wParam
, lParam
, TRUE
);
1483 if (oldPos
!= SCROLL_GetScrollPos( hwnd
, SB_CTL
)) return oldPos
;
1487 case SBM_SETSCROLLINFO
:
1488 return SetScrollInfo( hwnd
, SB_CTL
, (SCROLLINFO
*)lParam
, wParam
);
1490 case SBM_GETSCROLLINFO
:
1491 return SCROLL_GetScrollInfo(hwnd
, SB_CTL
, (SCROLLINFO
*)lParam
);
1501 ERR("unknown Win32 msg %04x wp=%08x lp=%08lx\n",
1502 message
, wParam
, lParam
);
1506 if (message
>= WM_USER
)
1507 WARN("unknown msg %04x wp=%04x lp=%08lx\n",
1508 message
, wParam
, lParam
);
1509 return DefWindowProcW( hwnd
, message
, wParam
, lParam
);
1515 /*************************************************************************
1516 * SetScrollInfo (USER32.@)
1517 * SetScrollInfo can be used to set the position, upper bound,
1518 * lower bound, and page size of a scrollbar control.
1521 * Scrollbar position
1524 * For 100 lines of text to be displayed in a window of 25 lines,
1525 * one would for instance use info->nMin=0, info->nMax=75
1526 * (corresponding to the 76 different positions of the window on
1527 * the text), and info->nPage=25.
1529 INT WINAPI
SetScrollInfo(
1530 HWND hwnd
/* [in] Handle of window whose scrollbar will be affected */,
1531 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1532 const SCROLLINFO
*info
/* [in] Specifies what to change and new values */,
1533 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */)
1536 INT retVal
= SCROLL_SetScrollInfo( hwnd
, nBar
, info
, &action
);
1538 if( action
& SA_SSI_HIDE
)
1539 SCROLL_ShowScrollBar( hwnd
, nBar
, FALSE
, FALSE
);
1542 if( action
& SA_SSI_SHOW
)
1543 if( SCROLL_ShowScrollBar( hwnd
, nBar
, TRUE
, TRUE
) )
1544 return retVal
; /* SetWindowPos() already did the painting */
1547 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, TRUE
);
1548 else if( action
& SA_SSI_REPAINT_ARROWS
)
1549 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, FALSE
);
1554 INT
SCROLL_SetScrollInfo( HWND hwnd
, INT nBar
,
1555 const SCROLLINFO
*info
, INT
*action
)
1557 /* Update the scrollbar state and set action flags according to
1558 * what has to be done graphics wise. */
1560 SCROLLBAR_INFO
*infoPtr
;
1562 BOOL bChangeParams
= FALSE
; /* don't show/hide scrollbar if params don't change */
1566 if (!(infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
))) return 0;
1567 if (info
->fMask
& ~(SIF_ALL
| SIF_DISABLENOSCROLL
)) return 0;
1568 if ((info
->cbSize
!= sizeof(*info
)) &&
1569 (info
->cbSize
!= sizeof(*info
)-sizeof(info
->nTrackPos
))) return 0;
1571 if (TRACE_ON(scroll
))
1573 TRACE("hwnd=%p bar=%d", hwnd
, nBar
);
1574 if (info
->fMask
& SIF_PAGE
) TRACE( " page=%d", info
->nPage
);
1575 if (info
->fMask
& SIF_POS
) TRACE( " pos=%d", info
->nPos
);
1576 if (info
->fMask
& SIF_RANGE
) TRACE( " min=%d max=%d", info
->nMin
, info
->nMax
);
1580 /* Set the page size */
1582 if (info
->fMask
& SIF_PAGE
)
1584 if( infoPtr
->page
!= info
->nPage
)
1586 infoPtr
->page
= info
->nPage
;
1587 *action
|= SA_SSI_REFRESH
;
1588 bChangeParams
= TRUE
;
1592 /* Set the scroll pos */
1594 if (info
->fMask
& SIF_POS
)
1596 if( infoPtr
->curVal
!= info
->nPos
)
1598 infoPtr
->curVal
= info
->nPos
;
1599 *action
|= SA_SSI_REFRESH
;
1603 /* Set the scroll range */
1605 if (info
->fMask
& SIF_RANGE
)
1607 /* Invalid range -> range is set to (0,0) */
1608 if ((info
->nMin
> info
->nMax
) ||
1609 ((UINT
)(info
->nMax
- info
->nMin
) >= 0x80000000))
1611 infoPtr
->minVal
= 0;
1612 infoPtr
->maxVal
= 0;
1613 bChangeParams
= TRUE
;
1617 if( infoPtr
->minVal
!= info
->nMin
||
1618 infoPtr
->maxVal
!= info
->nMax
)
1620 *action
|= SA_SSI_REFRESH
;
1621 infoPtr
->minVal
= info
->nMin
;
1622 infoPtr
->maxVal
= info
->nMax
;
1623 bChangeParams
= TRUE
;
1628 /* Make sure the page size is valid */
1630 if (infoPtr
->page
< 0) infoPtr
->page
= 0;
1631 else if (infoPtr
->page
> infoPtr
->maxVal
- infoPtr
->minVal
+ 1 )
1632 infoPtr
->page
= infoPtr
->maxVal
- infoPtr
->minVal
+ 1;
1634 /* Make sure the pos is inside the range */
1636 if (infoPtr
->curVal
< infoPtr
->minVal
)
1637 infoPtr
->curVal
= infoPtr
->minVal
;
1638 else if (infoPtr
->curVal
> infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 ))
1639 infoPtr
->curVal
= infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 );
1641 TRACE(" new values: page=%d pos=%d min=%d max=%d\n",
1642 infoPtr
->page
, infoPtr
->curVal
,
1643 infoPtr
->minVal
, infoPtr
->maxVal
);
1645 /* don't change the scrollbar state if SetScrollInfo
1646 * is just called with SIF_DISABLENOSCROLL
1648 if(!(info
->fMask
& SIF_ALL
)) goto done
;
1650 /* Check if the scrollbar should be hidden or disabled */
1652 if (info
->fMask
& (SIF_RANGE
| SIF_PAGE
| SIF_DISABLENOSCROLL
))
1654 new_flags
= infoPtr
->flags
;
1655 if (infoPtr
->minVal
>= infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 ))
1657 /* Hide or disable scroll-bar */
1658 if (info
->fMask
& SIF_DISABLENOSCROLL
)
1660 new_flags
= ESB_DISABLE_BOTH
;
1661 *action
|= SA_SSI_REFRESH
;
1663 else if ((nBar
!= SB_CTL
) && bChangeParams
)
1665 *action
= SA_SSI_HIDE
;
1669 else /* Show and enable scroll-bar */
1672 if ((nBar
!= SB_CTL
) && bChangeParams
)
1673 *action
|= SA_SSI_SHOW
;
1676 if (infoPtr
->flags
!= new_flags
) /* check arrow flags */
1678 infoPtr
->flags
= new_flags
;
1679 *action
|= SA_SSI_REPAINT_ARROWS
;
1684 /* Return current position */
1686 return infoPtr
->curVal
;
1690 /*************************************************************************
1691 * GetScrollInfo (USER32.@)
1693 * GetScrollInfo can be used to retrieve the position, upper bound,
1694 * lower bound, and page size of a scrollbar control.
1698 BOOL WINAPI
GetScrollInfo(
1699 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1700 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1701 LPSCROLLINFO info
/* [in/out] (fMask specifies which values to retrieve) */)
1703 TRACE("hwnd=%p nBar=%d info=%p\n", hwnd
, nBar
, info
);
1705 /* Refer SB_CTL requests to the window */
1707 return SendMessageA(hwnd
, SBM_GETSCROLLINFO
, (WPARAM
)0, (LPARAM
)info
);
1709 return SCROLL_GetScrollInfo(hwnd
, nBar
, info
);
1713 /*************************************************************************
1714 * SetScrollPos (USER32.@)
1717 * Success: Scrollbar position
1721 * Note the ambiguity when 0 is returned. Use GetLastError
1722 * to make sure there was an error (and to know which one).
1724 INT WINAPI
SetScrollPos(
1725 HWND hwnd
/* [in] Handle of window whose scrollbar will be affected */,
1726 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1727 INT nPos
/* [in] New value */,
1728 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */ )
1731 SCROLLBAR_INFO
*infoPtr
;
1734 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
))) return 0;
1735 oldPos
= infoPtr
->curVal
;
1736 info
.cbSize
= sizeof(info
);
1738 info
.fMask
= SIF_POS
;
1739 SetScrollInfo( hwnd
, nBar
, &info
, bRedraw
);
1744 /*************************************************************************
1745 * GetScrollPos (USER32.@)
1748 * Success: Current position
1752 * There is ambiguity when 0 is returned. Use GetLastError
1753 * to make sure there was an error (and to know which one).
1755 INT WINAPI
GetScrollPos(
1756 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1757 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1759 TRACE("hwnd=%p nBar=%d\n", hwnd
, nBar
);
1761 /* Refer SB_CTL requests to the window */
1763 return SendMessageA(hwnd
, SBM_GETPOS
, (WPARAM
)0, (LPARAM
)0);
1765 return SCROLL_GetScrollPos(hwnd
, nBar
);
1769 /*************************************************************************
1770 * SetScrollRange (USER32.@)
1774 BOOL WINAPI
SetScrollRange(
1775 HWND hwnd
, /* [in] Handle of window whose scrollbar will be affected */
1776 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1777 INT minVal
, /* [in] New minimum value */
1778 INT maxVal
, /* [in] New maximum value */
1779 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */)
1783 info
.cbSize
= sizeof(info
);
1786 info
.fMask
= SIF_RANGE
;
1787 SetScrollInfo( hwnd
, nBar
, &info
, bRedraw
);
1792 /*************************************************************************
1793 * SCROLL_SetNCSbState
1795 * Updates both scrollbars at the same time. Used by MDI CalcChildScroll().
1797 INT
SCROLL_SetNCSbState(HWND hwnd
, int vMin
, int vMax
, int vPos
,
1798 int hMin
, int hMax
, int hPos
)
1801 SCROLLINFO vInfo
, hInfo
;
1803 vInfo
.cbSize
= hInfo
.cbSize
= sizeof(SCROLLINFO
);
1810 vInfo
.fMask
= hInfo
.fMask
= SIF_RANGE
| SIF_POS
;
1812 SCROLL_SetScrollInfo( hwnd
, SB_VERT
, &vInfo
, &vA
);
1813 SCROLL_SetScrollInfo( hwnd
, SB_HORZ
, &hInfo
, &hA
);
1815 if( !SCROLL_ShowScrollBar( hwnd
, SB_BOTH
,
1816 (hA
& SA_SSI_SHOW
),(vA
& SA_SSI_SHOW
) ) )
1818 /* SetWindowPos() wasn't called, just redraw the scrollbars if needed */
1819 if( vA
& SA_SSI_REFRESH
)
1820 SCROLL_RefreshScrollBar( hwnd
, SB_VERT
, FALSE
, TRUE
);
1822 if( hA
& SA_SSI_REFRESH
)
1823 SCROLL_RefreshScrollBar( hwnd
, SB_HORZ
, FALSE
, TRUE
);
1829 /*************************************************************************
1830 * GetScrollRange (USER32.@)
1834 BOOL WINAPI
GetScrollRange(
1835 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1836 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1837 LPINT lpMin
/* [out] Where to store minimum value */,
1838 LPINT lpMax
/* [out] Where to store maximum value */)
1840 TRACE("hwnd=%p nBar=%d lpMin=%p lpMax=%p\n", hwnd
, nBar
, lpMin
, lpMax
);
1842 /* Refer SB_CTL requests to the window */
1844 return SendMessageA(hwnd
, SBM_GETRANGE
, (WPARAM
)lpMin
, (LPARAM
)lpMax
);
1846 return SCROLL_GetScrollRange(hwnd
, nBar
, lpMin
, lpMax
);
1850 /*************************************************************************
1851 * SCROLL_ShowScrollBar()
1853 * Back-end for ShowScrollBar(). Returns FALSE if no action was taken.
1855 BOOL
SCROLL_ShowScrollBar( HWND hwnd
, INT nBar
,
1856 BOOL fShowH
, BOOL fShowV
)
1858 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1860 TRACE("hwnd=%p bar=%d horz=%d, vert=%d\n", hwnd
, nBar
, fShowH
, fShowV
);
1865 ShowWindow( hwnd
, fShowH
? SW_SHOW
: SW_HIDE
);
1872 fShowH
= !(style
& WS_HSCROLL
);
1873 style
|= WS_HSCROLL
;
1877 fShowH
= (style
& WS_HSCROLL
);
1878 style
&= ~WS_HSCROLL
;
1880 if( nBar
== SB_HORZ
) {
1889 fShowV
= !(style
& WS_VSCROLL
);
1890 style
|= WS_VSCROLL
;
1894 fShowV
= (style
& WS_VSCROLL
);
1895 style
&= ~WS_VSCROLL
;
1897 if ( nBar
== SB_VERT
)
1902 return FALSE
; /* Nothing to do! */
1905 if( fShowH
|| fShowV
) /* frame has been changed, let the window redraw itself */
1907 WIN_SetStyle( hwnd
, style
);
1908 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
1909 | SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
1912 return FALSE
; /* no frame changes */
1916 /*************************************************************************
1917 * ShowScrollBar (USER32.@)
1921 BOOL WINAPI
ShowScrollBar(
1922 HWND hwnd
, /* [in] Handle of window whose scrollbar(s) will be affected */
1923 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */
1924 BOOL fShow
/* [in] TRUE = show, FALSE = hide */)
1926 SCROLL_ShowScrollBar( hwnd
, nBar
, (nBar
== SB_VERT
) ? 0 : fShow
,
1927 (nBar
== SB_HORZ
) ? 0 : fShow
);
1932 /*************************************************************************
1933 * EnableScrollBar (USER32.@)
1935 BOOL WINAPI
EnableScrollBar( HWND hwnd
, INT nBar
, UINT flags
)
1938 SCROLLBAR_INFO
*infoPtr
;
1940 TRACE("%p %d %d\n", hwnd
, nBar
, flags
);
1942 flags
&= ESB_DISABLE_BOTH
;
1944 if (nBar
== SB_BOTH
)
1946 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, SB_VERT
))) return FALSE
;
1947 if (!(bFineWithMe
= (infoPtr
->flags
== flags
)) )
1949 infoPtr
->flags
= flags
;
1950 SCROLL_RefreshScrollBar( hwnd
, SB_VERT
, TRUE
, TRUE
);
1957 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
))) return FALSE
;
1958 if (bFineWithMe
&& infoPtr
->flags
== flags
) return FALSE
;
1959 infoPtr
->flags
= flags
;
1961 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, TRUE
);