- Implement CB_SETCURSEL, CBEM_DELETEITEM, CBEM_GETITEM,
[wine.git] / controls / scroll.c
blob2c739b87b65d3464092997a7becaf9cc6172f5be
1 /*
2 * Scrollbar control
4 * Copyright 1993 Martin Ayotte
5 * Copyright 1994, 1996 Alexandre Julliard
6 */
8 #include "windef.h"
9 #include "wingdi.h"
10 #include "wine/winuser16.h"
11 #include "controls.h"
12 #include "heap.h"
13 #include "win.h"
14 #include "debugtools.h"
15 #include "user.h"
17 DEFAULT_DEBUG_CHANNEL(scroll);
19 typedef struct
21 INT CurVal; /* Current scroll-bar value */
22 INT MinVal; /* Minimum scroll-bar value */
23 INT MaxVal; /* Maximum scroll-bar value */
24 INT Page; /* Page size of scroll bar (Win32) */
25 UINT flags; /* EnableScrollBar flags */
26 } SCROLLBAR_INFO;
29 static HBITMAP hUpArrow;
30 static HBITMAP hDnArrow;
31 static HBITMAP hLfArrow;
32 static HBITMAP hRgArrow;
33 static HBITMAP hUpArrowD;
34 static HBITMAP hDnArrowD;
35 static HBITMAP hLfArrowD;
36 static HBITMAP hRgArrowD;
37 static HBITMAP hUpArrowI;
38 static HBITMAP hDnArrowI;
39 static HBITMAP hLfArrowI;
40 static HBITMAP hRgArrowI;
42 #define TOP_ARROW(flags,pressed) \
43 (((flags)&ESB_DISABLE_UP) ? hUpArrowI : ((pressed) ? hUpArrowD:hUpArrow))
44 #define BOTTOM_ARROW(flags,pressed) \
45 (((flags)&ESB_DISABLE_DOWN) ? hDnArrowI : ((pressed) ? hDnArrowD:hDnArrow))
46 #define LEFT_ARROW(flags,pressed) \
47 (((flags)&ESB_DISABLE_LEFT) ? hLfArrowI : ((pressed) ? hLfArrowD:hLfArrow))
48 #define RIGHT_ARROW(flags,pressed) \
49 (((flags)&ESB_DISABLE_RIGHT) ? hRgArrowI : ((pressed) ? hRgArrowD:hRgArrow))
52 /* Minimum size of the rectangle between the arrows */
53 #define SCROLL_MIN_RECT 4
55 /* Minimum size of the thumb in pixels */
56 #define SCROLL_MIN_THUMB 6
58 /* Overlap between arrows and thumb */
59 #define SCROLL_ARROW_THUMB_OVERLAP ((TWEAK_WineLook == WIN31_LOOK) ? 1 : 0)
61 /* Delay (in ms) before first repetition when holding the button down */
62 #define SCROLL_FIRST_DELAY 200
64 /* Delay (in ms) between scroll repetitions */
65 #define SCROLL_REPEAT_DELAY 50
67 /* Scroll timer id */
68 #define SCROLL_TIMER 0
70 /* Scroll-bar hit testing */
71 enum SCROLL_HITTEST
73 SCROLL_NOWHERE, /* Outside the scroll bar */
74 SCROLL_TOP_ARROW, /* Top or left arrow */
75 SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
76 SCROLL_THUMB, /* Thumb rectangle */
77 SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
78 SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
81 /* What to do after SCROLL_SetScrollInfo() */
82 #define SA_SSI_HIDE 0x0001
83 #define SA_SSI_SHOW 0x0002
84 #define SA_SSI_REFRESH 0x0004
85 #define SA_SSI_REPAINT_ARROWS 0x0008
87 /* Thumb-tracking info */
88 static HWND SCROLL_TrackingWin = 0;
89 static INT SCROLL_TrackingBar = 0;
90 static INT SCROLL_TrackingPos = 0;
91 static INT SCROLL_TrackingVal = 0;
92 /* Hit test code of the last button-down event */
93 static enum SCROLL_HITTEST SCROLL_trackHitTest;
94 static BOOL SCROLL_trackVertical;
96 /* Is the moving thumb being displayed? */
97 static BOOL SCROLL_MovingThumb = FALSE;
99 /* Local functions */
100 static BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
101 BOOL fShowH, BOOL fShowV );
102 static INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar,
103 const SCROLLINFO *info, INT *action );
104 static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar,
105 RECT *rect, INT arrowSize,
106 INT thumbSize, INT thumbPos,
107 UINT flags, BOOL vertical,
108 BOOL top_selected, BOOL bottom_selected );
109 static LRESULT WINAPI ScrollBarWndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
112 /*********************************************************************
113 * scrollbar class descriptor
115 const struct builtin_class_descr SCROLL_builtin_class =
117 "ScrollBar", /* name */
118 CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC, /* style */
119 NULL, /* procA (winproc is Unicode only) */
120 ScrollBarWndProc, /* procW */
121 sizeof(SCROLLBAR_INFO), /* extra */
122 IDC_ARROWA, /* cursor */
123 0 /* brush */
127 /***********************************************************************
128 * SCROLL_LoadBitmaps
130 static void SCROLL_LoadBitmaps(void)
132 hUpArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROW) );
133 hDnArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROW) );
134 hLfArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROW) );
135 hRgArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROW) );
136 hUpArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWD) );
137 hDnArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWD) );
138 hLfArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWD) );
139 hRgArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWD) );
140 hUpArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWI) );
141 hDnArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWI) );
142 hLfArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWI) );
143 hRgArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWI) );
147 /***********************************************************************
148 * SCROLL_GetPtrScrollInfo
150 static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, INT nBar )
152 SCROLLBAR_INFO *infoPtr;
154 if (!wndPtr) return NULL;
155 switch(nBar)
157 case SB_HORZ: infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll; break;
158 case SB_VERT: infoPtr = (SCROLLBAR_INFO *)wndPtr->pVScroll; break;
159 case SB_CTL: infoPtr = (SCROLLBAR_INFO *)wndPtr->wExtra; break;
160 default: return NULL;
163 if (!infoPtr) /* Create the info structure if needed */
165 if ((infoPtr = HeapAlloc( SystemHeap, 0, sizeof(SCROLLBAR_INFO) )))
167 infoPtr->MinVal = infoPtr->CurVal = infoPtr->Page = 0;
168 infoPtr->MaxVal = 100;
169 infoPtr->flags = ESB_ENABLE_BOTH;
170 if (nBar == SB_HORZ) wndPtr->pHScroll = infoPtr;
171 else wndPtr->pVScroll = infoPtr;
173 if (!hUpArrow) SCROLL_LoadBitmaps();
175 return infoPtr;
179 /***********************************************************************
180 * SCROLL_GetScrollInfo
182 static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar )
184 SCROLLBAR_INFO *retvalue;
185 WND *wndPtr = WIN_FindWndPtr( hwnd );
186 retvalue = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
187 WIN_ReleaseWndPtr(wndPtr);
188 return retvalue;
192 /***********************************************************************
193 * SCROLL_GetScrollBarRect
195 * Compute the scroll bar rectangle, in drawing coordinates (i.e. client
196 * coords for SB_CTL, window coords for SB_VERT and SB_HORZ).
197 * 'arrowSize' returns the width or height of an arrow (depending on
198 * the orientation of the scrollbar), 'thumbSize' returns the size of
199 * the thumb, and 'thumbPos' returns the position of the thumb
200 * relative to the left or to the top.
201 * Return TRUE if the scrollbar is vertical, FALSE if horizontal.
203 static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
204 INT *arrowSize, INT *thumbSize,
205 INT *thumbPos )
207 INT pixels;
208 BOOL vertical;
209 WND *wndPtr = WIN_FindWndPtr( hwnd );
211 switch(nBar)
213 case SB_HORZ:
214 lprect->left = wndPtr->rectClient.left - wndPtr->rectWindow.left;
215 lprect->top = wndPtr->rectClient.bottom - wndPtr->rectWindow.top;
216 lprect->right = wndPtr->rectClient.right - wndPtr->rectWindow.left;
217 lprect->bottom = lprect->top + GetSystemMetrics(SM_CYHSCROLL);
218 if(wndPtr->dwStyle & WS_BORDER) {
219 lprect->left--;
220 lprect->right++;
221 } else if(wndPtr->dwStyle & WS_VSCROLL)
222 lprect->right++;
223 vertical = FALSE;
224 break;
226 case SB_VERT:
227 lprect->left = wndPtr->rectClient.right - wndPtr->rectWindow.left;
228 lprect->top = wndPtr->rectClient.top - wndPtr->rectWindow.top;
229 lprect->right = lprect->left + GetSystemMetrics(SM_CXVSCROLL);
230 lprect->bottom = wndPtr->rectClient.bottom - wndPtr->rectWindow.top;
231 if(wndPtr->dwStyle & WS_BORDER) {
232 lprect->top--;
233 lprect->bottom++;
234 } else if(wndPtr->dwStyle & WS_HSCROLL)
235 lprect->bottom++;
236 vertical = TRUE;
237 break;
239 case SB_CTL:
240 GetClientRect( hwnd, lprect );
241 vertical = ((wndPtr->dwStyle & SBS_VERT) != 0);
242 break;
244 default:
245 WIN_ReleaseWndPtr(wndPtr);
246 return FALSE;
249 if (vertical) pixels = lprect->bottom - lprect->top;
250 else pixels = lprect->right - lprect->left;
252 if (pixels <= 2*GetSystemMetrics(SM_CXVSCROLL) + SCROLL_MIN_RECT)
254 if (pixels > SCROLL_MIN_RECT)
255 *arrowSize = (pixels - SCROLL_MIN_RECT) / 2;
256 else
257 *arrowSize = 0;
258 *thumbPos = *thumbSize = 0;
260 else
262 SCROLLBAR_INFO *info = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
264 *arrowSize = GetSystemMetrics(SM_CXVSCROLL);
265 pixels -= (2 * (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP));
267 if (info->Page)
269 *thumbSize = pixels * info->Page / (info->MaxVal-info->MinVal+1);
270 if (*thumbSize < SCROLL_MIN_THUMB) *thumbSize = SCROLL_MIN_THUMB;
272 else *thumbSize = GetSystemMetrics(SM_CXVSCROLL);
274 if (((pixels -= *thumbSize ) < 0) ||
275 ((info->flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH))
277 /* Rectangle too small or scrollbar disabled -> no thumb */
278 *thumbPos = *thumbSize = 0;
280 else
282 INT max = info->MaxVal - max( info->Page-1, 0 );
283 if (info->MinVal >= max)
284 *thumbPos = *arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
285 else
286 *thumbPos = *arrowSize - SCROLL_ARROW_THUMB_OVERLAP
287 + pixels * (info->CurVal-info->MinVal) / (max - info->MinVal);
290 WIN_ReleaseWndPtr(wndPtr);
291 return vertical;
295 /***********************************************************************
296 * SCROLL_GetThumbVal
298 * Compute the current scroll position based on the thumb position in pixels
299 * from the top of the scroll-bar.
301 static UINT SCROLL_GetThumbVal( SCROLLBAR_INFO *infoPtr, RECT *rect,
302 BOOL vertical, INT pos )
304 INT thumbSize;
305 INT pixels = vertical ? rect->bottom-rect->top : rect->right-rect->left;
307 if ((pixels -= 2*(GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP)) <= 0)
308 return infoPtr->MinVal;
310 if (infoPtr->Page)
312 thumbSize = pixels * infoPtr->Page/(infoPtr->MaxVal-infoPtr->MinVal+1);
313 if (thumbSize < SCROLL_MIN_THUMB) thumbSize = SCROLL_MIN_THUMB;
315 else thumbSize = GetSystemMetrics(SM_CXVSCROLL);
317 if ((pixels -= thumbSize) <= 0) return infoPtr->MinVal;
319 pos = max( 0, pos - (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP) );
320 if (pos > pixels) pos = pixels;
322 if (!infoPtr->Page) pos *= infoPtr->MaxVal - infoPtr->MinVal;
323 else pos *= infoPtr->MaxVal - infoPtr->MinVal - infoPtr->Page + 1;
324 return infoPtr->MinVal + ((pos + pixels / 2) / pixels);
327 /***********************************************************************
328 * SCROLL_PtInRectEx
330 static BOOL SCROLL_PtInRectEx( LPRECT lpRect, POINT pt, BOOL vertical )
332 RECT rect = *lpRect;
334 if (vertical)
336 rect.left -= lpRect->right - lpRect->left;
337 rect.right += lpRect->right - lpRect->left;
339 else
341 rect.top -= lpRect->bottom - lpRect->top;
342 rect.bottom += lpRect->bottom - lpRect->top;
344 return PtInRect( &rect, pt );
347 /***********************************************************************
348 * SCROLL_ClipPos
350 static POINT SCROLL_ClipPos( LPRECT lpRect, POINT pt )
352 if( pt.x < lpRect->left )
353 pt.x = lpRect->left;
354 else
355 if( pt.x > lpRect->right )
356 pt.x = lpRect->right;
358 if( pt.y < lpRect->top )
359 pt.y = lpRect->top;
360 else
361 if( pt.y > lpRect->bottom )
362 pt.y = lpRect->bottom;
364 return pt;
368 /***********************************************************************
369 * SCROLL_HitTest
371 * Scroll-bar hit testing (don't confuse this with WM_NCHITTEST!).
373 static enum SCROLL_HITTEST SCROLL_HitTest( HWND hwnd, INT nBar,
374 POINT pt, BOOL bDragging )
376 INT arrowSize, thumbSize, thumbPos;
377 RECT rect;
379 BOOL vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
380 &arrowSize, &thumbSize, &thumbPos );
382 if ( (bDragging && !SCROLL_PtInRectEx( &rect, pt, vertical )) ||
383 (!PtInRect( &rect, pt )) ) return SCROLL_NOWHERE;
385 if (vertical)
387 if (pt.y < rect.top + arrowSize) return SCROLL_TOP_ARROW;
388 if (pt.y >= rect.bottom - arrowSize) return SCROLL_BOTTOM_ARROW;
389 if (!thumbPos) return SCROLL_TOP_RECT;
390 pt.y -= rect.top;
391 if (pt.y < thumbPos) return SCROLL_TOP_RECT;
392 if (pt.y >= thumbPos + thumbSize) return SCROLL_BOTTOM_RECT;
394 else /* horizontal */
396 if (pt.x < rect.left + arrowSize) return SCROLL_TOP_ARROW;
397 if (pt.x >= rect.right - arrowSize) return SCROLL_BOTTOM_ARROW;
398 if (!thumbPos) return SCROLL_TOP_RECT;
399 pt.x -= rect.left;
400 if (pt.x < thumbPos) return SCROLL_TOP_RECT;
401 if (pt.x >= thumbPos + thumbSize) return SCROLL_BOTTOM_RECT;
403 return SCROLL_THUMB;
407 /***********************************************************************
408 * SCROLL_DrawArrows
410 * Draw the scroll bar arrows.
412 static void SCROLL_DrawArrows_9x( HDC hdc, SCROLLBAR_INFO *infoPtr,
413 RECT *rect, INT arrowSize, BOOL vertical,
414 BOOL top_pressed, BOOL bottom_pressed )
416 RECT r;
418 r = *rect;
419 if( vertical )
420 r.bottom = r.top + arrowSize;
421 else
422 r.right = r.left + arrowSize;
424 DrawFrameControl( hdc, &r, DFC_SCROLL,
425 (vertical ? DFCS_SCROLLUP : DFCS_SCROLLLEFT)
426 | (top_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
427 | (infoPtr->flags&ESB_DISABLE_LTUP ? DFCS_INACTIVE : 0 ) );
429 r = *rect;
430 if( vertical )
431 r.top = r.bottom-arrowSize;
432 else
433 r.left = r.right-arrowSize;
435 DrawFrameControl( hdc, &r, DFC_SCROLL,
436 (vertical ? DFCS_SCROLLDOWN : DFCS_SCROLLRIGHT)
437 | (bottom_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
438 | (infoPtr->flags&ESB_DISABLE_RTDN ? DFCS_INACTIVE : 0) );
441 static void SCROLL_DrawArrows_31( HDC hdc, SCROLLBAR_INFO *infoPtr,
442 RECT *rect, INT arrowSize, BOOL vertical,
443 BOOL top_pressed, BOOL bottom_pressed )
445 HDC hdcMem = CreateCompatibleDC( hdc );
446 HBITMAP hbmpPrev = SelectObject( hdcMem, vertical ?
447 TOP_ARROW(infoPtr->flags, top_pressed)
448 : LEFT_ARROW(infoPtr->flags, top_pressed));
450 SetStretchBltMode( hdc, STRETCH_DELETESCANS );
451 StretchBlt( hdc, rect->left, rect->top,
452 vertical ? rect->right-rect->left : arrowSize,
453 vertical ? arrowSize : rect->bottom-rect->top,
454 hdcMem, 0, 0,
455 GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL),
456 SRCCOPY );
458 SelectObject( hdcMem, vertical ?
459 BOTTOM_ARROW( infoPtr->flags, bottom_pressed )
460 : RIGHT_ARROW( infoPtr->flags, bottom_pressed ) );
461 if (vertical)
462 StretchBlt( hdc, rect->left, rect->bottom - arrowSize,
463 rect->right - rect->left, arrowSize,
464 hdcMem, 0, 0,
465 GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL),
466 SRCCOPY );
467 else
468 StretchBlt( hdc, rect->right - arrowSize, rect->top,
469 arrowSize, rect->bottom - rect->top,
470 hdcMem, 0, 0,
471 GetSystemMetrics(SM_CXVSCROLL), GetSystemMetrics(SM_CYHSCROLL),
472 SRCCOPY );
473 SelectObject( hdcMem, hbmpPrev );
474 DeleteDC( hdcMem );
477 static void SCROLL_DrawArrows( HDC hdc, SCROLLBAR_INFO *infoPtr,
478 RECT *rect, INT arrowSize, BOOL vertical,
479 BOOL top_pressed, BOOL bottom_pressed )
481 if( TWEAK_WineLook == WIN31_LOOK )
482 SCROLL_DrawArrows_31( hdc, infoPtr, rect, arrowSize,
483 vertical, top_pressed,bottom_pressed );
484 else
485 SCROLL_DrawArrows_9x( hdc, infoPtr, rect, arrowSize,
486 vertical, top_pressed,bottom_pressed );
490 /***********************************************************************
491 * SCROLL_DrawMovingThumb
493 * Draw the moving thumb rectangle.
495 static void SCROLL_DrawMovingThumb_31( HDC hdc, RECT *rect, BOOL vertical,
496 INT arrowSize, INT thumbSize )
498 RECT r = *rect;
499 if (vertical)
501 r.top += SCROLL_TrackingPos;
502 if (r.top < rect->top + arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
503 r.top = rect->top + arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
504 if (r.top + thumbSize >
505 rect->bottom - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP))
506 r.top = rect->bottom - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
507 - thumbSize;
508 r.bottom = r.top + thumbSize;
510 else
512 r.left += SCROLL_TrackingPos;
513 if (r.left < rect->left + arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
514 r.left = rect->left + arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
515 if (r.left + thumbSize >
516 rect->right - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP))
517 r.left = rect->right - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
518 - thumbSize;
519 r.right = r.left + thumbSize;
522 DrawFocusRect( hdc, &r );
523 SCROLL_MovingThumb = !SCROLL_MovingThumb;
526 static void SCROLL_DrawMovingThumb_9x( HDC hdc, RECT *rect, BOOL vertical,
527 INT arrowSize, INT thumbSize )
529 INT pos = SCROLL_TrackingPos;
530 INT max_size;
532 if( vertical )
533 max_size = rect->bottom - rect->top;
534 else
535 max_size = rect->right - rect->left;
537 max_size -= (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) + thumbSize;
539 if( pos < (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) )
540 pos = (arrowSize-SCROLL_ARROW_THUMB_OVERLAP);
541 else if( pos > max_size )
542 pos = max_size;
544 SCROLL_DrawInterior_9x( SCROLL_TrackingWin, hdc, SCROLL_TrackingBar,
545 rect, arrowSize, thumbSize, pos,
546 0, vertical, FALSE, FALSE );
548 SCROLL_MovingThumb = !SCROLL_MovingThumb;
551 static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical,
552 INT arrowSize, INT thumbSize )
554 if( TWEAK_WineLook == WIN31_LOOK )
555 SCROLL_DrawMovingThumb_31( hdc, rect, vertical, arrowSize, thumbSize );
556 else
557 SCROLL_DrawMovingThumb_9x( hdc, rect, vertical, arrowSize, thumbSize );
560 /***********************************************************************
561 * SCROLL_DrawInterior
563 * Draw the scroll bar interior (everything except the arrows).
565 static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar,
566 RECT *rect, INT arrowSize,
567 INT thumbSize, INT thumbPos,
568 UINT flags, BOOL vertical,
569 BOOL top_selected, BOOL bottom_selected )
571 RECT r;
572 HPEN hSavePen;
573 HBRUSH hSaveBrush,hBrush;
575 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
576 * The window-owned scrollbars need to call DEFWND_ControlColor
577 * to correctly setup default scrollbar colors
579 if (nBar == SB_CTL)
581 hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
582 (WPARAM)hdc,(LPARAM)hwnd);
584 else
586 hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
589 hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
590 hSaveBrush = SelectObject( hdc, hBrush );
592 /* Calculate the scroll rectangle */
593 r = *rect;
594 if (vertical)
596 r.top += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
597 r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
599 else
601 r.left += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
602 r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
605 /* Draw the scroll rectangles and thumb */
606 if (!thumbPos) /* No thumb to draw */
608 PatBlt( hdc, r.left, r.top,
609 r.right - r.left, r.bottom - r.top,
610 PATCOPY );
612 /* cleanup and return */
613 SelectObject( hdc, hSavePen );
614 SelectObject( hdc, hSaveBrush );
615 return;
618 if (vertical)
620 PatBlt( hdc, r.left, r.top,
621 r.right - r.left,
622 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
623 top_selected ? 0x0f0000 : PATCOPY );
624 r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
625 PatBlt( hdc, r.left, r.top + thumbSize,
626 r.right - r.left,
627 r.bottom - r.top - thumbSize,
628 bottom_selected ? 0x0f0000 : PATCOPY );
629 r.bottom = r.top + thumbSize;
631 else /* horizontal */
633 PatBlt( hdc, r.left, r.top,
634 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
635 r.bottom - r.top,
636 top_selected ? 0x0f0000 : PATCOPY );
637 r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
638 PatBlt( hdc, r.left + thumbSize, r.top,
639 r.right - r.left - thumbSize,
640 r.bottom - r.top,
641 bottom_selected ? 0x0f0000 : PATCOPY );
642 r.right = r.left + thumbSize;
645 /* Draw the thumb */
646 DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT | BF_MIDDLE );
648 /* cleanup */
649 SelectObject( hdc, hSavePen );
650 SelectObject( hdc, hSaveBrush );
654 static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar,
655 RECT *rect, INT arrowSize,
656 INT thumbSize, INT thumbPos,
657 UINT flags, BOOL vertical,
658 BOOL top_selected, BOOL bottom_selected )
660 RECT r;
661 HPEN hSavePen;
662 HBRUSH hSaveBrush,hBrush;
663 BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
665 if (Save_SCROLL_MovingThumb &&
666 (SCROLL_TrackingWin == hwnd) &&
667 (SCROLL_TrackingBar == nBar))
668 SCROLL_DrawMovingThumb( hdc, rect, vertical, arrowSize, thumbSize );
670 /* Select the correct brush and pen */
672 if (TWEAK_WineLook == WIN31_LOOK && (flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH)
674 /* This ought to be the color of the parent window */
675 hBrush = GetSysColorBrush(COLOR_WINDOW);
677 else
679 /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
680 * The window-owned scrollbars need to call DEFWND_ControlColor
681 * to correctly setup default scrollbar colors
683 if (nBar == SB_CTL) {
684 hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
685 (WPARAM)hdc,(LPARAM)hwnd);
686 } else {
687 hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
690 hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
691 hSaveBrush = SelectObject( hdc, hBrush );
693 /* Calculate the scroll rectangle */
695 r = *rect;
696 if (vertical)
698 r.top += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
699 r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
701 else
703 r.left += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
704 r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
707 /* Draw the scroll bar frame */
709 /* Only draw outline if Win 3.1. Mar 24, 1999 - Ronald B. Cemer */
710 if (TWEAK_WineLook == WIN31_LOOK)
711 Rectangle( hdc, r.left, r.top, r.right, r.bottom );
713 /* Draw the scroll rectangles and thumb */
715 if (!thumbPos) /* No thumb to draw */
717 INT offset = (TWEAK_WineLook > WIN31_LOOK) ? 0 : 1;
719 PatBlt( hdc, r.left+offset, r.top+offset,
720 r.right - r.left - 2*offset, r.bottom - r.top - 2*offset,
721 PATCOPY );
723 /* cleanup and return */
724 SelectObject( hdc, hSavePen );
725 SelectObject( hdc, hSaveBrush );
726 return;
729 if (vertical)
731 INT offset = (TWEAK_WineLook == WIN31_LOOK) ? 1 : 0;
733 PatBlt( hdc, r.left + offset, r.top + offset,
734 r.right - r.left - offset*2,
735 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - offset,
736 top_selected ? 0x0f0000 : PATCOPY );
737 r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
738 PatBlt( hdc, r.left + offset, r.top + thumbSize,
739 r.right - r.left - offset*2,
740 r.bottom - r.top - thumbSize - offset,
741 bottom_selected ? 0x0f0000 : PATCOPY );
742 r.bottom = r.top + thumbSize;
744 else /* horizontal */
746 INT offset = (TWEAK_WineLook == WIN31_LOOK) ? 1 : 0;
748 PatBlt( hdc, r.left + offset, r.top + offset,
749 thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
750 r.bottom - r.top - offset*2,
751 top_selected ? 0x0f0000 : PATCOPY );
752 r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
753 PatBlt( hdc, r.left + thumbSize, r.top + offset,
754 r.right - r.left - thumbSize - offset,
755 r.bottom - r.top - offset*2,
756 bottom_selected ? 0x0f0000 : PATCOPY );
757 r.right = r.left + thumbSize;
760 /* Draw the thumb */
762 SelectObject( hdc, GetSysColorBrush(COLOR_BTNFACE) );
763 if (TWEAK_WineLook == WIN31_LOOK)
765 Rectangle( hdc, r.left, r.top, r.right, r.bottom );
766 r.top++, r.left++;
768 else
770 Rectangle( hdc, r.left+1, r.top+1, r.right-1, r.bottom-1 );
772 DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT );
774 if (Save_SCROLL_MovingThumb &&
775 (SCROLL_TrackingWin == hwnd) &&
776 (SCROLL_TrackingBar == nBar))
777 SCROLL_DrawMovingThumb( hdc, rect, vertical, arrowSize, thumbSize );
779 /* cleanup */
780 SelectObject( hdc, hSavePen );
781 SelectObject( hdc, hSaveBrush );
785 /***********************************************************************
786 * SCROLL_DrawScrollBar
788 * Redraw the whole scrollbar.
790 void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
791 BOOL arrows, BOOL interior )
793 INT arrowSize, thumbSize, thumbPos;
794 RECT rect;
795 BOOL vertical;
796 WND *wndPtr = WIN_FindWndPtr( hwnd );
797 SCROLLBAR_INFO *infoPtr = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
798 BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
800 if (!wndPtr || !infoPtr ||
801 ((nBar == SB_VERT) && !(wndPtr->dwStyle & WS_VSCROLL)) ||
802 ((nBar == SB_HORZ) && !(wndPtr->dwStyle & WS_HSCROLL))) goto END;
803 if (!WIN_IsWindowDrawable( wndPtr, FALSE )) goto END;
805 vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
806 &arrowSize, &thumbSize, &thumbPos );
808 /* do not draw if the scrollbar rectangle is empty */
809 if(IsRectEmpty(&rect))
810 goto END;
812 if (Save_SCROLL_MovingThumb &&
813 (SCROLL_TrackingWin == hwnd) &&
814 (SCROLL_TrackingBar == nBar))
815 SCROLL_DrawMovingThumb( hdc, &rect, vertical, arrowSize, thumbSize );
817 /* Draw the arrows */
819 if (arrows && arrowSize)
821 if( vertical == SCROLL_trackVertical && GetCapture() == hwnd )
822 SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
823 (SCROLL_trackHitTest == SCROLL_TOP_ARROW),
824 (SCROLL_trackHitTest == SCROLL_BOTTOM_ARROW) );
825 else
826 SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
827 FALSE, FALSE );
829 if( interior )
830 SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
831 thumbPos, infoPtr->flags, vertical, FALSE, FALSE );
833 if (Save_SCROLL_MovingThumb &&
834 (SCROLL_TrackingWin == hwnd) &&
835 (SCROLL_TrackingBar == nBar))
836 SCROLL_DrawMovingThumb( hdc, &rect, vertical, arrowSize, thumbSize );
838 /* if scroll bar has focus, reposition the caret*/
839 if(hwnd==GetFocus() && (nBar==SB_CTL))
841 if (!vertical)
843 SetCaretPos(thumbPos+1, rect.top+1);
845 else
847 SetCaretPos(rect.top+1, thumbPos+1);
851 END:
852 WIN_ReleaseWndPtr(wndPtr);
856 /***********************************************************************
857 * SCROLL_RefreshScrollBar
859 * Repaint the scroll bar interior after a SetScrollRange() or
860 * SetScrollPos() call.
862 static void SCROLL_RefreshScrollBar( HWND hwnd, INT nBar,
863 BOOL arrows, BOOL interior )
865 HDC hdc = GetDCEx( hwnd, 0,
866 DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) );
867 if (!hdc) return;
869 SCROLL_DrawScrollBar( hwnd, hdc, nBar, arrows, interior );
870 ReleaseDC( hwnd, hdc );
874 /***********************************************************************
875 * SCROLL_HandleKbdEvent
877 * Handle a keyboard event (only for SB_CTL scrollbars).
879 static void SCROLL_HandleKbdEvent( HWND hwnd, WPARAM wParam )
881 WND *wndPtr = WIN_FindWndPtr( hwnd );
882 WPARAM msg;
884 switch(wParam)
886 case VK_PRIOR: msg = SB_PAGEUP; break;
887 case VK_NEXT: msg = SB_PAGEDOWN; break;
888 case VK_HOME: msg = SB_TOP; break;
889 case VK_END: msg = SB_BOTTOM; break;
890 case VK_UP: msg = SB_LINEUP; break;
891 case VK_DOWN: msg = SB_LINEDOWN; break;
892 default:
893 WIN_ReleaseWndPtr(wndPtr);
894 return;
896 SendMessageW( GetParent(hwnd),
897 (wndPtr->dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL,
898 msg, hwnd );
899 WIN_ReleaseWndPtr(wndPtr);
903 /***********************************************************************
904 * SCROLL_HandleScrollEvent
906 * Handle a mouse or timer event for the scrollbar.
907 * 'pt' is the location of the mouse event in client (for SB_CTL) or
908 * windows coordinates.
910 void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
912 /* Previous mouse position for timer events */
913 static POINT prevPt;
914 /* Thumb position when tracking started. */
915 static UINT trackThumbPos;
916 /* Position in the scroll-bar of the last button-down event. */
917 static INT lastClickPos;
918 /* Position in the scroll-bar of the last mouse event. */
919 static INT lastMousePos;
921 enum SCROLL_HITTEST hittest;
922 HWND hwndOwner, hwndCtl;
923 BOOL vertical;
924 INT arrowSize, thumbSize, thumbPos;
925 RECT rect;
926 HDC hdc;
928 SCROLLBAR_INFO *infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
929 if (!infoPtr) return;
930 if ((SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN))
931 return;
933 hdc = GetDCEx( hwnd, 0, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
934 vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
935 &arrowSize, &thumbSize, &thumbPos );
936 hwndOwner = (nBar == SB_CTL) ? GetParent(hwnd) : hwnd;
937 hwndCtl = (nBar == SB_CTL) ? hwnd : 0;
939 switch(msg)
941 case WM_LBUTTONDOWN: /* Initialise mouse tracking */
942 HideCaret(hwnd); /* hide caret while holding down LBUTTON*/
943 SCROLL_trackVertical = vertical;
944 SCROLL_trackHitTest = hittest = SCROLL_HitTest( hwnd, nBar, pt, FALSE );
945 lastClickPos = vertical ? (pt.y - rect.top) : (pt.x - rect.left);
946 lastMousePos = lastClickPos;
947 trackThumbPos = thumbPos;
948 prevPt = pt;
949 SetCapture( hwnd );
950 if (nBar == SB_CTL && (GetWindowLongA(hwnd, GWL_STYLE) & WS_TABSTOP)) SetFocus( hwnd );
951 break;
953 case WM_MOUSEMOVE:
954 hittest = SCROLL_HitTest( hwnd, nBar, pt, TRUE );
955 prevPt = pt;
956 break;
958 case WM_LBUTTONUP:
959 hittest = SCROLL_NOWHERE;
960 ReleaseCapture();
961 /* if scrollbar has focus, show back caret */
962 if (hwnd==GetFocus()) ShowCaret(hwnd);
963 break;
965 case WM_SYSTIMER:
966 pt = prevPt;
967 hittest = SCROLL_HitTest( hwnd, nBar, pt, FALSE );
968 break;
970 default:
971 return; /* Should never happen */
974 TRACE("Event: hwnd=%04x bar=%d msg=%x pt=%ld,%ld hit=%d\n",
975 hwnd, nBar, msg, pt.x, pt.y, hittest );
977 switch(SCROLL_trackHitTest)
979 case SCROLL_NOWHERE: /* No tracking in progress */
980 break;
982 case SCROLL_TOP_ARROW:
983 SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
984 (hittest == SCROLL_trackHitTest), FALSE );
985 if (hittest == SCROLL_trackHitTest)
987 if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
989 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
990 SB_LINEUP, hwndCtl );
993 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
994 SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
995 (TIMERPROC)0 );
997 else KillSystemTimer( hwnd, SCROLL_TIMER );
998 break;
1000 case SCROLL_TOP_RECT:
1001 SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
1002 thumbPos, infoPtr->flags, vertical,
1003 (hittest == SCROLL_trackHitTest), FALSE );
1004 if (hittest == SCROLL_trackHitTest)
1006 if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
1008 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
1009 SB_PAGEUP, hwndCtl );
1010 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
1011 SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
1012 (TIMERPROC)0 );
1015 else KillSystemTimer( hwnd, SCROLL_TIMER );
1016 break;
1018 case SCROLL_THUMB:
1019 if (msg == WM_LBUTTONDOWN)
1021 SCROLL_TrackingWin = hwnd;
1022 SCROLL_TrackingBar = nBar;
1023 SCROLL_TrackingPos = trackThumbPos + lastMousePos - lastClickPos;
1024 if (!SCROLL_MovingThumb)
1025 SCROLL_DrawMovingThumb(hdc, &rect, vertical, arrowSize, thumbSize);
1027 else if (msg == WM_LBUTTONUP)
1029 if (SCROLL_MovingThumb)
1030 SCROLL_DrawMovingThumb(hdc, &rect, vertical, arrowSize, thumbSize);
1031 SCROLL_TrackingWin = 0;
1032 SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
1033 thumbPos, infoPtr->flags, vertical,
1034 FALSE, FALSE );
1036 else /* WM_MOUSEMOVE */
1038 UINT pos;
1040 if (!SCROLL_PtInRectEx( &rect, pt, vertical )) pos = lastClickPos;
1041 else
1043 pt = SCROLL_ClipPos( &rect, pt );
1044 pos = vertical ? (pt.y - rect.top) : (pt.x - rect.left);
1046 if ( (pos != lastMousePos) || (!SCROLL_MovingThumb) )
1048 if (SCROLL_MovingThumb)
1049 SCROLL_DrawMovingThumb( hdc, &rect, vertical,
1050 arrowSize, thumbSize );
1051 lastMousePos = pos;
1052 SCROLL_TrackingPos = trackThumbPos + pos - lastClickPos;
1053 SCROLL_TrackingVal = SCROLL_GetThumbVal( infoPtr, &rect,
1054 vertical,
1055 SCROLL_TrackingPos );
1056 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
1057 MAKEWPARAM( SB_THUMBTRACK, SCROLL_TrackingVal),
1058 hwndCtl );
1059 if (!SCROLL_MovingThumb)
1060 SCROLL_DrawMovingThumb( hdc, &rect, vertical,
1061 arrowSize, thumbSize );
1064 break;
1066 case SCROLL_BOTTOM_RECT:
1067 SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
1068 thumbPos, infoPtr->flags, vertical,
1069 FALSE, (hittest == SCROLL_trackHitTest) );
1070 if (hittest == SCROLL_trackHitTest)
1072 if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
1074 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
1075 SB_PAGEDOWN, hwndCtl );
1076 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
1077 SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
1078 (TIMERPROC)0 );
1081 else KillSystemTimer( hwnd, SCROLL_TIMER );
1082 break;
1084 case SCROLL_BOTTOM_ARROW:
1085 SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
1086 FALSE, (hittest == SCROLL_trackHitTest) );
1087 if (hittest == SCROLL_trackHitTest)
1089 if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
1091 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
1092 SB_LINEDOWN, hwndCtl );
1095 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
1096 SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
1097 (TIMERPROC)0 );
1099 else KillSystemTimer( hwnd, SCROLL_TIMER );
1100 break;
1103 if (msg == WM_LBUTTONUP)
1105 hittest = SCROLL_trackHitTest;
1106 SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */
1108 if (hittest == SCROLL_THUMB)
1110 UINT val = SCROLL_GetThumbVal( infoPtr, &rect, vertical,
1111 trackThumbPos + lastMousePos - lastClickPos );
1112 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
1113 MAKEWPARAM( SB_THUMBPOSITION, val ), hwndCtl );
1115 else
1116 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
1117 SB_ENDSCROLL, hwndCtl );
1120 ReleaseDC( hwnd, hdc );
1124 /***********************************************************************
1125 * ScrollBarWndProc
1127 static LRESULT WINAPI ScrollBarWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
1129 switch(message)
1131 case WM_CREATE:
1133 CREATESTRUCTW *lpCreat = (CREATESTRUCTW *)lParam;
1134 if (lpCreat->style & SBS_SIZEBOX)
1136 FIXME("Unimplemented style SBS_SIZEBOX.\n" );
1137 return 0;
1139 if (lpCreat->style & SBS_VERT)
1141 if (lpCreat->style & SBS_LEFTALIGN)
1142 MoveWindow( hwnd, lpCreat->x, lpCreat->y,
1143 GetSystemMetrics(SM_CXVSCROLL)+1, lpCreat->cy, FALSE );
1144 else if (lpCreat->style & SBS_RIGHTALIGN)
1145 MoveWindow( hwnd,
1146 lpCreat->x+lpCreat->cx-GetSystemMetrics(SM_CXVSCROLL)-1,
1147 lpCreat->y,
1148 GetSystemMetrics(SM_CXVSCROLL)+1, lpCreat->cy, FALSE );
1150 else /* SBS_HORZ */
1152 if (lpCreat->style & SBS_TOPALIGN)
1153 MoveWindow( hwnd, lpCreat->x, lpCreat->y,
1154 lpCreat->cx, GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
1155 else if (lpCreat->style & SBS_BOTTOMALIGN)
1156 MoveWindow( hwnd,
1157 lpCreat->x,
1158 lpCreat->y+lpCreat->cy-GetSystemMetrics(SM_CYHSCROLL)-1,
1159 lpCreat->cx, GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
1162 if (!hUpArrow) SCROLL_LoadBitmaps();
1163 TRACE("ScrollBar creation, hwnd=%04x\n", hwnd );
1164 return 0;
1166 case WM_LBUTTONDOWN:
1167 case WM_LBUTTONUP:
1168 case WM_MOUSEMOVE:
1169 case WM_SYSTIMER:
1171 POINT pt;
1172 pt.x = SLOWORD(lParam);
1173 pt.y = SHIWORD(lParam);
1174 SCROLL_HandleScrollEvent( hwnd, SB_CTL, message, pt );
1176 break;
1178 /* if key event is received, the scrollbar has the focus*/
1179 case WM_KEYDOWN:
1180 /* hide caret on first KEYDOWN to prevent flicker */
1181 if ((lParam & 0x40000000)==0)
1182 HideCaret(hwnd);
1183 SCROLL_HandleKbdEvent( hwnd, wParam );
1184 break;
1186 case WM_KEYUP:
1187 ShowCaret(hwnd);
1188 break;
1190 case WM_SETFOCUS:
1192 /* Create a caret when a ScrollBar get focus*/
1193 RECT rect;
1194 int arrowSize, thumbSize, thumbPos, vertical;
1195 vertical = SCROLL_GetScrollBarRect( hwnd, SB_CTL, &rect,
1196 &arrowSize, &thumbSize, &thumbPos );
1197 if (!vertical)
1199 CreateCaret(hwnd,1, thumbSize-2, rect.bottom-rect.top-2);
1200 SetCaretPos(thumbPos+1, rect.top+1);
1202 else
1204 CreateCaret(hwnd,1, rect.right-rect.left-2,thumbSize-2);
1205 SetCaretPos(rect.top+1, thumbPos+1);
1207 ShowCaret(hwnd);
1209 break;
1211 case WM_KILLFOCUS:
1213 RECT rect;
1214 int arrowSize, thumbSize, thumbPos, vertical;
1215 vertical = SCROLL_GetScrollBarRect( hwnd, SB_CTL, &rect,&arrowSize, &thumbSize, &thumbPos );
1216 if (!vertical){
1217 rect.left=thumbPos+1;
1218 rect.right=rect.left+thumbSize;
1220 else
1222 rect.top=thumbPos+1;
1223 rect.bottom=rect.top+thumbSize;
1225 HideCaret(hwnd);
1226 InvalidateRect(hwnd,&rect,0);
1227 DestroyCaret();
1229 break;
1231 case WM_ERASEBKGND:
1232 return 1;
1234 case WM_GETDLGCODE:
1235 return DLGC_WANTARROWS; /* Windows returns this value */
1237 case WM_PAINT:
1239 PAINTSTRUCT ps;
1240 HDC hdc = BeginPaint( hwnd, &ps );
1241 SCROLL_DrawScrollBar( hwnd, hdc, SB_CTL, TRUE, TRUE );
1242 EndPaint( hwnd, &ps );
1244 break;
1246 case SBM_SETPOS16:
1247 case SBM_SETPOS:
1248 return SetScrollPos( hwnd, SB_CTL, wParam, (BOOL)lParam );
1250 case SBM_GETPOS16:
1251 case SBM_GETPOS:
1252 return GetScrollPos( hwnd, SB_CTL );
1254 case SBM_SETRANGE16:
1255 SetScrollRange( hwnd, SB_CTL, LOWORD(lParam), HIWORD(lParam),
1256 wParam /* FIXME: Is this correct? */ );
1257 return 0;
1259 case SBM_SETRANGE:
1260 SetScrollRange( hwnd, SB_CTL, wParam, lParam, FALSE );
1261 return 0; /* FIXME: return previous position */
1263 case SBM_GETRANGE16:
1264 FIXME("don't know how to handle SBM_GETRANGE16 (wp=%04x,lp=%08lx)\n", wParam, lParam );
1265 return 0;
1267 case SBM_GETRANGE:
1268 GetScrollRange( hwnd, SB_CTL, (LPINT)wParam, (LPINT)lParam );
1269 return 0;
1271 case SBM_ENABLE_ARROWS16:
1272 case SBM_ENABLE_ARROWS:
1273 return EnableScrollBar( hwnd, SB_CTL, wParam );
1275 case SBM_SETRANGEREDRAW:
1276 SetScrollRange( hwnd, SB_CTL, wParam, lParam, TRUE );
1277 return 0; /* FIXME: return previous position */
1279 case SBM_SETSCROLLINFO:
1280 return SetScrollInfo( hwnd, SB_CTL, (SCROLLINFO *)lParam, wParam );
1282 case SBM_GETSCROLLINFO:
1283 return GetScrollInfo( hwnd, SB_CTL, (SCROLLINFO *)lParam );
1285 case 0x00e5:
1286 case 0x00e7:
1287 case 0x00e8:
1288 case 0x00eb:
1289 case 0x00ec:
1290 case 0x00ed:
1291 case 0x00ee:
1292 case 0x00ef:
1293 ERR("unknown Win32 msg %04x wp=%08x lp=%08lx\n",
1294 message, wParam, lParam );
1295 break;
1297 default:
1298 if (message >= WM_USER)
1299 WARN("unknown msg %04x wp=%04x lp=%08lx\n",
1300 message, wParam, lParam );
1301 return DefWindowProcW( hwnd, message, wParam, lParam );
1303 return 0;
1307 /*************************************************************************
1308 * SetScrollInfo16 (USER.475)
1310 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info,
1311 BOOL16 bRedraw )
1313 return (INT16)SetScrollInfo( hwnd, nBar, info, bRedraw );
1317 /*************************************************************************
1318 * SetScrollInfo (USER32.@)
1319 * SetScrollInfo can be used to set the position, upper bound,
1320 * lower bound, and page size of a scrollbar control.
1322 * RETURNS
1323 * Scrollbar position
1325 * NOTE
1326 * For 100 lines of text to be displayed in a window of 25 lines,
1327 * one would for instance use info->nMin=0, info->nMax=75
1328 * (corresponding to the 76 different positions of the window on
1329 * the text), and info->nPage=25.
1331 INT WINAPI SetScrollInfo(
1332 HWND hwnd /* [in] Handle of window whose scrollbar will be affected */,
1333 INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1334 const SCROLLINFO *info /* [in] Specifies what to change and new values */,
1335 BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */)
1337 INT action;
1338 INT retVal = SCROLL_SetScrollInfo( hwnd, nBar, info, &action );
1340 if( action & SA_SSI_HIDE )
1341 SCROLL_ShowScrollBar( hwnd, nBar, FALSE, FALSE );
1342 else
1344 if( action & SA_SSI_SHOW )
1345 if( SCROLL_ShowScrollBar( hwnd, nBar, TRUE, TRUE ) )
1346 return retVal; /* SetWindowPos() already did the painting */
1348 if( bRedraw && (action & SA_SSI_REFRESH))
1349 SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
1350 else if( action & SA_SSI_REPAINT_ARROWS )
1351 SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, FALSE );
1353 return retVal;
1356 INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar,
1357 const SCROLLINFO *info, INT *action )
1359 /* Update the scrollbar state and set action flags according to
1360 * what has to be done graphics wise. */
1362 SCROLLBAR_INFO *infoPtr;
1363 UINT new_flags;
1364 BOOL bChangeParams = FALSE; /* don't show/hide scrollbar if params don't change */
1366 *action = 0;
1368 if (!(infoPtr = SCROLL_GetScrollInfo(hwnd, nBar))) return 0;
1369 if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return 0;
1370 if ((info->cbSize != sizeof(*info)) &&
1371 (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return 0;
1373 if (TRACE_ON(scroll))
1375 TRACE("hwnd=%04x bar=%d", hwnd, nBar);
1376 if (info->fMask & SIF_PAGE) DPRINTF( " page=%d", info->nPage );
1377 if (info->fMask & SIF_POS) DPRINTF( " pos=%d", info->nPos );
1378 if (info->fMask & SIF_RANGE) DPRINTF( " min=%d max=%d", info->nMin, info->nMax );
1379 DPRINTF("\n");
1382 /* Set the page size */
1384 if (info->fMask & SIF_PAGE)
1386 if( infoPtr->Page != info->nPage )
1388 infoPtr->Page = info->nPage;
1389 *action |= SA_SSI_REFRESH;
1390 bChangeParams = TRUE;
1394 /* Set the scroll pos */
1396 if (info->fMask & SIF_POS)
1398 if( infoPtr->CurVal != info->nPos )
1400 infoPtr->CurVal = info->nPos;
1401 *action |= SA_SSI_REFRESH;
1405 /* Set the scroll range */
1407 if (info->fMask & SIF_RANGE)
1409 /* Invalid range -> range is set to (0,0) */
1410 if ((info->nMin > info->nMax) ||
1411 ((UINT)(info->nMax - info->nMin) >= 0x80000000))
1413 infoPtr->MinVal = 0;
1414 infoPtr->MaxVal = 0;
1415 bChangeParams = TRUE;
1417 else
1419 if( infoPtr->MinVal != info->nMin ||
1420 infoPtr->MaxVal != info->nMax )
1422 *action |= SA_SSI_REFRESH;
1423 infoPtr->MinVal = info->nMin;
1424 infoPtr->MaxVal = info->nMax;
1425 bChangeParams = TRUE;
1430 /* Make sure the page size is valid */
1432 if (infoPtr->Page < 0) infoPtr->Page = 0;
1433 else if (infoPtr->Page > infoPtr->MaxVal - infoPtr->MinVal + 1 )
1434 infoPtr->Page = infoPtr->MaxVal - infoPtr->MinVal + 1;
1436 /* Make sure the pos is inside the range */
1438 if (infoPtr->CurVal < infoPtr->MinVal)
1439 infoPtr->CurVal = infoPtr->MinVal;
1440 else if (infoPtr->CurVal > infoPtr->MaxVal - max( infoPtr->Page-1, 0 ))
1441 infoPtr->CurVal = infoPtr->MaxVal - max( infoPtr->Page-1, 0 );
1443 TRACE(" new values: page=%d pos=%d min=%d max=%d\n",
1444 infoPtr->Page, infoPtr->CurVal,
1445 infoPtr->MinVal, infoPtr->MaxVal );
1447 /* don't change the scrollbar state if SetScrollInfo
1448 * is just called with SIF_DISABLENOSCROLL
1450 if(!(info->fMask & SIF_ALL)) goto done;
1452 /* Check if the scrollbar should be hidden or disabled */
1454 if (info->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
1456 new_flags = infoPtr->flags;
1457 if (infoPtr->MinVal >= infoPtr->MaxVal - max( infoPtr->Page-1, 0 ))
1459 /* Hide or disable scroll-bar */
1460 if (info->fMask & SIF_DISABLENOSCROLL)
1462 new_flags = ESB_DISABLE_BOTH;
1463 *action |= SA_SSI_REFRESH;
1465 else if ((nBar != SB_CTL) && bChangeParams)
1467 *action = SA_SSI_HIDE;
1468 goto done;
1471 else /* Show and enable scroll-bar */
1473 new_flags = 0;
1474 if ((nBar != SB_CTL) && bChangeParams)
1475 *action |= SA_SSI_SHOW;
1478 if (infoPtr->flags != new_flags) /* check arrow flags */
1480 infoPtr->flags = new_flags;
1481 *action |= SA_SSI_REPAINT_ARROWS;
1485 done:
1486 /* Return current position */
1488 return infoPtr->CurVal;
1492 /*************************************************************************
1493 * GetScrollInfo16 (USER.476)
1495 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
1497 return GetScrollInfo( hwnd, nBar, info );
1501 /*************************************************************************
1502 * GetScrollInfo (USER32.@)
1503 * GetScrollInfo can be used to retrieve the position, upper bound,
1504 * lower bound, and page size of a scrollbar control.
1506 * RETURNS STD
1508 BOOL WINAPI GetScrollInfo(
1509 HWND hwnd /* [in] Handle of window */ ,
1510 INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1511 LPSCROLLINFO info /* [in/out] (info.fMask [in] specifies which values are to retrieve) */)
1513 SCROLLBAR_INFO *infoPtr;
1515 if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
1516 if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return FALSE;
1517 if ((info->cbSize != sizeof(*info)) &&
1518 (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return FALSE;
1520 if (info->fMask & SIF_PAGE) info->nPage = infoPtr->Page;
1521 if (info->fMask & SIF_POS) info->nPos = infoPtr->CurVal;
1522 if ((info->fMask & SIF_TRACKPOS) && (info->cbSize == sizeof(*info)))
1523 info->nTrackPos = (SCROLL_TrackingWin==hwnd) ? SCROLL_TrackingVal : infoPtr->CurVal;
1524 if (info->fMask & SIF_RANGE)
1526 info->nMin = infoPtr->MinVal;
1527 info->nMax = infoPtr->MaxVal;
1529 return (info->fMask & SIF_ALL) != 0;
1533 /*************************************************************************
1534 * SetScrollPos16 (USER.62)
1536 INT16 WINAPI SetScrollPos16( HWND16 hwnd, INT16 nBar, INT16 nPos,
1537 BOOL16 bRedraw )
1539 return (INT16)SetScrollPos( hwnd, nBar, nPos, bRedraw );
1543 /*************************************************************************
1544 * SetScrollPos (USER32.@)
1546 * RETURNS
1547 * Success: Scrollbar position
1548 * Failure: 0
1550 * REMARKS
1551 * Note the ambiguity when 0 is returned. Use GetLastError
1552 * to make sure there was an error (and to know which one).
1554 INT WINAPI SetScrollPos(
1555 HWND hwnd /* [in] Handle of window whose scrollbar will be affected */,
1556 INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */,
1557 INT nPos /* [in] New value */,
1558 BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */ )
1560 SCROLLINFO info;
1561 SCROLLBAR_INFO *infoPtr;
1562 INT oldPos;
1564 if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
1565 oldPos = infoPtr->CurVal;
1566 info.cbSize = sizeof(info);
1567 info.nPos = nPos;
1568 info.fMask = SIF_POS;
1569 SetScrollInfo( hwnd, nBar, &info, bRedraw );
1570 return oldPos;
1574 /*************************************************************************
1575 * GetScrollPos16 (USER.63)
1577 INT16 WINAPI GetScrollPos16( HWND16 hwnd, INT16 nBar )
1579 return (INT16)GetScrollPos( hwnd, nBar );
1583 /*************************************************************************
1584 * GetScrollPos (USER32.@)
1586 * RETURNS
1587 * Success: Current position
1588 * Failure: 0
1590 * REMARKS
1591 * Note the ambiguity when 0 is returned. Use GetLastError
1592 * to make sure there was an error (and to know which one).
1594 INT WINAPI GetScrollPos(
1595 HWND hwnd, /* [in] Handle of window */
1596 INT nBar /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */)
1598 SCROLLBAR_INFO *infoPtr;
1600 if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
1601 return infoPtr->CurVal;
1605 /*************************************************************************
1606 * SetScrollRange16 (USER.64)
1608 void WINAPI SetScrollRange16( HWND16 hwnd, INT16 nBar,
1609 INT16 MinVal, INT16 MaxVal, BOOL16 bRedraw )
1611 /* Invalid range -> range is set to (0,0) */
1612 if ((INT)MaxVal - (INT)MinVal > 0x7fff) MinVal = MaxVal = 0;
1613 SetScrollRange( hwnd, nBar, MinVal, MaxVal, bRedraw );
1617 /*************************************************************************
1618 * SetScrollRange (USER32.@)
1620 * RETURNS STD
1622 BOOL WINAPI SetScrollRange(
1623 HWND hwnd, /* [in] Handle of window whose scrollbar will be affected */
1624 INT nBar, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1625 INT MinVal, /* [in] New minimum value */
1626 INT MaxVal, /* [in] New maximum value */
1627 BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */)
1629 SCROLLINFO info;
1631 info.cbSize = sizeof(info);
1632 info.nMin = MinVal;
1633 info.nMax = MaxVal;
1634 info.fMask = SIF_RANGE;
1635 SetScrollInfo( hwnd, nBar, &info, bRedraw );
1636 return TRUE;
1640 /*************************************************************************
1641 * SCROLL_SetNCSbState
1643 * Updates both scrollbars at the same time. Used by MDI CalcChildScroll().
1645 INT SCROLL_SetNCSbState(WND* wndPtr, int vMin, int vMax, int vPos,
1646 int hMin, int hMax, int hPos)
1648 INT vA, hA;
1649 SCROLLINFO vInfo, hInfo;
1651 vInfo.cbSize = hInfo.cbSize = sizeof(SCROLLINFO);
1652 vInfo.nMin = vMin; hInfo.nMin = hMin;
1653 vInfo.nMax = vMax; hInfo.nMax = hMax;
1654 vInfo.nPos = vPos; hInfo.nPos = hPos;
1655 vInfo.fMask = hInfo.fMask = SIF_RANGE | SIF_POS;
1657 SCROLL_SetScrollInfo( wndPtr->hwndSelf, SB_VERT, &vInfo, &vA );
1658 SCROLL_SetScrollInfo( wndPtr->hwndSelf, SB_HORZ, &hInfo, &hA );
1660 if( !SCROLL_ShowScrollBar( wndPtr->hwndSelf, SB_BOTH,
1661 (hA & SA_SSI_SHOW),(vA & SA_SSI_SHOW) ) )
1663 /* SetWindowPos() wasn't called, just redraw the scrollbars if needed */
1664 if( vA & SA_SSI_REFRESH )
1665 SCROLL_RefreshScrollBar( wndPtr->hwndSelf, SB_VERT, FALSE, TRUE );
1667 if( hA & SA_SSI_REFRESH )
1668 SCROLL_RefreshScrollBar( wndPtr->hwndSelf, SB_HORZ, FALSE, TRUE );
1670 return 0;
1674 /*************************************************************************
1675 * GetScrollRange16 (USER.65)
1677 BOOL16 WINAPI GetScrollRange16( HWND16 hwnd, INT16 nBar,
1678 LPINT16 lpMin, LPINT16 lpMax)
1680 INT min, max;
1681 BOOL16 ret = GetScrollRange( hwnd, nBar, &min, &max );
1682 if (lpMin) *lpMin = min;
1683 if (lpMax) *lpMax = max;
1684 return ret;
1688 /*************************************************************************
1689 * GetScrollRange (USER32.@)
1691 * RETURNS STD
1693 BOOL WINAPI GetScrollRange(
1694 HWND hwnd, /* [in] Handle of window */
1695 INT nBar, /* [in] One of SB_HORZ, SB_VERT, or SB_CTL */
1696 LPINT lpMin, /* [out] Where to store minimum value */
1697 LPINT lpMax /* [out] Where to store maximum value */)
1699 SCROLLBAR_INFO *infoPtr;
1701 if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar )))
1703 if (lpMin) lpMin = 0;
1704 if (lpMax) lpMax = 0;
1705 return FALSE;
1707 if (lpMin) *lpMin = infoPtr->MinVal;
1708 if (lpMax) *lpMax = infoPtr->MaxVal;
1709 return TRUE;
1713 /*************************************************************************
1714 * SCROLL_ShowScrollBar()
1716 * Back-end for ShowScrollBar(). Returns FALSE if no action was taken.
1718 BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
1719 BOOL fShowH, BOOL fShowV )
1721 WND *wndPtr = WIN_FindWndPtr( hwnd );
1722 BOOL retvalue = FALSE;
1724 if (!wndPtr) return FALSE;
1725 TRACE("hwnd=%04x bar=%d horz=%d, vert=%d\n",
1726 hwnd, nBar, fShowH, fShowV );
1728 switch(nBar)
1730 case SB_CTL:
1731 ShowWindow( hwnd, fShowH ? SW_SHOW : SW_HIDE );
1732 retvalue = TRUE;
1733 goto END;
1735 case SB_BOTH:
1736 case SB_HORZ:
1737 if (fShowH)
1739 fShowH = !(wndPtr->dwStyle & WS_HSCROLL);
1740 wndPtr->dwStyle |= WS_HSCROLL;
1742 else /* hide it */
1744 fShowH = (wndPtr->dwStyle & WS_HSCROLL);
1745 wndPtr->dwStyle &= ~WS_HSCROLL;
1747 if( nBar == SB_HORZ ) {
1748 fShowV = FALSE;
1749 break;
1751 /* fall through */
1753 case SB_VERT:
1754 if (fShowV)
1756 fShowV = !(wndPtr->dwStyle & WS_VSCROLL);
1757 wndPtr->dwStyle |= WS_VSCROLL;
1759 else /* hide it */
1761 fShowV = (wndPtr->dwStyle & WS_VSCROLL);
1762 wndPtr->dwStyle &= ~WS_VSCROLL;
1764 if ( nBar == SB_VERT )
1765 fShowH = FALSE;
1766 break;
1768 default:
1769 retvalue = FALSE; /* Nothing to do! */
1770 goto END;
1773 if( fShowH || fShowV ) /* frame has been changed, let the window redraw itself */
1775 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
1776 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
1777 retvalue = TRUE;
1778 goto END;
1781 retvalue = FALSE; /* no frame changes */
1782 END:
1783 WIN_ReleaseWndPtr(wndPtr);
1784 return retvalue;
1788 /*************************************************************************
1789 * ShowScrollBar16 (USER.267)
1791 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1793 SCROLL_ShowScrollBar( hwnd, nBar, (nBar == SB_VERT) ? 0 : fShow,
1794 (nBar == SB_HORZ) ? 0 : fShow );
1798 /*************************************************************************
1799 * ShowScrollBar (USER32.@)
1801 * RETURNS STD
1803 BOOL WINAPI ShowScrollBar(
1804 HWND hwnd, /* [in] Handle of window whose scrollbar(s) will be affected */
1805 INT nBar, /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */
1806 BOOL fShow /* [in] TRUE = show, FALSE = hide */)
1808 SCROLL_ShowScrollBar( hwnd, nBar, (nBar == SB_VERT) ? 0 : fShow,
1809 (nBar == SB_HORZ) ? 0 : fShow );
1810 return TRUE;
1814 /*************************************************************************
1815 * EnableScrollBar16 (USER.482)
1817 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
1819 return EnableScrollBar( hwnd, nBar, flags );
1823 /*************************************************************************
1824 * EnableScrollBar (USER32.@)
1826 BOOL WINAPI EnableScrollBar( HWND hwnd, INT nBar, UINT flags )
1828 BOOL bFineWithMe;
1829 SCROLLBAR_INFO *infoPtr;
1831 TRACE("%04x %d %d\n", hwnd, nBar, flags );
1833 flags &= ESB_DISABLE_BOTH;
1835 if (nBar == SB_BOTH)
1837 if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, SB_VERT ))) return FALSE;
1838 if (!(bFineWithMe = (infoPtr->flags == flags)) )
1840 infoPtr->flags = flags;
1841 SCROLL_RefreshScrollBar( hwnd, SB_VERT, TRUE, TRUE );
1843 nBar = SB_HORZ;
1845 else
1846 bFineWithMe = TRUE;
1848 if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
1849 if (bFineWithMe && infoPtr->flags == flags) return FALSE;
1850 infoPtr->flags = flags;
1852 SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
1853 return TRUE;