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
24 #include "wine/winuser16.h"
27 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(scroll
);
35 INT curVal
; /* Current scroll-bar value */
36 INT minVal
; /* Minimum scroll-bar value */
37 INT maxVal
; /* Maximum scroll-bar value */
38 INT page
; /* Page size of scroll bar (Win32) */
39 UINT flags
; /* EnableScrollBar flags */
40 } SCROLLBAR_INFO
, *LPSCROLLBAR_INFO
;
43 static HBITMAP hUpArrow
;
44 static HBITMAP hDnArrow
;
45 static HBITMAP hLfArrow
;
46 static HBITMAP hRgArrow
;
47 static HBITMAP hUpArrowD
;
48 static HBITMAP hDnArrowD
;
49 static HBITMAP hLfArrowD
;
50 static HBITMAP hRgArrowD
;
51 static HBITMAP hUpArrowI
;
52 static HBITMAP hDnArrowI
;
53 static HBITMAP hLfArrowI
;
54 static HBITMAP hRgArrowI
;
56 #define TOP_ARROW(flags,pressed) \
57 (((flags)&ESB_DISABLE_UP) ? hUpArrowI : ((pressed) ? hUpArrowD:hUpArrow))
58 #define BOTTOM_ARROW(flags,pressed) \
59 (((flags)&ESB_DISABLE_DOWN) ? hDnArrowI : ((pressed) ? hDnArrowD:hDnArrow))
60 #define LEFT_ARROW(flags,pressed) \
61 (((flags)&ESB_DISABLE_LEFT) ? hLfArrowI : ((pressed) ? hLfArrowD:hLfArrow))
62 #define RIGHT_ARROW(flags,pressed) \
63 (((flags)&ESB_DISABLE_RIGHT) ? hRgArrowI : ((pressed) ? hRgArrowD:hRgArrow))
66 /* Minimum size of the rectangle between the arrows */
67 #define SCROLL_MIN_RECT 4
69 /* Minimum size of the thumb in pixels */
70 #define SCROLL_MIN_THUMB 6
72 /* Overlap between arrows and thumb */
73 #define SCROLL_ARROW_THUMB_OVERLAP ((TWEAK_WineLook == WIN31_LOOK) ? 1 : 0)
75 /* Delay (in ms) before first repetition when holding the button down */
76 #define SCROLL_FIRST_DELAY 200
78 /* Delay (in ms) between scroll repetitions */
79 #define SCROLL_REPEAT_DELAY 50
82 #define SCROLL_TIMER 0
84 /* Scroll-bar hit testing */
87 SCROLL_NOWHERE
, /* Outside the scroll bar */
88 SCROLL_TOP_ARROW
, /* Top or left arrow */
89 SCROLL_TOP_RECT
, /* Rectangle between the top arrow and the thumb */
90 SCROLL_THUMB
, /* Thumb rectangle */
91 SCROLL_BOTTOM_RECT
, /* Rectangle between the thumb and the bottom arrow */
92 SCROLL_BOTTOM_ARROW
/* Bottom or right arrow */
95 /* What to do after SCROLL_SetScrollInfo() */
96 #define SA_SSI_HIDE 0x0001
97 #define SA_SSI_SHOW 0x0002
98 #define SA_SSI_REFRESH 0x0004
99 #define SA_SSI_REPAINT_ARROWS 0x0008
101 /* Thumb-tracking info */
102 static HWND SCROLL_TrackingWin
= 0;
103 static INT SCROLL_TrackingBar
= 0;
104 static INT SCROLL_TrackingPos
= 0;
105 static INT SCROLL_TrackingVal
= 0;
106 /* Hit test code of the last button-down event */
107 static enum SCROLL_HITTEST SCROLL_trackHitTest
;
108 static BOOL SCROLL_trackVertical
;
110 /* Is the moving thumb being displayed? */
111 static BOOL SCROLL_MovingThumb
= FALSE
;
113 /* Local functions */
114 static BOOL
SCROLL_ShowScrollBar( HWND hwnd
, INT nBar
,
115 BOOL fShowH
, BOOL fShowV
);
116 static INT
SCROLL_SetScrollInfo( HWND hwnd
, INT nBar
,
117 const SCROLLINFO
*info
, INT
*action
);
118 static void SCROLL_DrawInterior_9x( HWND hwnd
, HDC hdc
, INT nBar
,
119 RECT
*rect
, INT arrowSize
,
120 INT thumbSize
, INT thumbPos
,
121 UINT flags
, BOOL vertical
,
122 BOOL top_selected
, BOOL bottom_selected
);
123 static LRESULT WINAPI
ScrollBarWndProc( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
126 /*********************************************************************
127 * scrollbar class descriptor
129 const struct builtin_class_descr SCROLL_builtin_class
=
131 "ScrollBar", /* name */
132 CS_GLOBALCLASS
| CS_DBLCLKS
| CS_VREDRAW
| CS_HREDRAW
| CS_PARENTDC
, /* style */
133 NULL
, /* procA (winproc is Unicode only) */
134 ScrollBarWndProc
, /* procW */
135 sizeof(SCROLLBAR_INFO
), /* extra */
136 IDC_ARROWA
, /* cursor */
140 /***********************************************************************
141 * SCROLL_ScrollInfoValid
143 * Determine if the supplied SCROLLINFO struct is valid.
145 inline static BOOL
SCROLL_ScrollInfoValid(
146 LPSCROLLINFO info
/* [in] The SCROLLINFO struct to be tested */)
148 return !(info
->fMask
& ~(SIF_ALL
| SIF_DISABLENOSCROLL
)
149 || (info
->cbSize
!= sizeof(*info
)
150 && info
->cbSize
!= sizeof(*info
) - sizeof(info
->nTrackPos
)));
154 /***********************************************************************
157 static void SCROLL_LoadBitmaps(void)
159 hUpArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROW
) );
160 hDnArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROW
) );
161 hLfArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROW
) );
162 hRgArrow
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROW
) );
163 hUpArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWD
) );
164 hDnArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWD
) );
165 hLfArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWD
) );
166 hRgArrowD
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWD
) );
167 hUpArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWI
) );
168 hDnArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWI
) );
169 hLfArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWI
) );
170 hRgArrowI
= LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWI
) );
174 /***********************************************************************
175 * SCROLL_GetScrollBarInfo
177 static SCROLLBAR_INFO
*SCROLL_GetScrollBarInfo( HWND hwnd
, INT nBar
)
179 SCROLLBAR_INFO
*infoPtr
;
180 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
182 if (!wndPtr
) return NULL
;
185 case SB_HORZ
: infoPtr
= (SCROLLBAR_INFO
*)wndPtr
->pHScroll
; break;
186 case SB_VERT
: infoPtr
= (SCROLLBAR_INFO
*)wndPtr
->pVScroll
; break;
187 case SB_CTL
: infoPtr
= (SCROLLBAR_INFO
*)wndPtr
->wExtra
; break;
189 WIN_ReleaseWndPtr( wndPtr
);
193 if (!infoPtr
) /* Create the info structure if needed */
195 if ((infoPtr
= HeapAlloc( GetProcessHeap(), 0, sizeof(SCROLLBAR_INFO
) )))
197 infoPtr
->minVal
= infoPtr
->curVal
= infoPtr
->page
= 0;
198 infoPtr
->maxVal
= 100;
199 infoPtr
->flags
= ESB_ENABLE_BOTH
;
200 if (nBar
== SB_HORZ
) wndPtr
->pHScroll
= infoPtr
;
201 else wndPtr
->pVScroll
= infoPtr
;
203 if (!hUpArrow
) SCROLL_LoadBitmaps();
205 WIN_ReleaseWndPtr( wndPtr
);
210 /***********************************************************************
211 * SCROLL_GetScrollBarRect
213 * Compute the scroll bar rectangle, in drawing coordinates (i.e. client
214 * coords for SB_CTL, window coords for SB_VERT and SB_HORZ).
215 * 'arrowSize' returns the width or height of an arrow (depending on
216 * the orientation of the scrollbar), 'thumbSize' returns the size of
217 * the thumb, and 'thumbPos' returns the position of the thumb
218 * relative to the left or to the top.
219 * Return TRUE if the scrollbar is vertical, FALSE if horizontal.
221 static BOOL
SCROLL_GetScrollBarRect( HWND hwnd
, INT nBar
, RECT
*lprect
,
222 INT
*arrowSize
, INT
*thumbSize
,
227 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
232 lprect
->left
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
233 lprect
->top
= wndPtr
->rectClient
.bottom
- wndPtr
->rectWindow
.top
;
234 lprect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectWindow
.left
;
235 lprect
->bottom
= lprect
->top
+ GetSystemMetrics(SM_CYHSCROLL
);
236 if(wndPtr
->dwStyle
& WS_BORDER
) {
239 } else if(wndPtr
->dwStyle
& WS_VSCROLL
)
245 if((wndPtr
->dwExStyle
& WS_EX_LEFTSCROLLBAR
) != 0)
246 lprect
->left
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
- GetSystemMetrics(SM_CXVSCROLL
);
248 lprect
->left
= wndPtr
->rectClient
.right
- wndPtr
->rectWindow
.left
;
249 lprect
->top
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
250 lprect
->right
= lprect
->left
+ GetSystemMetrics(SM_CXVSCROLL
);
251 lprect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectWindow
.top
;
252 if(wndPtr
->dwStyle
& WS_BORDER
) {
255 } else if(wndPtr
->dwStyle
& WS_HSCROLL
)
261 GetClientRect( hwnd
, lprect
);
262 vertical
= ((wndPtr
->dwStyle
& SBS_VERT
) != 0);
266 WIN_ReleaseWndPtr(wndPtr
);
270 if (vertical
) pixels
= lprect
->bottom
- lprect
->top
;
271 else pixels
= lprect
->right
- lprect
->left
;
273 if (pixels
<= 2*GetSystemMetrics(SM_CXVSCROLL
) + SCROLL_MIN_RECT
)
275 if (pixels
> SCROLL_MIN_RECT
)
276 *arrowSize
= (pixels
- SCROLL_MIN_RECT
) / 2;
279 *thumbPos
= *thumbSize
= 0;
283 SCROLLBAR_INFO
*info
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
285 *arrowSize
= GetSystemMetrics(SM_CXVSCROLL
);
286 pixels
-= (2 * (GetSystemMetrics(SM_CXVSCROLL
) - SCROLL_ARROW_THUMB_OVERLAP
));
290 *thumbSize
= MulDiv(pixels
,info
->page
,(info
->maxVal
-info
->minVal
+1));
291 if (*thumbSize
< SCROLL_MIN_THUMB
) *thumbSize
= SCROLL_MIN_THUMB
;
293 else *thumbSize
= GetSystemMetrics(SM_CXVSCROLL
);
295 if (((pixels
-= *thumbSize
) < 0) ||
296 ((info
->flags
& ESB_DISABLE_BOTH
) == ESB_DISABLE_BOTH
))
298 /* Rectangle too small or scrollbar disabled -> no thumb */
299 *thumbPos
= *thumbSize
= 0;
303 INT max
= info
->maxVal
- max( info
->page
-1, 0 );
304 if (info
->minVal
>= max
)
305 *thumbPos
= *arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
307 *thumbPos
= *arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
308 + MulDiv(pixels
, (info
->curVal
-info
->minVal
),(max
- info
->minVal
));
311 WIN_ReleaseWndPtr(wndPtr
);
316 /***********************************************************************
319 * Compute the current scroll position based on the thumb position in pixels
320 * from the top of the scroll-bar.
322 static UINT
SCROLL_GetThumbVal( SCROLLBAR_INFO
*infoPtr
, RECT
*rect
,
323 BOOL vertical
, INT pos
)
326 INT pixels
= vertical
? rect
->bottom
-rect
->top
: rect
->right
-rect
->left
;
328 if ((pixels
-= 2*(GetSystemMetrics(SM_CXVSCROLL
) - SCROLL_ARROW_THUMB_OVERLAP
)) <= 0)
329 return infoPtr
->minVal
;
333 thumbSize
= MulDiv(pixels
,infoPtr
->page
,(infoPtr
->maxVal
-infoPtr
->minVal
+1));
334 if (thumbSize
< SCROLL_MIN_THUMB
) thumbSize
= SCROLL_MIN_THUMB
;
336 else thumbSize
= GetSystemMetrics(SM_CXVSCROLL
);
338 if ((pixels
-= thumbSize
) <= 0) return infoPtr
->minVal
;
340 pos
= max( 0, pos
- (GetSystemMetrics(SM_CXVSCROLL
) - SCROLL_ARROW_THUMB_OVERLAP
) );
341 if (pos
> pixels
) pos
= pixels
;
343 if (!infoPtr
->page
) pos
*= infoPtr
->maxVal
- infoPtr
->minVal
;
344 else pos
*= infoPtr
->maxVal
- infoPtr
->minVal
- infoPtr
->page
+ 1;
345 return infoPtr
->minVal
+ ((pos
+ pixels
/ 2) / pixels
);
348 /***********************************************************************
351 static BOOL
SCROLL_PtInRectEx( LPRECT lpRect
, POINT pt
, BOOL vertical
)
357 rect
.left
-= lpRect
->right
- lpRect
->left
;
358 rect
.right
+= lpRect
->right
- lpRect
->left
;
362 rect
.top
-= lpRect
->bottom
- lpRect
->top
;
363 rect
.bottom
+= lpRect
->bottom
- lpRect
->top
;
365 return PtInRect( &rect
, pt
);
368 /***********************************************************************
371 static POINT
SCROLL_ClipPos( LPRECT lpRect
, POINT pt
)
373 if( pt
.x
< lpRect
->left
)
376 if( pt
.x
> lpRect
->right
)
377 pt
.x
= lpRect
->right
;
379 if( pt
.y
< lpRect
->top
)
382 if( pt
.y
> lpRect
->bottom
)
383 pt
.y
= lpRect
->bottom
;
389 /***********************************************************************
392 * Scroll-bar hit testing (don't confuse this with WM_NCHITTEST!).
394 static enum SCROLL_HITTEST
SCROLL_HitTest( HWND hwnd
, INT nBar
,
395 POINT pt
, BOOL bDragging
)
397 INT arrowSize
, thumbSize
, thumbPos
;
400 BOOL vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
401 &arrowSize
, &thumbSize
, &thumbPos
);
403 if ( (bDragging
&& !SCROLL_PtInRectEx( &rect
, pt
, vertical
)) ||
404 (!PtInRect( &rect
, pt
)) ) return SCROLL_NOWHERE
;
408 if (pt
.y
< rect
.top
+ arrowSize
) return SCROLL_TOP_ARROW
;
409 if (pt
.y
>= rect
.bottom
- arrowSize
) return SCROLL_BOTTOM_ARROW
;
410 if (!thumbPos
) return SCROLL_TOP_RECT
;
412 if (pt
.y
< thumbPos
) return SCROLL_TOP_RECT
;
413 if (pt
.y
>= thumbPos
+ thumbSize
) return SCROLL_BOTTOM_RECT
;
415 else /* horizontal */
417 if (pt
.x
< rect
.left
+ arrowSize
) return SCROLL_TOP_ARROW
;
418 if (pt
.x
>= rect
.right
- arrowSize
) return SCROLL_BOTTOM_ARROW
;
419 if (!thumbPos
) return SCROLL_TOP_RECT
;
421 if (pt
.x
< thumbPos
) return SCROLL_TOP_RECT
;
422 if (pt
.x
>= thumbPos
+ thumbSize
) return SCROLL_BOTTOM_RECT
;
428 /***********************************************************************
431 * Draw the scroll bar arrows.
433 static void SCROLL_DrawArrows_9x( HDC hdc
, SCROLLBAR_INFO
*infoPtr
,
434 RECT
*rect
, INT arrowSize
, BOOL vertical
,
435 BOOL top_pressed
, BOOL bottom_pressed
)
441 r
.bottom
= r
.top
+ arrowSize
;
443 r
.right
= r
.left
+ arrowSize
;
445 DrawFrameControl( hdc
, &r
, DFC_SCROLL
,
446 (vertical
? DFCS_SCROLLUP
: DFCS_SCROLLLEFT
)
447 | (top_pressed
? (DFCS_PUSHED
| DFCS_FLAT
) : 0 )
448 | (infoPtr
->flags
&ESB_DISABLE_LTUP
? DFCS_INACTIVE
: 0 ) );
452 r
.top
= r
.bottom
-arrowSize
;
454 r
.left
= r
.right
-arrowSize
;
456 DrawFrameControl( hdc
, &r
, DFC_SCROLL
,
457 (vertical
? DFCS_SCROLLDOWN
: DFCS_SCROLLRIGHT
)
458 | (bottom_pressed
? (DFCS_PUSHED
| DFCS_FLAT
) : 0 )
459 | (infoPtr
->flags
&ESB_DISABLE_RTDN
? DFCS_INACTIVE
: 0) );
462 static void SCROLL_DrawArrows_31( HDC hdc
, SCROLLBAR_INFO
*infoPtr
,
463 RECT
*rect
, INT arrowSize
, BOOL vertical
,
464 BOOL top_pressed
, BOOL bottom_pressed
)
466 HDC hdcMem
= CreateCompatibleDC( hdc
);
467 HBITMAP hbmpPrev
= SelectObject( hdcMem
, vertical
?
468 TOP_ARROW(infoPtr
->flags
, top_pressed
)
469 : LEFT_ARROW(infoPtr
->flags
, top_pressed
));
471 SetStretchBltMode( hdc
, STRETCH_DELETESCANS
);
472 StretchBlt( hdc
, rect
->left
, rect
->top
,
473 vertical
? rect
->right
-rect
->left
: arrowSize
,
474 vertical
? arrowSize
: rect
->bottom
-rect
->top
,
476 GetSystemMetrics(SM_CXVSCROLL
),GetSystemMetrics(SM_CYHSCROLL
),
479 SelectObject( hdcMem
, vertical
?
480 BOTTOM_ARROW( infoPtr
->flags
, bottom_pressed
)
481 : RIGHT_ARROW( infoPtr
->flags
, bottom_pressed
) );
483 StretchBlt( hdc
, rect
->left
, rect
->bottom
- arrowSize
,
484 rect
->right
- rect
->left
, arrowSize
,
486 GetSystemMetrics(SM_CXVSCROLL
),GetSystemMetrics(SM_CYHSCROLL
),
489 StretchBlt( hdc
, rect
->right
- arrowSize
, rect
->top
,
490 arrowSize
, rect
->bottom
- rect
->top
,
492 GetSystemMetrics(SM_CXVSCROLL
), GetSystemMetrics(SM_CYHSCROLL
),
494 SelectObject( hdcMem
, hbmpPrev
);
498 static void SCROLL_DrawArrows( HDC hdc
, SCROLLBAR_INFO
*infoPtr
,
499 RECT
*rect
, INT arrowSize
, BOOL vertical
,
500 BOOL top_pressed
, BOOL bottom_pressed
)
502 if( TWEAK_WineLook
== WIN31_LOOK
)
503 SCROLL_DrawArrows_31( hdc
, infoPtr
, rect
, arrowSize
,
504 vertical
, top_pressed
,bottom_pressed
);
506 SCROLL_DrawArrows_9x( hdc
, infoPtr
, rect
, arrowSize
,
507 vertical
, top_pressed
,bottom_pressed
);
511 /***********************************************************************
512 * SCROLL_DrawMovingThumb
514 * Draw the moving thumb rectangle.
516 static void SCROLL_DrawMovingThumb_31( HDC hdc
, RECT
*rect
, BOOL vertical
,
517 INT arrowSize
, INT thumbSize
)
522 r
.top
+= SCROLL_TrackingPos
;
523 if (r
.top
< rect
->top
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
524 r
.top
= rect
->top
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
525 if (r
.top
+ thumbSize
>
526 rect
->bottom
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
))
527 r
.top
= rect
->bottom
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
529 r
.bottom
= r
.top
+ thumbSize
;
533 r
.left
+= SCROLL_TrackingPos
;
534 if (r
.left
< rect
->left
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
535 r
.left
= rect
->left
+ arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
536 if (r
.left
+ thumbSize
>
537 rect
->right
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
))
538 r
.left
= rect
->right
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
)
540 r
.right
= r
.left
+ thumbSize
;
543 DrawFocusRect( hdc
, &r
);
544 SCROLL_MovingThumb
= !SCROLL_MovingThumb
;
547 static void SCROLL_DrawMovingThumb_9x( HDC hdc
, RECT
*rect
, BOOL vertical
,
548 INT arrowSize
, INT thumbSize
)
550 INT pos
= SCROLL_TrackingPos
;
554 max_size
= rect
->bottom
- rect
->top
;
556 max_size
= rect
->right
- rect
->left
;
558 max_size
-= (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
) + thumbSize
;
560 if( pos
< (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
) )
561 pos
= (arrowSize
-SCROLL_ARROW_THUMB_OVERLAP
);
562 else if( pos
> max_size
)
565 SCROLL_DrawInterior_9x( SCROLL_TrackingWin
, hdc
, SCROLL_TrackingBar
,
566 rect
, arrowSize
, thumbSize
, pos
,
567 0, vertical
, FALSE
, FALSE
);
569 SCROLL_MovingThumb
= !SCROLL_MovingThumb
;
572 static void SCROLL_DrawMovingThumb( HDC hdc
, RECT
*rect
, BOOL vertical
,
573 INT arrowSize
, INT thumbSize
)
575 if( TWEAK_WineLook
== WIN31_LOOK
)
576 SCROLL_DrawMovingThumb_31( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
578 SCROLL_DrawMovingThumb_9x( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
581 /***********************************************************************
582 * SCROLL_DrawInterior
584 * Draw the scroll bar interior (everything except the arrows).
586 static void SCROLL_DrawInterior_9x( HWND hwnd
, HDC hdc
, INT nBar
,
587 RECT
*rect
, INT arrowSize
,
588 INT thumbSize
, INT thumbPos
,
589 UINT flags
, BOOL vertical
,
590 BOOL top_selected
, BOOL bottom_selected
)
594 HBRUSH hSaveBrush
,hBrush
;
596 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
597 * The window-owned scrollbars need to call DEFWND_ControlColor
598 * to correctly setup default scrollbar colors
602 hBrush
= (HBRUSH
)SendMessageA( GetParent(hwnd
), WM_CTLCOLORSCROLLBAR
,
603 (WPARAM
)hdc
,(LPARAM
)hwnd
);
607 hBrush
= DEFWND_ControlColor( hdc
, CTLCOLOR_SCROLLBAR
);
610 hSavePen
= SelectObject( hdc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
611 hSaveBrush
= SelectObject( hdc
, hBrush
);
613 /* Calculate the scroll rectangle */
617 r
.top
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
618 r
.bottom
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
622 r
.left
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
623 r
.right
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
626 /* Draw the scroll rectangles and thumb */
627 if (!thumbPos
) /* No thumb to draw */
629 PatBlt( hdc
, r
.left
, r
.top
,
630 r
.right
- r
.left
, r
.bottom
- r
.top
,
633 /* cleanup and return */
634 SelectObject( hdc
, hSavePen
);
635 SelectObject( hdc
, hSaveBrush
);
641 PatBlt( hdc
, r
.left
, r
.top
,
643 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
644 top_selected
? 0x0f0000 : PATCOPY
);
645 r
.top
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
646 PatBlt( hdc
, r
.left
, r
.top
+ thumbSize
,
648 r
.bottom
- r
.top
- thumbSize
,
649 bottom_selected
? 0x0f0000 : PATCOPY
);
650 r
.bottom
= r
.top
+ thumbSize
;
652 else /* horizontal */
654 PatBlt( hdc
, r
.left
, r
.top
,
655 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
657 top_selected
? 0x0f0000 : PATCOPY
);
658 r
.left
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
659 PatBlt( hdc
, r
.left
+ thumbSize
, r
.top
,
660 r
.right
- r
.left
- thumbSize
,
662 bottom_selected
? 0x0f0000 : PATCOPY
);
663 r
.right
= r
.left
+ thumbSize
;
667 DrawEdge( hdc
, &r
, EDGE_RAISED
, BF_RECT
| BF_MIDDLE
);
670 SelectObject( hdc
, hSavePen
);
671 SelectObject( hdc
, hSaveBrush
);
675 static void SCROLL_DrawInterior( HWND hwnd
, HDC hdc
, INT nBar
,
676 RECT
*rect
, INT arrowSize
,
677 INT thumbSize
, INT thumbPos
,
678 UINT flags
, BOOL vertical
,
679 BOOL top_selected
, BOOL bottom_selected
)
683 HBRUSH hSaveBrush
,hBrush
;
684 BOOL Save_SCROLL_MovingThumb
= SCROLL_MovingThumb
;
686 if (Save_SCROLL_MovingThumb
&&
687 (SCROLL_TrackingWin
== hwnd
) &&
688 (SCROLL_TrackingBar
== nBar
))
689 SCROLL_DrawMovingThumb( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
691 /* Select the correct brush and pen */
693 if (TWEAK_WineLook
== WIN31_LOOK
&& (flags
& ESB_DISABLE_BOTH
) == ESB_DISABLE_BOTH
)
695 /* This ought to be the color of the parent window */
696 hBrush
= GetSysColorBrush(COLOR_WINDOW
);
700 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
701 * The window-owned scrollbars need to call DEFWND_ControlColor
702 * to correctly setup default scrollbar colors
704 if (nBar
== SB_CTL
) {
705 hBrush
= (HBRUSH
)SendMessageA( GetParent(hwnd
), WM_CTLCOLORSCROLLBAR
,
706 (WPARAM
)hdc
,(LPARAM
)hwnd
);
708 hBrush
= DEFWND_ControlColor( hdc
, CTLCOLOR_SCROLLBAR
);
711 hSavePen
= SelectObject( hdc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
712 hSaveBrush
= SelectObject( hdc
, hBrush
);
714 /* Calculate the scroll rectangle */
719 r
.top
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
720 r
.bottom
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
724 r
.left
+= arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
;
725 r
.right
-= (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
728 /* Draw the scroll bar frame */
730 /* Only draw outline if Win 3.1. Mar 24, 1999 - Ronald B. Cemer */
731 if (TWEAK_WineLook
== WIN31_LOOK
)
732 Rectangle( hdc
, r
.left
, r
.top
, r
.right
, r
.bottom
);
734 /* Draw the scroll rectangles and thumb */
736 if (!thumbPos
) /* No thumb to draw */
738 INT offset
= (TWEAK_WineLook
> WIN31_LOOK
) ? 0 : 1;
740 PatBlt( hdc
, r
.left
+offset
, r
.top
+offset
,
741 r
.right
- r
.left
- 2*offset
, r
.bottom
- r
.top
- 2*offset
,
744 /* cleanup and return */
745 SelectObject( hdc
, hSavePen
);
746 SelectObject( hdc
, hSaveBrush
);
752 INT offset
= (TWEAK_WineLook
== WIN31_LOOK
) ? 1 : 0;
754 PatBlt( hdc
, r
.left
+ offset
, r
.top
+ offset
,
755 r
.right
- r
.left
- offset
*2,
756 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
) - offset
,
757 top_selected
? 0x0f0000 : PATCOPY
);
758 r
.top
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
759 PatBlt( hdc
, r
.left
+ offset
, r
.top
+ thumbSize
,
760 r
.right
- r
.left
- offset
*2,
761 r
.bottom
- r
.top
- thumbSize
- offset
,
762 bottom_selected
? 0x0f0000 : PATCOPY
);
763 r
.bottom
= r
.top
+ thumbSize
;
765 else /* horizontal */
767 INT offset
= (TWEAK_WineLook
== WIN31_LOOK
) ? 1 : 0;
769 PatBlt( hdc
, r
.left
+ offset
, r
.top
+ offset
,
770 thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
),
771 r
.bottom
- r
.top
- offset
*2,
772 top_selected
? 0x0f0000 : PATCOPY
);
773 r
.left
+= thumbPos
- (arrowSize
- SCROLL_ARROW_THUMB_OVERLAP
);
774 PatBlt( hdc
, r
.left
+ thumbSize
, r
.top
+ offset
,
775 r
.right
- r
.left
- thumbSize
- offset
,
776 r
.bottom
- r
.top
- offset
*2,
777 bottom_selected
? 0x0f0000 : PATCOPY
);
778 r
.right
= r
.left
+ thumbSize
;
783 SelectObject( hdc
, GetSysColorBrush(COLOR_BTNFACE
) );
784 if (TWEAK_WineLook
== WIN31_LOOK
)
786 Rectangle( hdc
, r
.left
, r
.top
, r
.right
, r
.bottom
);
791 Rectangle( hdc
, r
.left
+1, r
.top
+1, r
.right
-1, r
.bottom
-1 );
793 DrawEdge( hdc
, &r
, EDGE_RAISED
, BF_RECT
);
795 if (Save_SCROLL_MovingThumb
&&
796 (SCROLL_TrackingWin
== hwnd
) &&
797 (SCROLL_TrackingBar
== nBar
))
798 SCROLL_DrawMovingThumb( hdc
, rect
, vertical
, arrowSize
, thumbSize
);
801 SelectObject( hdc
, hSavePen
);
802 SelectObject( hdc
, hSaveBrush
);
806 /***********************************************************************
807 * SCROLL_DrawScrollBar
809 * Redraw the whole scrollbar.
811 void SCROLL_DrawScrollBar( HWND hwnd
, HDC hdc
, INT nBar
,
812 BOOL arrows
, BOOL interior
)
814 INT arrowSize
, thumbSize
, thumbPos
;
817 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
818 SCROLLBAR_INFO
*infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
819 BOOL Save_SCROLL_MovingThumb
= SCROLL_MovingThumb
;
821 if (!wndPtr
|| !infoPtr
||
822 ((nBar
== SB_VERT
) && !(wndPtr
->dwStyle
& WS_VSCROLL
)) ||
823 ((nBar
== SB_HORZ
) && !(wndPtr
->dwStyle
& WS_HSCROLL
))) goto END
;
824 if (!WIN_IsWindowDrawable( hwnd
, FALSE
)) goto END
;
825 hwnd
= wndPtr
->hwndSelf
; /* make it a full handle */
827 vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
828 &arrowSize
, &thumbSize
, &thumbPos
);
830 /* do not draw if the scrollbar rectangle is empty */
831 if(IsRectEmpty(&rect
))
834 if (Save_SCROLL_MovingThumb
&&
835 (SCROLL_TrackingWin
== hwnd
) &&
836 (SCROLL_TrackingBar
== nBar
))
837 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
839 /* Draw the arrows */
841 if (arrows
&& arrowSize
)
843 if( vertical
== SCROLL_trackVertical
&& GetCapture() == hwnd
)
844 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
845 (SCROLL_trackHitTest
== SCROLL_TOP_ARROW
),
846 (SCROLL_trackHitTest
== SCROLL_BOTTOM_ARROW
) );
848 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
852 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
853 thumbPos
, infoPtr
->flags
, vertical
, FALSE
, FALSE
);
855 if (Save_SCROLL_MovingThumb
&&
856 (SCROLL_TrackingWin
== hwnd
) &&
857 (SCROLL_TrackingBar
== nBar
))
858 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
860 /* if scroll bar has focus, reposition the caret */
861 if(hwnd
==GetFocus() && (nBar
==SB_CTL
))
865 SetCaretPos(thumbPos
+1, rect
.top
+1);
869 SetCaretPos(rect
.top
+1, thumbPos
+1);
874 WIN_ReleaseWndPtr(wndPtr
);
878 /***********************************************************************
879 * SCROLL_RefreshScrollBar
881 * Repaint the scroll bar interior after a SetScrollRange() or
882 * SetScrollPos() call.
884 static void SCROLL_RefreshScrollBar( HWND hwnd
, INT nBar
,
885 BOOL arrows
, BOOL interior
)
887 HDC hdc
= GetDCEx( hwnd
, 0,
888 DCX_CACHE
| ((nBar
== SB_CTL
) ? 0 : DCX_WINDOW
) );
891 SCROLL_DrawScrollBar( hwnd
, hdc
, nBar
, arrows
, interior
);
892 ReleaseDC( hwnd
, hdc
);
896 /***********************************************************************
897 * SCROLL_HandleKbdEvent
899 * Handle a keyboard event (only for SB_CTL scrollbars with focus).
901 static void SCROLL_HandleKbdEvent(
902 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
903 WPARAM wParam
/* [in] Variable input including enable state */,
904 LPARAM lParam
/* [in] Variable input including input point */)
906 TRACE("hwnd=%p wParam=%d lParam=%ld\n", hwnd
, wParam
, lParam
);
908 /* hide caret on first KEYDOWN to prevent flicker */
909 if ((lParam
& PFD_DOUBLEBUFFER_DONTCARE
) == 0)
914 case VK_PRIOR
: wParam
= SB_PAGEUP
; break;
915 case VK_NEXT
: wParam
= SB_PAGEDOWN
; break;
916 case VK_HOME
: wParam
= SB_TOP
; break;
917 case VK_END
: wParam
= SB_BOTTOM
; break;
918 case VK_UP
: wParam
= SB_LINEUP
; break;
919 case VK_DOWN
: wParam
= SB_LINEDOWN
; break;
922 SendMessageW(GetParent(hwnd
),
923 ((GetWindowLongA( hwnd
, GWL_STYLE
) & SBS_VERT
) ?
924 WM_VSCROLL
: WM_HSCROLL
), wParam
, (LPARAM
)hwnd
);
928 /***********************************************************************
929 * SCROLL_HandleScrollEvent
931 * Handle a mouse or timer event for the scrollbar.
932 * 'pt' is the location of the mouse event in client (for SB_CTL) or
933 * windows coordinates.
935 static void SCROLL_HandleScrollEvent( HWND hwnd
, INT nBar
, UINT msg
, POINT pt
)
937 /* Previous mouse position for timer events */
939 /* Thumb position when tracking started. */
940 static UINT trackThumbPos
;
941 /* Position in the scroll-bar of the last button-down event. */
942 static INT lastClickPos
;
943 /* Position in the scroll-bar of the last mouse event. */
944 static INT lastMousePos
;
946 enum SCROLL_HITTEST hittest
;
947 HWND hwndOwner
, hwndCtl
;
949 INT arrowSize
, thumbSize
, thumbPos
;
953 SCROLLBAR_INFO
*infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
);
954 if (!infoPtr
) return;
955 if ((SCROLL_trackHitTest
== SCROLL_NOWHERE
) && (msg
!= WM_LBUTTONDOWN
))
958 hdc
= GetDCEx( hwnd
, 0, DCX_CACHE
| ((nBar
== SB_CTL
) ? 0 : DCX_WINDOW
));
959 vertical
= SCROLL_GetScrollBarRect( hwnd
, nBar
, &rect
,
960 &arrowSize
, &thumbSize
, &thumbPos
);
961 hwndOwner
= (nBar
== SB_CTL
) ? GetParent(hwnd
) : hwnd
;
962 hwndCtl
= (nBar
== SB_CTL
) ? hwnd
: 0;
966 case WM_LBUTTONDOWN
: /* Initialise mouse tracking */
967 HideCaret(hwnd
); /* hide caret while holding down LBUTTON */
968 SCROLL_trackVertical
= vertical
;
969 SCROLL_trackHitTest
= hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, FALSE
);
970 lastClickPos
= vertical
? (pt
.y
- rect
.top
) : (pt
.x
- rect
.left
);
971 lastMousePos
= lastClickPos
;
972 trackThumbPos
= thumbPos
;
974 if (nBar
== SB_CTL
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_TABSTOP
)) SetFocus( hwnd
);
979 hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, TRUE
);
984 hittest
= SCROLL_NOWHERE
;
986 /* if scrollbar has focus, show back caret */
987 if (hwnd
==GetFocus()) ShowCaret(hwnd
);
992 hittest
= SCROLL_HitTest( hwnd
, nBar
, pt
, FALSE
);
996 return; /* Should never happen */
999 TRACE("Event: hwnd=%p bar=%d msg=%s pt=%ld,%ld hit=%d\n",
1000 hwnd
, nBar
, SPY_GetMsgName(msg
,hwnd
), pt
.x
, pt
.y
, hittest
);
1002 switch(SCROLL_trackHitTest
)
1004 case SCROLL_NOWHERE
: /* No tracking in progress */
1007 case SCROLL_TOP_ARROW
:
1008 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
1009 (hittest
== SCROLL_trackHitTest
), FALSE
);
1010 if (hittest
== SCROLL_trackHitTest
)
1012 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1014 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1015 SB_LINEUP
, (LPARAM
)hwndCtl
);
1018 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1019 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1022 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1025 case SCROLL_TOP_RECT
:
1026 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1027 thumbPos
, infoPtr
->flags
, vertical
,
1028 (hittest
== SCROLL_trackHitTest
), FALSE
);
1029 if (hittest
== SCROLL_trackHitTest
)
1031 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1033 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1034 SB_PAGEUP
, (LPARAM
)hwndCtl
);
1036 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1037 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1040 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1044 if (msg
== WM_LBUTTONDOWN
)
1046 SCROLL_TrackingWin
= hwnd
;
1047 SCROLL_TrackingBar
= nBar
;
1048 SCROLL_TrackingPos
= trackThumbPos
+ lastMousePos
- lastClickPos
;
1049 SCROLL_TrackingVal
= SCROLL_GetThumbVal( infoPtr
, &rect
,
1051 SCROLL_TrackingPos
);
1052 if (!SCROLL_MovingThumb
)
1053 SCROLL_DrawMovingThumb(hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
1055 else if (msg
== WM_LBUTTONUP
)
1057 if (SCROLL_MovingThumb
)
1058 SCROLL_DrawMovingThumb(hdc
, &rect
, vertical
, arrowSize
, thumbSize
);
1059 SCROLL_TrackingWin
= 0;
1060 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1061 thumbPos
, infoPtr
->flags
, vertical
,
1064 else /* WM_MOUSEMOVE */
1068 if (!SCROLL_PtInRectEx( &rect
, pt
, vertical
)) pos
= lastClickPos
;
1071 pt
= SCROLL_ClipPos( &rect
, pt
);
1072 pos
= vertical
? (pt
.y
- rect
.top
) : (pt
.x
- rect
.left
);
1074 if ( (pos
!= lastMousePos
) || (!SCROLL_MovingThumb
) )
1076 if (SCROLL_MovingThumb
)
1077 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
,
1078 arrowSize
, thumbSize
);
1080 SCROLL_TrackingPos
= trackThumbPos
+ pos
- lastClickPos
;
1081 SCROLL_TrackingVal
= SCROLL_GetThumbVal( infoPtr
, &rect
,
1083 SCROLL_TrackingPos
);
1084 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1085 MAKEWPARAM( SB_THUMBTRACK
, SCROLL_TrackingVal
),
1087 if (!SCROLL_MovingThumb
)
1088 SCROLL_DrawMovingThumb( hdc
, &rect
, vertical
,
1089 arrowSize
, thumbSize
);
1094 case SCROLL_BOTTOM_RECT
:
1095 SCROLL_DrawInterior( hwnd
, hdc
, nBar
, &rect
, arrowSize
, thumbSize
,
1096 thumbPos
, infoPtr
->flags
, vertical
,
1097 FALSE
, (hittest
== SCROLL_trackHitTest
) );
1098 if (hittest
== SCROLL_trackHitTest
)
1100 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1102 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1103 SB_PAGEDOWN
, (LPARAM
)hwndCtl
);
1105 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1106 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1109 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1112 case SCROLL_BOTTOM_ARROW
:
1113 SCROLL_DrawArrows( hdc
, infoPtr
, &rect
, arrowSize
, vertical
,
1114 FALSE
, (hittest
== SCROLL_trackHitTest
) );
1115 if (hittest
== SCROLL_trackHitTest
)
1117 if ((msg
== WM_LBUTTONDOWN
) || (msg
== WM_SYSTIMER
))
1119 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1120 SB_LINEDOWN
, (LPARAM
)hwndCtl
);
1123 SetSystemTimer( hwnd
, SCROLL_TIMER
, (msg
== WM_LBUTTONDOWN
) ?
1124 SCROLL_FIRST_DELAY
: SCROLL_REPEAT_DELAY
,
1127 else KillSystemTimer( hwnd
, SCROLL_TIMER
);
1131 if (msg
== WM_LBUTTONDOWN
)
1134 if (hittest
== SCROLL_THUMB
)
1136 UINT val
= SCROLL_GetThumbVal( infoPtr
, &rect
, vertical
,
1137 trackThumbPos
+ lastMousePos
- lastClickPos
);
1138 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1139 MAKEWPARAM( SB_THUMBTRACK
, val
), (LPARAM
)hwndCtl
);
1143 if (msg
== WM_LBUTTONUP
)
1145 hittest
= SCROLL_trackHitTest
;
1146 SCROLL_trackHitTest
= SCROLL_NOWHERE
; /* Terminate tracking */
1148 if (hittest
== SCROLL_THUMB
)
1150 UINT val
= SCROLL_GetThumbVal( infoPtr
, &rect
, vertical
,
1151 trackThumbPos
+ lastMousePos
- lastClickPos
);
1152 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1153 MAKEWPARAM( SB_THUMBPOSITION
, val
), (LPARAM
)hwndCtl
);
1155 SendMessageA( hwndOwner
, vertical
? WM_VSCROLL
: WM_HSCROLL
,
1156 SB_ENDSCROLL
, (LPARAM
)hwndCtl
);
1159 ReleaseDC( hwnd
, hdc
);
1163 /***********************************************************************
1164 * SCROLL_TrackScrollBar
1166 * Track a mouse button press on a scroll-bar.
1167 * pt is in screen-coordinates for non-client scroll bars.
1169 void SCROLL_TrackScrollBar( HWND hwnd
, INT scrollbar
, POINT pt
)
1172 INT xoffset
= 0, yoffset
= 0;
1174 if (scrollbar
!= SB_CTL
)
1176 WND
*wndPtr
= WIN_GetPtr( hwnd
);
1177 if (!wndPtr
|| wndPtr
== WND_OTHER_PROCESS
) return;
1178 xoffset
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
1179 yoffset
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
1180 WIN_ReleasePtr( wndPtr
);
1181 ScreenToClient( hwnd
, &pt
);
1186 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, WM_LBUTTONDOWN
, pt
);
1190 if (!GetMessageW( &msg
, 0, 0, 0 )) break;
1191 if (CallMsgFilterW( &msg
, MSGF_SCROLLBAR
)) continue;
1197 pt
.x
= LOWORD(msg
.lParam
) + xoffset
;
1198 pt
.y
= HIWORD(msg
.lParam
) + yoffset
;
1199 SCROLL_HandleScrollEvent( hwnd
, scrollbar
, msg
.message
, pt
);
1202 TranslateMessage( &msg
);
1203 DispatchMessageW( &msg
);
1206 if (!IsWindow( hwnd
))
1211 } while (msg
.message
!= WM_LBUTTONUP
);
1215 /***********************************************************************
1216 * SCROLL_CreateScrollBar
1218 * Create a scroll bar
1220 static void SCROLL_CreateScrollBar(
1221 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1222 LPCREATESTRUCTW lpCreate
/* [in] The style and place of the scroll bar */)
1225 LPSCROLLBAR_INFO info
= SCROLL_GetScrollBarInfo(hwnd
, SB_CTL
);
1228 TRACE("hwnd=%p lpCreate=%p\n", hwnd
, lpCreate
);
1230 if (lpCreate
->style
& WS_DISABLED
)
1232 info
->flags
= ESB_DISABLE_BOTH
;
1233 TRACE("Created WS_DISABLED scrollbar\n");
1236 /* copy the desired positions and size */
1237 pos
.x
= lpCreate
->x
; pos
.y
= lpCreate
->y
;
1238 size
.x
= lpCreate
->cx
; size
.y
= lpCreate
->cy
;
1240 /* move position based on style */
1241 if (lpCreate
->style
& SBS_RIGHTALIGN
)
1242 pos
.x
+= size
.x
- GetSystemMetrics(SM_CXVSCROLL
) - 1;
1243 else if (lpCreate
->style
& SBS_BOTTOMALIGN
)
1244 pos
.y
+= size
.y
- GetSystemMetrics(SM_CYHSCROLL
) - 1;
1246 /* change size based on style */
1247 if (lpCreate
->style
& SBS_VERT
)
1248 size
.x
= GetSystemMetrics(SM_CXVSCROLL
) + 1;
1250 size
.y
= GetSystemMetrics(SM_CYHSCROLL
) + 1;
1252 MoveWindow(hwnd
, pos
.x
, pos
.y
, size
.x
, size
.y
, FALSE
);
1256 /*************************************************************************
1257 * SCROLL_GetScrollInfo
1259 * Internal helper for the API function
1261 static BOOL
SCROLL_GetScrollInfo(
1262 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1263 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1264 LPSCROLLINFO info
/* [in/out] (fMask specifies which values to retrieve) */)
1266 LPSCROLLBAR_INFO infoPtr
;
1268 /* handle invalid data structure */
1269 if (!SCROLL_ScrollInfoValid(info
)
1270 || !(infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
)))
1273 /* fill in the desired scroll info structure */
1274 if (info
->fMask
& SIF_PAGE
) info
->nPage
= infoPtr
->page
;
1275 if (info
->fMask
& SIF_POS
) info
->nPos
= infoPtr
->curVal
;
1276 if ((info
->fMask
& SIF_TRACKPOS
) && (info
->cbSize
== sizeof(*info
)))
1277 info
->nTrackPos
= (SCROLL_TrackingWin
== WIN_GetFullHandle(hwnd
)) ? SCROLL_TrackingVal
: infoPtr
->curVal
;
1278 if (info
->fMask
& SIF_RANGE
)
1280 info
->nMin
= infoPtr
->minVal
;
1281 info
->nMax
= infoPtr
->maxVal
;
1284 return (info
->fMask
& SIF_ALL
) != 0;
1288 /*************************************************************************
1289 * SCROLL_GetScrollPos
1291 * Internal helper for the API function
1293 static INT
SCROLL_GetScrollPos(
1294 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1295 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1297 LPSCROLLBAR_INFO infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
);
1298 return infoPtr
? infoPtr
->curVal
: 0;
1302 /*************************************************************************
1303 * SCROLL_GetScrollRange
1305 * Internal helper for the API function
1309 static BOOL
SCROLL_GetScrollRange(
1310 HWND hwnd
, /* [in] Handle of window */
1311 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1312 LPINT lpMin
, /* [out] Where to store minimum value */
1313 LPINT lpMax
/* [out] Where to store maximum value */)
1315 LPSCROLLBAR_INFO infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
);
1317 if (lpMin
) *lpMin
= infoPtr
? infoPtr
->minVal
: 0;
1318 if (lpMax
) *lpMax
= infoPtr
? infoPtr
->maxVal
: 0;
1320 return infoPtr
? TRUE
: FALSE
;
1325 /***********************************************************************
1328 static LRESULT WINAPI
ScrollBarWndProc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1330 if (!IsWindow( hwnd
)) return 0;
1335 SCROLL_CreateScrollBar(hwnd
, (LPCREATESTRUCTW
)lParam
);
1336 if (!hUpArrow
) SCROLL_LoadBitmaps();
1341 SCROLLBAR_INFO
*infoPtr
;
1342 if ((infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, SB_CTL
)))
1344 infoPtr
->flags
= wParam
? ESB_ENABLE_BOTH
: ESB_DISABLE_BOTH
;
1345 SCROLL_RefreshScrollBar(hwnd
, SB_CTL
, TRUE
, TRUE
);
1350 case WM_LBUTTONDOWN
:
1353 pt
.x
= SLOWORD(lParam
);
1354 pt
.y
= SHIWORD(lParam
);
1355 SCROLL_TrackScrollBar( hwnd
, SB_CTL
, pt
);
1363 pt
.x
= SLOWORD(lParam
);
1364 pt
.y
= SHIWORD(lParam
);
1365 SCROLL_HandleScrollEvent( hwnd
, SB_CTL
, message
, pt
);
1370 SCROLL_HandleKbdEvent(hwnd
, wParam
, lParam
);
1379 /* Create a caret when a ScrollBar get focus */
1381 int arrowSize
, thumbSize
, thumbPos
, vertical
;
1382 vertical
= SCROLL_GetScrollBarRect( hwnd
, SB_CTL
, &rect
,
1383 &arrowSize
, &thumbSize
, &thumbPos
);
1386 CreateCaret(hwnd
, (HBITMAP
)1, thumbSize
-2, rect
.bottom
-rect
.top
-2);
1387 SetCaretPos(thumbPos
+1, rect
.top
+1);
1391 CreateCaret(hwnd
, (HBITMAP
)1, rect
.right
-rect
.left
-2,thumbSize
-2);
1392 SetCaretPos(rect
.top
+1, thumbPos
+1);
1401 int arrowSize
, thumbSize
, thumbPos
, vertical
;
1402 vertical
= SCROLL_GetScrollBarRect( hwnd
, SB_CTL
, &rect
,&arrowSize
, &thumbSize
, &thumbPos
);
1404 rect
.left
=thumbPos
+1;
1405 rect
.right
=rect
.left
+thumbSize
;
1409 rect
.top
=thumbPos
+1;
1410 rect
.bottom
=rect
.top
+thumbSize
;
1413 InvalidateRect(hwnd
,&rect
,0);
1422 return DLGC_WANTARROWS
; /* Windows returns this value */
1427 HDC hdc
= BeginPaint( hwnd
, &ps
);
1428 if (GetWindowLongW( hwnd
, GWL_STYLE
) & SBS_SIZEBOX
)
1429 FillRect( hdc
, &ps
.rcPaint
, GetSysColorBrush(COLOR_SCROLLBAR
) );
1431 SCROLL_DrawScrollBar( hwnd
, hdc
, SB_CTL
, TRUE
, TRUE
);
1432 EndPaint( hwnd
, &ps
);
1438 return SetScrollPos( hwnd
, SB_CTL
, wParam
, (BOOL
)lParam
);
1442 return SCROLL_GetScrollPos(hwnd
, SB_CTL
);
1444 case SBM_SETRANGE16
:
1445 SetScrollRange( hwnd
, SB_CTL
, LOWORD(lParam
), HIWORD(lParam
),
1446 wParam
/* FIXME: Is this correct? */ );
1451 INT oldPos
= SCROLL_GetScrollPos( hwnd
, SB_CTL
);
1452 SetScrollRange( hwnd
, SB_CTL
, wParam
, lParam
, FALSE
);
1453 if (oldPos
!= SCROLL_GetScrollPos( hwnd
, SB_CTL
)) return oldPos
;
1457 case SBM_GETRANGE16
:
1458 FIXME("don't know how to handle SBM_GETRANGE16 (wp=%04x,lp=%08lx)\n", wParam
, lParam
);
1462 return SCROLL_GetScrollRange(hwnd
, SB_CTL
, (LPINT
)wParam
, (LPINT
)lParam
);
1464 case SBM_ENABLE_ARROWS16
:
1465 case SBM_ENABLE_ARROWS
:
1466 return EnableScrollBar( hwnd
, SB_CTL
, wParam
);
1468 case SBM_SETRANGEREDRAW
:
1470 INT oldPos
= SCROLL_GetScrollPos( hwnd
, SB_CTL
);
1471 SetScrollRange( hwnd
, SB_CTL
, wParam
, lParam
, TRUE
);
1472 if (oldPos
!= SCROLL_GetScrollPos( hwnd
, SB_CTL
)) return oldPos
;
1476 case SBM_SETSCROLLINFO
:
1477 return SetScrollInfo( hwnd
, SB_CTL
, (SCROLLINFO
*)lParam
, wParam
);
1479 case SBM_GETSCROLLINFO
:
1480 return SCROLL_GetScrollInfo(hwnd
, SB_CTL
, (SCROLLINFO
*)lParam
);
1490 ERR("unknown Win32 msg %04x wp=%08x lp=%08lx\n",
1491 message
, wParam
, lParam
);
1495 if (message
>= WM_USER
)
1496 WARN("unknown msg %04x wp=%04x lp=%08lx\n",
1497 message
, wParam
, lParam
);
1498 return DefWindowProcW( hwnd
, message
, wParam
, lParam
);
1504 /*************************************************************************
1505 * SetScrollInfo (USER32.@)
1506 * SetScrollInfo can be used to set the position, upper bound,
1507 * lower bound, and page size of a scrollbar control.
1510 * Scrollbar position
1513 * For 100 lines of text to be displayed in a window of 25 lines,
1514 * one would for instance use info->nMin=0, info->nMax=75
1515 * (corresponding to the 76 different positions of the window on
1516 * the text), and info->nPage=25.
1518 INT WINAPI
SetScrollInfo(
1519 HWND hwnd
/* [in] Handle of window whose scrollbar will be affected */,
1520 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1521 const SCROLLINFO
*info
/* [in] Specifies what to change and new values */,
1522 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */)
1525 INT retVal
= SCROLL_SetScrollInfo( hwnd
, nBar
, info
, &action
);
1527 if( action
& SA_SSI_HIDE
)
1528 SCROLL_ShowScrollBar( hwnd
, nBar
, FALSE
, FALSE
);
1531 if( action
& SA_SSI_SHOW
)
1532 if( SCROLL_ShowScrollBar( hwnd
, nBar
, TRUE
, TRUE
) )
1533 return retVal
; /* SetWindowPos() already did the painting */
1535 if( bRedraw
&& (action
& SA_SSI_REFRESH
))
1536 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, TRUE
);
1537 else if( action
& SA_SSI_REPAINT_ARROWS
)
1538 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, FALSE
);
1543 INT
SCROLL_SetScrollInfo( HWND hwnd
, INT nBar
,
1544 const SCROLLINFO
*info
, INT
*action
)
1546 /* Update the scrollbar state and set action flags according to
1547 * what has to be done graphics wise. */
1549 SCROLLBAR_INFO
*infoPtr
;
1551 BOOL bChangeParams
= FALSE
; /* don't show/hide scrollbar if params don't change */
1555 if (!(infoPtr
= SCROLL_GetScrollBarInfo(hwnd
, nBar
))) return 0;
1556 if (info
->fMask
& ~(SIF_ALL
| SIF_DISABLENOSCROLL
)) return 0;
1557 if ((info
->cbSize
!= sizeof(*info
)) &&
1558 (info
->cbSize
!= sizeof(*info
)-sizeof(info
->nTrackPos
))) return 0;
1560 if (TRACE_ON(scroll
))
1562 TRACE("hwnd=%p bar=%d", hwnd
, nBar
);
1563 if (info
->fMask
& SIF_PAGE
) DPRINTF( " page=%d", info
->nPage
);
1564 if (info
->fMask
& SIF_POS
) DPRINTF( " pos=%d", info
->nPos
);
1565 if (info
->fMask
& SIF_RANGE
) DPRINTF( " min=%d max=%d", info
->nMin
, info
->nMax
);
1569 /* Set the page size */
1571 if (info
->fMask
& SIF_PAGE
)
1573 if( infoPtr
->page
!= info
->nPage
)
1575 infoPtr
->page
= info
->nPage
;
1576 *action
|= SA_SSI_REFRESH
;
1577 bChangeParams
= TRUE
;
1581 /* Set the scroll pos */
1583 if (info
->fMask
& SIF_POS
)
1585 if( infoPtr
->curVal
!= info
->nPos
)
1587 infoPtr
->curVal
= info
->nPos
;
1588 *action
|= SA_SSI_REFRESH
;
1592 /* Set the scroll range */
1594 if (info
->fMask
& SIF_RANGE
)
1596 /* Invalid range -> range is set to (0,0) */
1597 if ((info
->nMin
> info
->nMax
) ||
1598 ((UINT
)(info
->nMax
- info
->nMin
) >= 0x80000000))
1600 infoPtr
->minVal
= 0;
1601 infoPtr
->maxVal
= 0;
1602 bChangeParams
= TRUE
;
1606 if( infoPtr
->minVal
!= info
->nMin
||
1607 infoPtr
->maxVal
!= info
->nMax
)
1609 *action
|= SA_SSI_REFRESH
;
1610 infoPtr
->minVal
= info
->nMin
;
1611 infoPtr
->maxVal
= info
->nMax
;
1612 bChangeParams
= TRUE
;
1617 /* Make sure the page size is valid */
1619 if (infoPtr
->page
< 0) infoPtr
->page
= 0;
1620 else if (infoPtr
->page
> infoPtr
->maxVal
- infoPtr
->minVal
+ 1 )
1621 infoPtr
->page
= infoPtr
->maxVal
- infoPtr
->minVal
+ 1;
1623 /* Make sure the pos is inside the range */
1625 if (infoPtr
->curVal
< infoPtr
->minVal
)
1626 infoPtr
->curVal
= infoPtr
->minVal
;
1627 else if (infoPtr
->curVal
> infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 ))
1628 infoPtr
->curVal
= infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 );
1630 TRACE(" new values: page=%d pos=%d min=%d max=%d\n",
1631 infoPtr
->page
, infoPtr
->curVal
,
1632 infoPtr
->minVal
, infoPtr
->maxVal
);
1634 /* don't change the scrollbar state if SetScrollInfo
1635 * is just called with SIF_DISABLENOSCROLL
1637 if(!(info
->fMask
& SIF_ALL
)) goto done
;
1639 /* Check if the scrollbar should be hidden or disabled */
1641 if (info
->fMask
& (SIF_RANGE
| SIF_PAGE
| SIF_DISABLENOSCROLL
))
1643 new_flags
= infoPtr
->flags
;
1644 if (infoPtr
->minVal
>= infoPtr
->maxVal
- max( infoPtr
->page
-1, 0 ))
1646 /* Hide or disable scroll-bar */
1647 if (info
->fMask
& SIF_DISABLENOSCROLL
)
1649 new_flags
= ESB_DISABLE_BOTH
;
1650 *action
|= SA_SSI_REFRESH
;
1652 else if ((nBar
!= SB_CTL
) && bChangeParams
)
1654 *action
= SA_SSI_HIDE
;
1658 else /* Show and enable scroll-bar */
1661 if ((nBar
!= SB_CTL
) && bChangeParams
)
1662 *action
|= SA_SSI_SHOW
;
1665 if (infoPtr
->flags
!= new_flags
) /* check arrow flags */
1667 infoPtr
->flags
= new_flags
;
1668 *action
|= SA_SSI_REPAINT_ARROWS
;
1673 /* Return current position */
1675 return infoPtr
->curVal
;
1679 /*************************************************************************
1680 * GetScrollInfo (USER32.@)
1682 * GetScrollInfo can be used to retrieve the position, upper bound,
1683 * lower bound, and page size of a scrollbar control.
1687 BOOL WINAPI
GetScrollInfo(
1688 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1689 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1690 LPSCROLLINFO info
/* [in/out] (fMask specifies which values to retrieve) */)
1692 TRACE("hwnd=%p nBar=%d info=%p\n", hwnd
, nBar
, info
);
1694 /* Refer SB_CTL requests to the window */
1696 return SendMessageA(hwnd
, SBM_GETSCROLLINFO
, (WPARAM
)0, (LPARAM
)info
);
1698 return SCROLL_GetScrollInfo(hwnd
, nBar
, info
);
1702 /*************************************************************************
1703 * SetScrollPos (USER32.@)
1706 * Success: Scrollbar position
1710 * Note the ambiguity when 0 is returned. Use GetLastError
1711 * to make sure there was an error (and to know which one).
1713 INT WINAPI
SetScrollPos(
1714 HWND hwnd
/* [in] Handle of window whose scrollbar will be affected */,
1715 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1716 INT nPos
/* [in] New value */,
1717 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */ )
1720 SCROLLBAR_INFO
*infoPtr
;
1723 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
))) return 0;
1724 oldPos
= infoPtr
->curVal
;
1725 info
.cbSize
= sizeof(info
);
1727 info
.fMask
= SIF_POS
;
1728 SetScrollInfo( hwnd
, nBar
, &info
, bRedraw
);
1733 /*************************************************************************
1734 * GetScrollPos (USER32.@)
1737 * Success: Current position
1741 * There is ambiguity when 0 is returned. Use GetLastError
1742 * to make sure there was an error (and to know which one).
1744 INT WINAPI
GetScrollPos(
1745 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1746 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1748 TRACE("hwnd=%p nBar=%d\n", hwnd
, nBar
);
1750 /* Refer SB_CTL requests to the window */
1752 return SendMessageA(hwnd
, SBM_GETPOS
, (WPARAM
)0, (LPARAM
)0);
1754 return SCROLL_GetScrollPos(hwnd
, nBar
);
1758 /*************************************************************************
1759 * SetScrollRange (USER32.@)
1763 BOOL WINAPI
SetScrollRange(
1764 HWND hwnd
, /* [in] Handle of window whose scrollbar will be affected */
1765 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1766 INT minVal
, /* [in] New minimum value */
1767 INT maxVal
, /* [in] New maximum value */
1768 BOOL bRedraw
/* [in] Should scrollbar be redrawn afterwards ? */)
1772 info
.cbSize
= sizeof(info
);
1775 info
.fMask
= SIF_RANGE
;
1776 SetScrollInfo( hwnd
, nBar
, &info
, bRedraw
);
1781 /*************************************************************************
1782 * SCROLL_SetNCSbState
1784 * Updates both scrollbars at the same time. Used by MDI CalcChildScroll().
1786 INT
SCROLL_SetNCSbState(HWND hwnd
, int vMin
, int vMax
, int vPos
,
1787 int hMin
, int hMax
, int hPos
)
1790 SCROLLINFO vInfo
, hInfo
;
1792 vInfo
.cbSize
= hInfo
.cbSize
= sizeof(SCROLLINFO
);
1799 vInfo
.fMask
= hInfo
.fMask
= SIF_RANGE
| SIF_POS
;
1801 SCROLL_SetScrollInfo( hwnd
, SB_VERT
, &vInfo
, &vA
);
1802 SCROLL_SetScrollInfo( hwnd
, SB_HORZ
, &hInfo
, &hA
);
1804 if( !SCROLL_ShowScrollBar( hwnd
, SB_BOTH
,
1805 (hA
& SA_SSI_SHOW
),(vA
& SA_SSI_SHOW
) ) )
1807 /* SetWindowPos() wasn't called, just redraw the scrollbars if needed */
1808 if( vA
& SA_SSI_REFRESH
)
1809 SCROLL_RefreshScrollBar( hwnd
, SB_VERT
, FALSE
, TRUE
);
1811 if( hA
& SA_SSI_REFRESH
)
1812 SCROLL_RefreshScrollBar( hwnd
, SB_HORZ
, FALSE
, TRUE
);
1818 /*************************************************************************
1819 * GetScrollRange (USER32.@)
1823 BOOL WINAPI
GetScrollRange(
1824 HWND hwnd
/* [in] Handle of window with scrollbar(s) */,
1825 INT nBar
/* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1826 LPINT lpMin
/* [out] Where to store minimum value */,
1827 LPINT lpMax
/* [out] Where to store maximum value */)
1829 TRACE("hwnd=%p nBar=%d lpMin=%p lpMax=%p\n", hwnd
, nBar
, lpMin
, lpMax
);
1831 /* Refer SB_CTL requests to the window */
1833 return SendMessageA(hwnd
, SBM_GETRANGE
, (WPARAM
)lpMin
, (LPARAM
)lpMax
);
1835 return SCROLL_GetScrollRange(hwnd
, nBar
, lpMin
, lpMax
);
1839 /*************************************************************************
1840 * SCROLL_ShowScrollBar()
1842 * Back-end for ShowScrollBar(). Returns FALSE if no action was taken.
1844 BOOL
SCROLL_ShowScrollBar( HWND hwnd
, INT nBar
,
1845 BOOL fShowH
, BOOL fShowV
)
1847 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1849 TRACE("hwnd=%p bar=%d horz=%d, vert=%d\n", hwnd
, nBar
, fShowH
, fShowV
);
1854 ShowWindow( hwnd
, fShowH
? SW_SHOW
: SW_HIDE
);
1861 fShowH
= !(style
& WS_HSCROLL
);
1862 style
|= WS_HSCROLL
;
1866 fShowH
= (style
& WS_HSCROLL
);
1867 style
&= ~WS_HSCROLL
;
1869 if( nBar
== SB_HORZ
) {
1878 fShowV
= !(style
& WS_VSCROLL
);
1879 style
|= WS_VSCROLL
;
1883 fShowV
= (style
& WS_VSCROLL
);
1884 style
&= ~WS_VSCROLL
;
1886 if ( nBar
== SB_VERT
)
1891 return FALSE
; /* Nothing to do! */
1894 if( fShowH
|| fShowV
) /* frame has been changed, let the window redraw itself */
1896 WIN_SetStyle( hwnd
, style
);
1897 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
1898 | SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
1901 return FALSE
; /* no frame changes */
1905 /*************************************************************************
1906 * ShowScrollBar (USER32.@)
1910 BOOL WINAPI
ShowScrollBar(
1911 HWND hwnd
, /* [in] Handle of window whose scrollbar(s) will be affected */
1912 INT nBar
, /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */
1913 BOOL fShow
/* [in] TRUE = show, FALSE = hide */)
1915 SCROLL_ShowScrollBar( hwnd
, nBar
, (nBar
== SB_VERT
) ? 0 : fShow
,
1916 (nBar
== SB_HORZ
) ? 0 : fShow
);
1921 /*************************************************************************
1922 * EnableScrollBar (USER32.@)
1924 BOOL WINAPI
EnableScrollBar( HWND hwnd
, INT nBar
, UINT flags
)
1927 SCROLLBAR_INFO
*infoPtr
;
1929 TRACE("%p %d %d\n", hwnd
, nBar
, flags
);
1931 flags
&= ESB_DISABLE_BOTH
;
1933 if (nBar
== SB_BOTH
)
1935 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, SB_VERT
))) return FALSE
;
1936 if (!(bFineWithMe
= (infoPtr
->flags
== flags
)) )
1938 infoPtr
->flags
= flags
;
1939 SCROLL_RefreshScrollBar( hwnd
, SB_VERT
, TRUE
, TRUE
);
1946 if (!(infoPtr
= SCROLL_GetScrollBarInfo( hwnd
, nBar
))) return FALSE
;
1947 if (bFineWithMe
&& infoPtr
->flags
== flags
) return FALSE
;
1948 infoPtr
->flags
= flags
;
1950 SCROLL_RefreshScrollBar( hwnd
, nBar
, TRUE
, TRUE
);