| 1 | /* $Id: scroll.cpp,v 1.5 1999-08-15 19:11:01 cbratschi Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Scrollbar control
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1999 Christoph Bratschi (ported from WINE)
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright 1993 Martin Ayotte
|
|---|
| 8 | * Copyright 1994, 1996 Alexandre Julliard
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | /* CB:
|
|---|
| 12 | - exported API removed, this functions are already implemented by Open32,
|
|---|
| 13 | code perhaps useful for new user32
|
|---|
| 14 | - only control, default scroll bars for windows need more work
|
|---|
| 15 | - SystemTimer not implemented
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 | #include <stdlib.h>
|
|---|
| 19 | #include "winuser.h"
|
|---|
| 20 | #include "winbase.h"
|
|---|
| 21 | #include "controls.h"
|
|---|
| 22 | #include "scroll.h"
|
|---|
| 23 |
|
|---|
| 24 | static HBITMAP hUpArrow = 0;
|
|---|
| 25 | static HBITMAP hDnArrow = 0;
|
|---|
| 26 | static HBITMAP hLfArrow = 0;
|
|---|
| 27 | static HBITMAP hRgArrow = 0;
|
|---|
| 28 | static HBITMAP hUpArrowD = 0;
|
|---|
| 29 | static HBITMAP hDnArrowD = 0;
|
|---|
| 30 | static HBITMAP hLfArrowD = 0;
|
|---|
| 31 | static HBITMAP hRgArrowD = 0;
|
|---|
| 32 | static HBITMAP hUpArrowI = 0;
|
|---|
| 33 | static HBITMAP hDnArrowI = 0;
|
|---|
| 34 | static HBITMAP hLfArrowI = 0;
|
|---|
| 35 | static HBITMAP hRgArrowI = 0;
|
|---|
| 36 |
|
|---|
| 37 | #define TOP_ARROW(flags,pressed) \
|
|---|
| 38 | (((flags)&ESB_DISABLE_UP) ? hUpArrowI : ((pressed) ? hUpArrowD:hUpArrow))
|
|---|
| 39 | #define BOTTOM_ARROW(flags,pressed) \
|
|---|
| 40 | (((flags)&ESB_DISABLE_DOWN) ? hDnArrowI : ((pressed) ? hDnArrowD:hDnArrow))
|
|---|
| 41 | #define LEFT_ARROW(flags,pressed) \
|
|---|
| 42 | (((flags)&ESB_DISABLE_LEFT) ? hLfArrowI : ((pressed) ? hLfArrowD:hLfArrow))
|
|---|
| 43 | #define RIGHT_ARROW(flags,pressed) \
|
|---|
| 44 | (((flags)&ESB_DISABLE_RIGHT) ? hRgArrowI : ((pressed) ? hRgArrowD:hRgArrow))
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | /* Minimum size of the rectangle between the arrows */
|
|---|
| 48 | #define SCROLL_MIN_RECT 4
|
|---|
| 49 |
|
|---|
| 50 | /* Minimum size of the thumb in pixels */
|
|---|
| 51 | #define SCROLL_MIN_THUMB 6
|
|---|
| 52 |
|
|---|
| 53 | /* Overlap between arrows and thumb */
|
|---|
| 54 | #define SCROLL_ARROW_THUMB_OVERLAP 0
|
|---|
| 55 |
|
|---|
| 56 | /* Delay (in ms) before first repetition when holding the button down */
|
|---|
| 57 | #define SCROLL_FIRST_DELAY 200
|
|---|
| 58 |
|
|---|
| 59 | /* Delay (in ms) between scroll repetitions */
|
|---|
| 60 | #define SCROLL_REPEAT_DELAY 50
|
|---|
| 61 |
|
|---|
| 62 | /* Scroll timer id */
|
|---|
| 63 | #define SCROLL_TIMER 0
|
|---|
| 64 |
|
|---|
| 65 | /* Scroll-bar hit testing */
|
|---|
| 66 | enum SCROLL_HITTEST
|
|---|
| 67 | {
|
|---|
| 68 | SCROLL_NOWHERE, /* Outside the scroll bar */
|
|---|
| 69 | SCROLL_TOP_ARROW, /* Top or left arrow */
|
|---|
| 70 | SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
|
|---|
| 71 | SCROLL_THUMB, /* Thumb rectangle */
|
|---|
| 72 | SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
|
|---|
| 73 | SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | /* What to do after SCROLL_SetScrollInfo() */
|
|---|
| 77 | #define SA_SSI_HIDE 0x0001
|
|---|
| 78 | #define SA_SSI_SHOW 0x0002
|
|---|
| 79 | #define SA_SSI_REFRESH 0x0004
|
|---|
| 80 | #define SA_SSI_REPAINT_ARROWS 0x0008
|
|---|
| 81 |
|
|---|
| 82 | /* Thumb-tracking info */
|
|---|
| 83 | static HWND SCROLL_TrackingWin = 0;
|
|---|
| 84 | static INT SCROLL_TrackingBar = 0;
|
|---|
| 85 | static INT SCROLL_TrackingPos = 0;
|
|---|
| 86 | static INT SCROLL_TrackingVal = 0;
|
|---|
| 87 | /* Hit test code of the last button-down event */
|
|---|
| 88 | static enum SCROLL_HITTEST SCROLL_trackHitTest;
|
|---|
| 89 | static BOOL SCROLL_trackVertical;
|
|---|
| 90 |
|
|---|
| 91 | /* Is the moving thumb being displayed? */
|
|---|
| 92 | static BOOL SCROLL_MovingThumb = FALSE;
|
|---|
| 93 |
|
|---|
| 94 | /* Local functions */
|
|---|
| 95 | static BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
|
|---|
| 96 | BOOL fShowH, BOOL fShowV );
|
|---|
| 97 | static INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar,
|
|---|
| 98 | const SCROLLINFO *info, INT *action );
|
|---|
| 99 | static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar,
|
|---|
| 100 | RECT *rect, INT arrowSize,
|
|---|
| 101 | INT thumbSize, INT thumbPos,
|
|---|
| 102 | UINT flags, BOOL vertical,
|
|---|
| 103 | BOOL top_selected, BOOL bottom_selected );
|
|---|
| 104 |
|
|---|
| 105 | /***********************************************************************
|
|---|
| 106 | * SCROLL_LoadBitmaps
|
|---|
| 107 | */
|
|---|
| 108 | static void SCROLL_LoadBitmaps(void)
|
|---|
| 109 | {
|
|---|
| 110 | hUpArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROW) );
|
|---|
| 111 | hDnArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROW) );
|
|---|
| 112 | hLfArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROW) );
|
|---|
| 113 | hRgArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROW) );
|
|---|
| 114 | hUpArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWD) );
|
|---|
| 115 | hDnArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWD) );
|
|---|
| 116 | hLfArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWD) );
|
|---|
| 117 | hRgArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWD) );
|
|---|
| 118 | hUpArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWI) );
|
|---|
| 119 | hDnArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWI) );
|
|---|
| 120 | hLfArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWI) );
|
|---|
| 121 | hRgArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWI) );
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | /***********************************************************************
|
|---|
| 125 | * SCROLL_GetPtrScrollInfo
|
|---|
| 126 | */
|
|---|
| 127 | static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( HWND hwnd, INT nBar )
|
|---|
| 128 | {
|
|---|
| 129 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 130 |
|
|---|
| 131 | switch(nBar)
|
|---|
| 132 | {
|
|---|
| 133 | /* CB: implement this later!
|
|---|
| 134 | case SB_HORZ:
|
|---|
| 135 | infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll;
|
|---|
| 136 | break;
|
|---|
| 137 | case SB_VERT:
|
|---|
| 138 | infoPtr = (SCROLLBAR_INFO *)wndPtr->pVScroll;
|
|---|
| 139 | break;
|
|---|
| 140 | */
|
|---|
| 141 | case SB_CTL:
|
|---|
| 142 | infoPtr = (SCROLLBAR_INFO *)GetInfoPtr(hwnd);
|
|---|
| 143 | break;
|
|---|
| 144 | default: return NULL;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | if (!infoPtr) /* Create the info structure if needed */
|
|---|
| 148 | {
|
|---|
| 149 | infoPtr = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 150 | infoPtr->MinVal = infoPtr->CurVal = infoPtr->Page = 0;
|
|---|
| 151 | infoPtr->MaxVal = 100;
|
|---|
| 152 | infoPtr->flags = ESB_ENABLE_BOTH;
|
|---|
| 153 |
|
|---|
| 154 | //CB: store in window class if not control!
|
|---|
| 155 | SetInfoPtr(hwnd,(DWORD)infoPtr);
|
|---|
| 156 |
|
|---|
| 157 | if (!hUpArrow) SCROLL_LoadBitmaps();
|
|---|
| 158 | }
|
|---|
| 159 | return infoPtr;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 | /***********************************************************************
|
|---|
| 164 | * SCROLL_GetScrollInfo
|
|---|
| 165 | */
|
|---|
| 166 | static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar )
|
|---|
| 167 | {
|
|---|
| 168 | return SCROLL_GetPtrScrollInfo( hwnd, nBar );
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 | /***********************************************************************
|
|---|
| 173 | * SCROLL_GetScrollBarRect
|
|---|
| 174 | *
|
|---|
| 175 | * Compute the scroll bar rectangle, in drawing coordinates (i.e. client
|
|---|
| 176 | * coords for SB_CTL, window coords for SB_VERT and SB_HORZ).
|
|---|
| 177 | * 'arrowSize' returns the width or height of an arrow (depending on
|
|---|
| 178 | * the orientation of the scrollbar), 'thumbSize' returns the size of
|
|---|
| 179 | * the thumb, and 'thumbPos' returns the position of the thumb
|
|---|
| 180 | * relative to the left or to the top.
|
|---|
| 181 | * Return TRUE if the scrollbar is vertical, FALSE if horizontal.
|
|---|
| 182 | */
|
|---|
| 183 | static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
|
|---|
| 184 | INT *arrowSize, INT *thumbSize,
|
|---|
| 185 | INT *thumbPos )
|
|---|
| 186 | {
|
|---|
| 187 | INT pixels;
|
|---|
| 188 | BOOL vertical;
|
|---|
| 189 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 190 | RECT rectClient;
|
|---|
| 191 |
|
|---|
| 192 | switch(nBar)
|
|---|
| 193 | {
|
|---|
| 194 | /* CB: implement later!
|
|---|
| 195 | case SB_HORZ:
|
|---|
| 196 | lprect->left = wndPtr->rectClient.left - wndPtr->rectWindow.left;
|
|---|
| 197 | lprect->top = wndPtr->rectClient.bottom - wndPtr->rectWindow.top;
|
|---|
| 198 | lprect->right = wndPtr->rectClient.right - wndPtr->rectWindow.left;
|
|---|
| 199 | lprect->bottom = lprect->top + GetSystemMetrics(SM_CYHSCROLL);
|
|---|
| 200 | if(dwStyle & WS_BORDER) {
|
|---|
| 201 | lprect->left--;
|
|---|
| 202 | lprect->right++;
|
|---|
| 203 | } else if(dwStyle & WS_VSCROLL)
|
|---|
| 204 | lprect->right++;
|
|---|
| 205 | vertical = FALSE;
|
|---|
| 206 | break;
|
|---|
| 207 |
|
|---|
| 208 | case SB_VERT:
|
|---|
| 209 | lprect->left = wndPtr->rectClient.right - wndPtr->rectWindow.left;
|
|---|
| 210 | lprect->top = wndPtr->rectClient.top - wndPtr->rectWindow.top;
|
|---|
| 211 | lprect->right = lprect->left + GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 212 | lprect->bottom = wndPtr->rectClient.bottom - wndPtr->rectWindow.top;
|
|---|
| 213 | if(wndPtr->dwStyle & WS_BORDER) {
|
|---|
| 214 | lprect->top--;
|
|---|
| 215 | lprect->bottom++;
|
|---|
| 216 | } else if(wndPtr->dwStyle & WS_HSCROLL)
|
|---|
| 217 | lprect->bottom++;
|
|---|
| 218 | vertical = TRUE;
|
|---|
| 219 | break;
|
|---|
| 220 | */
|
|---|
| 221 | case SB_CTL:
|
|---|
| 222 | GetClientRect( hwnd, lprect );
|
|---|
| 223 | vertical = ((dwStyle & SBS_VERT) != 0);
|
|---|
| 224 | break;
|
|---|
| 225 |
|
|---|
| 226 | default:
|
|---|
| 227 | return FALSE;
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | if (vertical) pixels = lprect->bottom - lprect->top;
|
|---|
| 231 | else pixels = lprect->right - lprect->left;
|
|---|
| 232 |
|
|---|
| 233 | if (pixels <= 2*GetSystemMetrics(SM_CXVSCROLL) + SCROLL_MIN_RECT)
|
|---|
| 234 | {
|
|---|
| 235 | if (pixels > SCROLL_MIN_RECT)
|
|---|
| 236 | *arrowSize = (pixels - SCROLL_MIN_RECT) / 2;
|
|---|
| 237 | else
|
|---|
| 238 | *arrowSize = 0;
|
|---|
| 239 | *thumbPos = *thumbSize = 0;
|
|---|
| 240 | }
|
|---|
| 241 | else
|
|---|
| 242 | {
|
|---|
| 243 | SCROLLBAR_INFO *info = SCROLL_GetPtrScrollInfo( hwnd, nBar );
|
|---|
| 244 |
|
|---|
| 245 | *arrowSize = GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 246 | pixels -= (2 * (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP));
|
|---|
| 247 |
|
|---|
| 248 | if (info->Page)
|
|---|
| 249 | {
|
|---|
| 250 | *thumbSize = pixels * info->Page / (info->MaxVal-info->MinVal+1);
|
|---|
| 251 | if (*thumbSize < SCROLL_MIN_THUMB) *thumbSize = SCROLL_MIN_THUMB;
|
|---|
| 252 | }
|
|---|
| 253 | else *thumbSize = GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 254 |
|
|---|
| 255 | if (((pixels -= *thumbSize ) < 0) ||
|
|---|
| 256 | ((info->flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH))
|
|---|
| 257 | {
|
|---|
| 258 | /* Rectangle too small or scrollbar disabled -> no thumb */
|
|---|
| 259 | *thumbPos = *thumbSize = 0;
|
|---|
| 260 | }
|
|---|
| 261 | else
|
|---|
| 262 | {
|
|---|
| 263 | INT max = info->MaxVal - MAX( info->Page-1, 0 );
|
|---|
| 264 | if (info->MinVal >= max)
|
|---|
| 265 | *thumbPos = *arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
|---|
| 266 | else
|
|---|
| 267 | *thumbPos = *arrowSize - SCROLL_ARROW_THUMB_OVERLAP
|
|---|
| 268 | + pixels * (info->CurVal-info->MinVal) / (max - info->MinVal);
|
|---|
| 269 | }
|
|---|
| 270 | }
|
|---|
| 271 | return vertical;
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 | /***********************************************************************
|
|---|
| 276 | * SCROLL_GetThumbVal
|
|---|
| 277 | *
|
|---|
| 278 | * Compute the current scroll position based on the thumb position in pixels
|
|---|
| 279 | * from the top of the scroll-bar.
|
|---|
| 280 | */
|
|---|
| 281 | static UINT SCROLL_GetThumbVal( SCROLLBAR_INFO *infoPtr, RECT *rect,
|
|---|
| 282 | BOOL vertical, INT pos )
|
|---|
| 283 | {
|
|---|
| 284 | INT thumbSize;
|
|---|
| 285 | INT pixels = vertical ? rect->bottom-rect->top : rect->right-rect->left;
|
|---|
| 286 |
|
|---|
| 287 | if ((pixels -= 2*(GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP)) <= 0)
|
|---|
| 288 | return infoPtr->MinVal;
|
|---|
| 289 |
|
|---|
| 290 | if (infoPtr->Page)
|
|---|
| 291 | {
|
|---|
| 292 | thumbSize = pixels * infoPtr->Page/(infoPtr->MaxVal-infoPtr->MinVal+1);
|
|---|
| 293 | if (thumbSize < SCROLL_MIN_THUMB) thumbSize = SCROLL_MIN_THUMB;
|
|---|
| 294 | }
|
|---|
| 295 | else thumbSize = GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 296 |
|
|---|
| 297 | if ((pixels -= thumbSize) <= 0) return infoPtr->MinVal;
|
|---|
| 298 |
|
|---|
| 299 | pos = MAX( 0, pos - (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP) );
|
|---|
| 300 | if (pos > pixels) pos = pixels;
|
|---|
| 301 |
|
|---|
| 302 | if (!infoPtr->Page) pos *= infoPtr->MaxVal - infoPtr->MinVal;
|
|---|
| 303 | else pos *= infoPtr->MaxVal - infoPtr->MinVal - infoPtr->Page + 1;
|
|---|
| 304 | return infoPtr->MinVal + ((pos + pixels / 2) / pixels);
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | /***********************************************************************
|
|---|
| 308 | * SCROLL_PtInRectEx
|
|---|
| 309 | */
|
|---|
| 310 | static BOOL SCROLL_PtInRectEx( LPRECT lpRect, POINT pt, BOOL vertical )
|
|---|
| 311 | {
|
|---|
| 312 | RECT rect = *lpRect;
|
|---|
| 313 |
|
|---|
| 314 | if (vertical)
|
|---|
| 315 | {
|
|---|
| 316 | rect.left -= lpRect->right - lpRect->left;
|
|---|
| 317 | rect.right += lpRect->right - lpRect->left;
|
|---|
| 318 | }
|
|---|
| 319 | else
|
|---|
| 320 | {
|
|---|
| 321 | rect.top -= lpRect->bottom - lpRect->top;
|
|---|
| 322 | rect.bottom += lpRect->bottom - lpRect->top;
|
|---|
| 323 | }
|
|---|
| 324 | return PtInRect( &rect, pt );
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | /***********************************************************************
|
|---|
| 328 | * SCROLL_ClipPos
|
|---|
| 329 | */
|
|---|
| 330 | static POINT SCROLL_ClipPos( LPRECT lpRect, POINT pt )
|
|---|
| 331 | {
|
|---|
| 332 | if( pt.x < lpRect->left )
|
|---|
| 333 | pt.x = lpRect->left;
|
|---|
| 334 | else
|
|---|
| 335 | if( pt.x > lpRect->right )
|
|---|
| 336 | pt.x = lpRect->right;
|
|---|
| 337 |
|
|---|
| 338 | if( pt.y < lpRect->top )
|
|---|
| 339 | pt.y = lpRect->top;
|
|---|
| 340 | else
|
|---|
| 341 | if( pt.y > lpRect->bottom )
|
|---|
| 342 | pt.y = lpRect->bottom;
|
|---|
| 343 |
|
|---|
| 344 | return pt;
|
|---|
| 345 | }
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 | /***********************************************************************
|
|---|
| 349 | * SCROLL_HitTest
|
|---|
| 350 | *
|
|---|
| 351 | * Scroll-bar hit testing (don't confuse this with WM_NCHITTEST!).
|
|---|
| 352 | */
|
|---|
| 353 | static enum SCROLL_HITTEST SCROLL_HitTest( HWND hwnd, INT nBar,
|
|---|
| 354 | POINT pt, BOOL bDragging )
|
|---|
| 355 | {
|
|---|
| 356 | INT arrowSize, thumbSize, thumbPos;
|
|---|
| 357 | RECT rect;
|
|---|
| 358 |
|
|---|
| 359 | BOOL vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
|---|
| 360 | &arrowSize, &thumbSize, &thumbPos );
|
|---|
| 361 |
|
|---|
| 362 | if ( (bDragging && !SCROLL_PtInRectEx( &rect, pt, vertical )) ||
|
|---|
| 363 | (!PtInRect( &rect, pt )) ) return SCROLL_NOWHERE;
|
|---|
| 364 |
|
|---|
| 365 | if (vertical)
|
|---|
| 366 | {
|
|---|
| 367 | if (pt.y < rect.top + arrowSize) return SCROLL_TOP_ARROW;
|
|---|
| 368 | if (pt.y >= rect.bottom - arrowSize) return SCROLL_BOTTOM_ARROW;
|
|---|
| 369 | if (!thumbPos) return SCROLL_TOP_RECT;
|
|---|
| 370 | pt.y -= rect.top;
|
|---|
| 371 | if (pt.y < thumbPos) return SCROLL_TOP_RECT;
|
|---|
| 372 | if (pt.y >= thumbPos + thumbSize) return SCROLL_BOTTOM_RECT;
|
|---|
| 373 | }
|
|---|
| 374 | else /* horizontal */
|
|---|
| 375 | {
|
|---|
| 376 | if (pt.x < rect.left + arrowSize) return SCROLL_TOP_ARROW;
|
|---|
| 377 | if (pt.x >= rect.right - arrowSize) return SCROLL_BOTTOM_ARROW;
|
|---|
| 378 | if (!thumbPos) return SCROLL_TOP_RECT;
|
|---|
| 379 | pt.x -= rect.left;
|
|---|
| 380 | if (pt.x < thumbPos) return SCROLL_TOP_RECT;
|
|---|
| 381 | if (pt.x >= thumbPos + thumbSize) return SCROLL_BOTTOM_RECT;
|
|---|
| 382 | }
|
|---|
| 383 | return SCROLL_THUMB;
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | /***********************************************************************
|
|---|
| 387 | * SCROLL_DrawArrows
|
|---|
| 388 | *
|
|---|
| 389 | * Draw the scroll bar arrows.
|
|---|
| 390 | */
|
|---|
| 391 | static void SCROLL_DrawArrows_9x( HDC hdc, SCROLLBAR_INFO *infoPtr,
|
|---|
| 392 | RECT *rect, INT arrowSize, BOOL vertical,
|
|---|
| 393 | BOOL top_pressed, BOOL bottom_pressed )
|
|---|
| 394 | {
|
|---|
| 395 | RECT r;
|
|---|
| 396 |
|
|---|
| 397 | r = *rect;
|
|---|
| 398 | if( vertical )
|
|---|
| 399 | r.bottom = r.top + arrowSize;
|
|---|
| 400 | else
|
|---|
| 401 | r.right = r.left + arrowSize;
|
|---|
| 402 |
|
|---|
| 403 | DrawFrameControl( hdc, &r, DFC_SCROLL,
|
|---|
| 404 | (vertical ? DFCS_SCROLLUP : DFCS_SCROLLLEFT)
|
|---|
| 405 | | (top_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
|
|---|
| 406 | | (infoPtr->flags&ESB_DISABLE_LTUP ? DFCS_INACTIVE : 0 ) );
|
|---|
| 407 |
|
|---|
| 408 | r = *rect;
|
|---|
| 409 | if( vertical )
|
|---|
| 410 | r.top = r.bottom-arrowSize;
|
|---|
| 411 | else
|
|---|
| 412 | r.left = r.right-arrowSize;
|
|---|
| 413 |
|
|---|
| 414 | DrawFrameControl( hdc, &r, DFC_SCROLL,
|
|---|
| 415 | (vertical ? DFCS_SCROLLDOWN : DFCS_SCROLLRIGHT)
|
|---|
| 416 | | (bottom_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
|
|---|
| 417 | | (infoPtr->flags&ESB_DISABLE_RTDN ? DFCS_INACTIVE : 0) );
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | static void SCROLL_DrawArrows( HDC hdc, SCROLLBAR_INFO *infoPtr,
|
|---|
| 421 | RECT *rect, INT arrowSize, BOOL vertical,
|
|---|
| 422 | BOOL top_pressed, BOOL bottom_pressed )
|
|---|
| 423 | {
|
|---|
| 424 | SCROLL_DrawArrows_9x( hdc, infoPtr, rect, arrowSize,
|
|---|
| 425 | vertical, top_pressed,bottom_pressed );
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 | /***********************************************************************
|
|---|
| 430 | * SCROLL_DrawMovingThumb
|
|---|
| 431 | *
|
|---|
| 432 | * Draw the moving thumb rectangle.
|
|---|
| 433 | */
|
|---|
| 434 | static void SCROLL_DrawMovingThumb_9x( HDC hdc, RECT *rect, BOOL vertical,
|
|---|
| 435 | INT arrowSize, INT thumbSize )
|
|---|
| 436 | {
|
|---|
| 437 | INT pos = SCROLL_TrackingPos;
|
|---|
| 438 | INT max_size;
|
|---|
| 439 |
|
|---|
| 440 | if( vertical )
|
|---|
| 441 | max_size = rect->bottom - rect->top;
|
|---|
| 442 | else
|
|---|
| 443 | max_size = rect->right - rect->left;
|
|---|
| 444 |
|
|---|
| 445 | max_size -= (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) + thumbSize;
|
|---|
| 446 |
|
|---|
| 447 | if( pos < (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) )
|
|---|
| 448 | pos = (arrowSize-SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 449 | else if( pos > max_size )
|
|---|
| 450 | pos = max_size;
|
|---|
| 451 |
|
|---|
| 452 | SCROLL_DrawInterior_9x( SCROLL_TrackingWin, hdc, SCROLL_TrackingBar,
|
|---|
| 453 | rect, arrowSize, thumbSize, pos,
|
|---|
| 454 | 0, vertical, FALSE, FALSE );
|
|---|
| 455 |
|
|---|
| 456 | SCROLL_MovingThumb = !SCROLL_MovingThumb;
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical,
|
|---|
| 460 | INT arrowSize, INT thumbSize )
|
|---|
| 461 | {
|
|---|
| 462 | SCROLL_DrawMovingThumb_9x( hdc, rect, vertical, arrowSize, thumbSize );
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | /***********************************************************************
|
|---|
| 466 | * SCROLL_DrawInterior
|
|---|
| 467 | *
|
|---|
| 468 | * Draw the scroll bar interior (everything except the arrows).
|
|---|
| 469 | */
|
|---|
| 470 | static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar,
|
|---|
| 471 | RECT *rect, INT arrowSize,
|
|---|
| 472 | INT thumbSize, INT thumbPos,
|
|---|
| 473 | UINT flags, BOOL vertical,
|
|---|
| 474 | BOOL top_selected, BOOL bottom_selected )
|
|---|
| 475 | {
|
|---|
| 476 | RECT r;
|
|---|
| 477 | HPEN hSavePen;
|
|---|
| 478 | HBRUSH hSaveBrush,hBrush;
|
|---|
| 479 |
|
|---|
| 480 | /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
|
|---|
| 481 | * The window-owned scrollbars need to call DEFWND_ControlColor
|
|---|
| 482 | * to correctly setup default scrollbar colors
|
|---|
| 483 | */
|
|---|
| 484 | if (nBar == SB_CTL)
|
|---|
| 485 | {
|
|---|
| 486 | hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
|
|---|
| 487 | (WPARAM)hdc,(LPARAM)hwnd);
|
|---|
| 488 | }
|
|---|
| 489 | else
|
|---|
| 490 | {
|
|---|
| 491 | //CB: implement!
|
|---|
| 492 | //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
|
|---|
| 493 | }
|
|---|
| 494 |
|
|---|
| 495 | hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
|
|---|
| 496 | hSaveBrush = SelectObject( hdc, hBrush );
|
|---|
| 497 |
|
|---|
| 498 | /* Calculate the scroll rectangle */
|
|---|
| 499 | r = *rect;
|
|---|
| 500 | if (vertical)
|
|---|
| 501 | {
|
|---|
| 502 | r.top += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
|---|
| 503 | r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 504 | }
|
|---|
| 505 | else
|
|---|
| 506 | {
|
|---|
| 507 | r.left += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
|---|
| 508 | r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | /* Draw the scroll rectangles and thumb */
|
|---|
| 512 | if (!thumbPos) /* No thumb to draw */
|
|---|
| 513 | {
|
|---|
| 514 | PatBlt( hdc, r.left, r.top,
|
|---|
| 515 | r.right - r.left, r.bottom - r.top,
|
|---|
| 516 | PATCOPY );
|
|---|
| 517 |
|
|---|
| 518 | /* cleanup and return */
|
|---|
| 519 | SelectObject( hdc, hSavePen );
|
|---|
| 520 | SelectObject( hdc, hSaveBrush );
|
|---|
| 521 | return;
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 | if (vertical)
|
|---|
| 525 | {
|
|---|
| 526 | PatBlt( hdc, r.left, r.top,
|
|---|
| 527 | r.right - r.left,
|
|---|
| 528 | thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
|
|---|
| 529 | top_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 530 | r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 531 | PatBlt( hdc, r.left, r.top + thumbSize,
|
|---|
| 532 | r.right - r.left,
|
|---|
| 533 | r.bottom - r.top - thumbSize,
|
|---|
| 534 | bottom_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 535 | r.bottom = r.top + thumbSize;
|
|---|
| 536 | }
|
|---|
| 537 | else /* horizontal */
|
|---|
| 538 | {
|
|---|
| 539 | PatBlt( hdc, r.left, r.top,
|
|---|
| 540 | thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
|
|---|
| 541 | r.bottom - r.top,
|
|---|
| 542 | top_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 543 | r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 544 | PatBlt( hdc, r.left + thumbSize, r.top,
|
|---|
| 545 | r.right - r.left - thumbSize,
|
|---|
| 546 | r.bottom - r.top,
|
|---|
| 547 | bottom_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 548 | r.right = r.left + thumbSize;
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | /* Draw the thumb */
|
|---|
| 552 | DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT | BF_MIDDLE );
|
|---|
| 553 |
|
|---|
| 554 | /* cleanup */
|
|---|
| 555 | SelectObject( hdc, hSavePen );
|
|---|
| 556 | SelectObject( hdc, hSaveBrush );
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 | static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar,
|
|---|
| 561 | RECT *rect, INT arrowSize,
|
|---|
| 562 | INT thumbSize, INT thumbPos,
|
|---|
| 563 | UINT flags, BOOL vertical,
|
|---|
| 564 | BOOL top_selected, BOOL bottom_selected )
|
|---|
| 565 | {
|
|---|
| 566 | RECT r;
|
|---|
| 567 | HPEN hSavePen;
|
|---|
| 568 | HBRUSH hSaveBrush,hBrush;
|
|---|
| 569 | BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
|
|---|
| 570 |
|
|---|
| 571 | if (Save_SCROLL_MovingThumb &&
|
|---|
| 572 | (SCROLL_TrackingWin == hwnd) &&
|
|---|
| 573 | (SCROLL_TrackingBar == nBar))
|
|---|
| 574 | SCROLL_DrawMovingThumb( hdc, rect, vertical, arrowSize, thumbSize );
|
|---|
| 575 |
|
|---|
| 576 | /* Select the correct brush and pen */
|
|---|
| 577 |
|
|---|
| 578 | /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
|
|---|
| 579 | * The window-owned scrollbars need to call DEFWND_ControlColor
|
|---|
| 580 | * to correctly setup default scrollbar colors
|
|---|
| 581 | */
|
|---|
| 582 | if (nBar == SB_CTL) {
|
|---|
| 583 | hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
|
|---|
| 584 | (WPARAM)hdc,(LPARAM)hwnd);
|
|---|
| 585 | } else {
|
|---|
| 586 | //CB: implement!
|
|---|
| 587 | //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
|
|---|
| 591 | hSaveBrush = SelectObject( hdc, hBrush );
|
|---|
| 592 |
|
|---|
| 593 | /* Calculate the scroll rectangle */
|
|---|
| 594 |
|
|---|
| 595 | r = *rect;
|
|---|
| 596 | if (vertical)
|
|---|
| 597 | {
|
|---|
| 598 | r.top += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
|---|
| 599 | r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 600 | }
|
|---|
| 601 | else
|
|---|
| 602 | {
|
|---|
| 603 | r.left += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
|
|---|
| 604 | r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 | /* Draw the scroll bar frame */
|
|---|
| 608 |
|
|---|
| 609 | /* Only draw outline if Win 3.1. Mar 24, 1999 - Ronald B. Cemer */
|
|---|
| 610 |
|
|---|
| 611 | /* Draw the scroll rectangles and thumb */
|
|---|
| 612 |
|
|---|
| 613 | if (!thumbPos) /* No thumb to draw */
|
|---|
| 614 | {
|
|---|
| 615 | INT offset = 0;
|
|---|
| 616 |
|
|---|
| 617 | PatBlt( hdc, r.left+offset, r.top+offset,
|
|---|
| 618 | r.right - r.left - 2*offset, r.bottom - r.top - 2*offset,
|
|---|
| 619 | PATCOPY );
|
|---|
| 620 |
|
|---|
| 621 | /* cleanup and return */
|
|---|
| 622 | SelectObject( hdc, hSavePen );
|
|---|
| 623 | SelectObject( hdc, hSaveBrush );
|
|---|
| 624 | return;
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | if (vertical)
|
|---|
| 628 | {
|
|---|
| 629 | INT offset = 0;
|
|---|
| 630 |
|
|---|
| 631 | PatBlt( hdc, r.left + offset, r.top + offset,
|
|---|
| 632 | r.right - r.left - offset*2,
|
|---|
| 633 | thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - offset,
|
|---|
| 634 | top_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 635 | r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 636 | PatBlt( hdc, r.left + offset, r.top + thumbSize,
|
|---|
| 637 | r.right - r.left - offset*2,
|
|---|
| 638 | r.bottom - r.top - thumbSize - offset,
|
|---|
| 639 | bottom_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 640 | r.bottom = r.top + thumbSize;
|
|---|
| 641 | }
|
|---|
| 642 | else /* horizontal */
|
|---|
| 643 | {
|
|---|
| 644 | INT offset = 0;
|
|---|
| 645 |
|
|---|
| 646 | PatBlt( hdc, r.left + offset, r.top + offset,
|
|---|
| 647 | thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
|
|---|
| 648 | r.bottom - r.top - offset*2,
|
|---|
| 649 | top_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 650 | r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
|
|---|
| 651 | PatBlt( hdc, r.left + thumbSize, r.top + offset,
|
|---|
| 652 | r.right - r.left - thumbSize - offset,
|
|---|
| 653 | r.bottom - r.top - offset*2,
|
|---|
| 654 | bottom_selected ? 0x0f0000 : PATCOPY );
|
|---|
| 655 | r.right = r.left + thumbSize;
|
|---|
| 656 | }
|
|---|
| 657 |
|
|---|
| 658 | /* Draw the thumb */
|
|---|
| 659 |
|
|---|
| 660 | SelectObject( hdc, GetSysColorBrush(COLOR_BTNFACE) );
|
|---|
| 661 |
|
|---|
| 662 | Rectangle( hdc, r.left+1, r.top+1, r.right-1, r.bottom-1 );
|
|---|
| 663 |
|
|---|
| 664 | DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT );
|
|---|
| 665 |
|
|---|
| 666 | if (Save_SCROLL_MovingThumb &&
|
|---|
| 667 | (SCROLL_TrackingWin == hwnd) &&
|
|---|
| 668 | (SCROLL_TrackingBar == nBar))
|
|---|
| 669 | SCROLL_DrawMovingThumb( hdc, rect, vertical, arrowSize, thumbSize );
|
|---|
| 670 |
|
|---|
| 671 | /* cleanup */
|
|---|
| 672 | SelectObject( hdc, hSavePen );
|
|---|
| 673 | SelectObject( hdc, hSaveBrush );
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | /***********************************************************************
|
|---|
| 677 | * SCROLL_DrawScrollBar
|
|---|
| 678 | *
|
|---|
| 679 | * Redraw the whole scrollbar.
|
|---|
| 680 | */
|
|---|
| 681 | void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar,
|
|---|
| 682 | BOOL arrows, BOOL interior )
|
|---|
| 683 | {
|
|---|
| 684 | INT arrowSize, thumbSize, thumbPos;
|
|---|
| 685 | RECT rect;
|
|---|
| 686 | BOOL vertical;
|
|---|
| 687 | SCROLLBAR_INFO *infoPtr = SCROLL_GetPtrScrollInfo( hwnd, nBar );
|
|---|
| 688 | BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
|
|---|
| 689 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 690 |
|
|---|
| 691 | if (!infoPtr ||
|
|---|
| 692 | ((nBar == SB_VERT) && !(dwStyle & WS_VSCROLL)) ||
|
|---|
| 693 | ((nBar == SB_HORZ) && !(dwStyle & WS_HSCROLL))) return;
|
|---|
| 694 | //if (!WIN_IsWindowDrawable( hwnd, FALSE )) return; //CB: what's that???
|
|---|
| 695 |
|
|---|
| 696 | vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
|---|
| 697 | &arrowSize, &thumbSize, &thumbPos );
|
|---|
| 698 |
|
|---|
| 699 | if (Save_SCROLL_MovingThumb &&
|
|---|
| 700 | (SCROLL_TrackingWin == hwnd) &&
|
|---|
| 701 | (SCROLL_TrackingBar == nBar))
|
|---|
| 702 | SCROLL_DrawMovingThumb( hdc, &rect, vertical, arrowSize, thumbSize );
|
|---|
| 703 |
|
|---|
| 704 | /* Draw the arrows */
|
|---|
| 705 |
|
|---|
| 706 | if (arrows && arrowSize)
|
|---|
| 707 | {
|
|---|
| 708 | if( vertical == SCROLL_trackVertical && GetCapture() == hwnd )
|
|---|
| 709 | SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
|
|---|
| 710 | (SCROLL_trackHitTest == SCROLL_TOP_ARROW),
|
|---|
| 711 | (SCROLL_trackHitTest == SCROLL_BOTTOM_ARROW) );
|
|---|
| 712 | else
|
|---|
| 713 | SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
|
|---|
| 714 | FALSE, FALSE );
|
|---|
| 715 | }
|
|---|
| 716 | if( interior )
|
|---|
| 717 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
|---|
| 718 | thumbPos, infoPtr->flags, vertical, FALSE, FALSE );
|
|---|
| 719 |
|
|---|
| 720 | if (Save_SCROLL_MovingThumb &&
|
|---|
| 721 | (SCROLL_TrackingWin == hwnd) &&
|
|---|
| 722 | (SCROLL_TrackingBar == nBar))
|
|---|
| 723 | SCROLL_DrawMovingThumb( hdc, &rect, vertical, arrowSize, thumbSize );
|
|---|
| 724 |
|
|---|
| 725 | }
|
|---|
| 726 |
|
|---|
| 727 |
|
|---|
| 728 | /***********************************************************************
|
|---|
| 729 | * SCROLL_RefreshScrollBar
|
|---|
| 730 | *
|
|---|
| 731 | * Repaint the scroll bar interior after a SetScrollRange() or
|
|---|
| 732 | * SetScrollPos() call.
|
|---|
| 733 | */
|
|---|
| 734 | static void SCROLL_RefreshScrollBar( HWND hwnd, INT nBar,
|
|---|
| 735 | BOOL arrows, BOOL interior )
|
|---|
| 736 | {
|
|---|
| 737 | HDC hdc = GetDCEx( hwnd, 0,
|
|---|
| 738 | DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) );
|
|---|
| 739 | if (!hdc) return;
|
|---|
| 740 |
|
|---|
| 741 | SCROLL_DrawScrollBar( hwnd, hdc, nBar, arrows, interior );
|
|---|
| 742 | ReleaseDC( hwnd, hdc );
|
|---|
| 743 | }
|
|---|
| 744 |
|
|---|
| 745 |
|
|---|
| 746 | /***********************************************************************
|
|---|
| 747 | * SCROLL_HandleKbdEvent
|
|---|
| 748 | *
|
|---|
| 749 | * Handle a keyboard event (only for SB_CTL scrollbars).
|
|---|
| 750 | */
|
|---|
| 751 | static void SCROLL_HandleKbdEvent( HWND hwnd, WPARAM wParam )
|
|---|
| 752 | {
|
|---|
| 753 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 754 | WPARAM msg;
|
|---|
| 755 |
|
|---|
| 756 | switch(wParam)
|
|---|
| 757 | {
|
|---|
| 758 | case VK_PRIOR: msg = SB_PAGEUP; break;
|
|---|
| 759 | case VK_NEXT: msg = SB_PAGEDOWN; break;
|
|---|
| 760 | case VK_HOME: msg = SB_TOP; break;
|
|---|
| 761 | case VK_END: msg = SB_BOTTOM; break;
|
|---|
| 762 | case VK_UP: msg = SB_LINEUP; break;
|
|---|
| 763 | case VK_DOWN: msg = SB_LINEDOWN; break;
|
|---|
| 764 | default:
|
|---|
| 765 | return;
|
|---|
| 766 | }
|
|---|
| 767 | SendMessageA( GetParent(hwnd),
|
|---|
| 768 | (dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 769 | msg, hwnd );
|
|---|
| 770 | }
|
|---|
| 771 |
|
|---|
| 772 |
|
|---|
| 773 | /***********************************************************************
|
|---|
| 774 | * SCROLL_HandleScrollEvent
|
|---|
| 775 | *
|
|---|
| 776 | * Handle a mouse or timer event for the scrollbar.
|
|---|
| 777 | * 'pt' is the location of the mouse event in client (for SB_CTL) or
|
|---|
| 778 | * windows coordinates.
|
|---|
| 779 | */
|
|---|
| 780 | void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
|
|---|
| 781 | {
|
|---|
| 782 | /* Previous mouse position for timer events */
|
|---|
| 783 | static POINT prevPt;
|
|---|
| 784 | /* Thumb position when tracking started. */
|
|---|
| 785 | static UINT trackThumbPos;
|
|---|
| 786 | /* Position in the scroll-bar of the last button-down event. */
|
|---|
| 787 | static INT lastClickPos;
|
|---|
| 788 | /* Position in the scroll-bar of the last mouse event. */
|
|---|
| 789 | static INT lastMousePos;
|
|---|
| 790 |
|
|---|
| 791 | enum SCROLL_HITTEST hittest;
|
|---|
| 792 | HWND hwndOwner, hwndCtl;
|
|---|
| 793 | BOOL vertical;
|
|---|
| 794 | INT arrowSize, thumbSize, thumbPos;
|
|---|
| 795 | RECT rect;
|
|---|
| 796 | HDC hdc;
|
|---|
| 797 |
|
|---|
| 798 | SCROLLBAR_INFO *infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
|
|---|
| 799 | if (!infoPtr) return;
|
|---|
| 800 | if ((SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN))
|
|---|
| 801 | return;
|
|---|
| 802 |
|
|---|
| 803 | hdc = GetDCEx( hwnd, 0, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
|
|---|
| 804 | vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
|
|---|
| 805 | &arrowSize, &thumbSize, &thumbPos );
|
|---|
| 806 | hwndOwner = (nBar == SB_CTL) ? GetParent(hwnd) : hwnd;
|
|---|
| 807 | hwndCtl = (nBar == SB_CTL) ? hwnd : 0;
|
|---|
| 808 |
|
|---|
| 809 | switch(msg)
|
|---|
| 810 | {
|
|---|
| 811 | case WM_LBUTTONDOWN: /* Initialise mouse tracking */
|
|---|
| 812 | SCROLL_trackVertical = vertical;
|
|---|
| 813 | SCROLL_trackHitTest = hittest = SCROLL_HitTest( hwnd, nBar, pt, FALSE );
|
|---|
| 814 | lastClickPos = vertical ? (pt.y - rect.top) : (pt.x - rect.left);
|
|---|
| 815 | lastMousePos = lastClickPos;
|
|---|
| 816 | trackThumbPos = thumbPos;
|
|---|
| 817 | prevPt = pt;
|
|---|
| 818 | SetCapture( hwnd );
|
|---|
| 819 | if (nBar == SB_CTL) SetFocus( hwnd );
|
|---|
| 820 | break;
|
|---|
| 821 |
|
|---|
| 822 | case WM_MOUSEMOVE:
|
|---|
| 823 | hittest = SCROLL_HitTest( hwnd, nBar, pt, TRUE );
|
|---|
| 824 | prevPt = pt;
|
|---|
| 825 | break;
|
|---|
| 826 |
|
|---|
| 827 | case WM_LBUTTONUP:
|
|---|
| 828 | hittest = SCROLL_NOWHERE;
|
|---|
| 829 | ReleaseCapture();
|
|---|
| 830 | break;
|
|---|
| 831 |
|
|---|
| 832 | case WM_SYSTIMER:
|
|---|
| 833 | pt = prevPt;
|
|---|
| 834 | hittest = SCROLL_HitTest( hwnd, nBar, pt, FALSE );
|
|---|
| 835 | break;
|
|---|
| 836 |
|
|---|
| 837 | default:
|
|---|
| 838 | return; /* Should never happen */
|
|---|
| 839 | }
|
|---|
| 840 |
|
|---|
| 841 | //TRACE("Event: hwnd=%04x bar=%d msg=%x pt=%ld,%ld hit=%d\n",
|
|---|
| 842 | // hwnd, nBar, msg, pt.x, pt.y, hittest );
|
|---|
| 843 |
|
|---|
| 844 | switch(SCROLL_trackHitTest)
|
|---|
| 845 | {
|
|---|
| 846 | case SCROLL_NOWHERE: /* No tracking in progress */
|
|---|
| 847 | break;
|
|---|
| 848 |
|
|---|
| 849 | case SCROLL_TOP_ARROW:
|
|---|
| 850 | SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
|
|---|
| 851 | (hittest == SCROLL_trackHitTest), FALSE );
|
|---|
| 852 | if (hittest == SCROLL_trackHitTest)
|
|---|
| 853 | {
|
|---|
| 854 | if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
|
|---|
| 855 | {
|
|---|
| 856 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 857 | SB_LINEUP, hwndCtl );
|
|---|
| 858 | }
|
|---|
| 859 | //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
|---|
| 860 | // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
|---|
| 861 | // (TIMERPROC)0 );
|
|---|
| 862 | }
|
|---|
| 863 | //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
|
|---|
| 864 | break;
|
|---|
| 865 |
|
|---|
| 866 | case SCROLL_TOP_RECT:
|
|---|
| 867 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
|---|
| 868 | thumbPos, infoPtr->flags, vertical,
|
|---|
| 869 | (hittest == SCROLL_trackHitTest), FALSE );
|
|---|
| 870 | if (hittest == SCROLL_trackHitTest)
|
|---|
| 871 | {
|
|---|
| 872 | if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
|
|---|
| 873 | {
|
|---|
| 874 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 875 | SB_PAGEUP, hwndCtl );
|
|---|
| 876 | //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
|---|
| 877 | // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
|---|
| 878 | // (TIMERPROC)0 );
|
|---|
| 879 | }
|
|---|
| 880 | }
|
|---|
| 881 | //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
|
|---|
| 882 | break;
|
|---|
| 883 |
|
|---|
| 884 | case SCROLL_THUMB:
|
|---|
| 885 | if (msg == WM_LBUTTONDOWN)
|
|---|
| 886 | {
|
|---|
| 887 | SCROLL_TrackingWin = hwnd;
|
|---|
| 888 | SCROLL_TrackingBar = nBar;
|
|---|
| 889 | SCROLL_TrackingPos = trackThumbPos + lastMousePos - lastClickPos;
|
|---|
| 890 | if (!SCROLL_MovingThumb)
|
|---|
| 891 | SCROLL_DrawMovingThumb(hdc, &rect, vertical, arrowSize, thumbSize);
|
|---|
| 892 | }
|
|---|
| 893 | else if (msg == WM_LBUTTONUP)
|
|---|
| 894 | {
|
|---|
| 895 | if (SCROLL_MovingThumb)
|
|---|
| 896 | SCROLL_DrawMovingThumb(hdc, &rect, vertical, arrowSize, thumbSize);
|
|---|
| 897 | SCROLL_TrackingWin = 0;
|
|---|
| 898 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
|---|
| 899 | thumbPos, infoPtr->flags, vertical,
|
|---|
| 900 | FALSE, FALSE );
|
|---|
| 901 | }
|
|---|
| 902 | else /* WM_MOUSEMOVE */
|
|---|
| 903 | {
|
|---|
| 904 | UINT pos;
|
|---|
| 905 |
|
|---|
| 906 | if (!SCROLL_PtInRectEx( &rect, pt, vertical )) pos = lastClickPos;
|
|---|
| 907 | else
|
|---|
| 908 | {
|
|---|
| 909 | pt = SCROLL_ClipPos( &rect, pt );
|
|---|
| 910 | pos = vertical ? (pt.y - rect.top) : (pt.x - rect.left);
|
|---|
| 911 | }
|
|---|
| 912 | if ( (pos != lastMousePos) || (!SCROLL_MovingThumb) )
|
|---|
| 913 | {
|
|---|
| 914 | if (SCROLL_MovingThumb)
|
|---|
| 915 | SCROLL_DrawMovingThumb( hdc, &rect, vertical,
|
|---|
| 916 | arrowSize, thumbSize );
|
|---|
| 917 | lastMousePos = pos;
|
|---|
| 918 | SCROLL_TrackingPos = trackThumbPos + pos - lastClickPos;
|
|---|
| 919 | SCROLL_TrackingVal = SCROLL_GetThumbVal( infoPtr, &rect,
|
|---|
| 920 | vertical,
|
|---|
| 921 | SCROLL_TrackingPos );
|
|---|
| 922 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 923 | MAKEWPARAM( SB_THUMBTRACK, SCROLL_TrackingVal),
|
|---|
| 924 | hwndCtl );
|
|---|
| 925 | if (!SCROLL_MovingThumb)
|
|---|
| 926 | SCROLL_DrawMovingThumb( hdc, &rect, vertical,
|
|---|
| 927 | arrowSize, thumbSize );
|
|---|
| 928 | }
|
|---|
| 929 | }
|
|---|
| 930 | break;
|
|---|
| 931 |
|
|---|
| 932 | case SCROLL_BOTTOM_RECT:
|
|---|
| 933 | SCROLL_DrawInterior( hwnd, hdc, nBar, &rect, arrowSize, thumbSize,
|
|---|
| 934 | thumbPos, infoPtr->flags, vertical,
|
|---|
| 935 | FALSE, (hittest == SCROLL_trackHitTest) );
|
|---|
| 936 | if (hittest == SCROLL_trackHitTest)
|
|---|
| 937 | {
|
|---|
| 938 | if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
|
|---|
| 939 | {
|
|---|
| 940 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 941 | SB_PAGEDOWN, hwndCtl );
|
|---|
| 942 | //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
|---|
| 943 | // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
|---|
| 944 | // (TIMERPROC)0 );
|
|---|
| 945 | }
|
|---|
| 946 | }
|
|---|
| 947 | //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
|
|---|
| 948 | break;
|
|---|
| 949 |
|
|---|
| 950 | case SCROLL_BOTTOM_ARROW:
|
|---|
| 951 | SCROLL_DrawArrows( hdc, infoPtr, &rect, arrowSize, vertical,
|
|---|
| 952 | FALSE, (hittest == SCROLL_trackHitTest) );
|
|---|
| 953 | if (hittest == SCROLL_trackHitTest)
|
|---|
| 954 | {
|
|---|
| 955 | if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
|
|---|
| 956 | {
|
|---|
| 957 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 958 | SB_LINEDOWN, hwndCtl );
|
|---|
| 959 | }
|
|---|
| 960 | //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
|
|---|
| 961 | // SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
|
|---|
| 962 | // (TIMERPROC)0 );
|
|---|
| 963 | }
|
|---|
| 964 | //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
|
|---|
| 965 | break;
|
|---|
| 966 | }
|
|---|
| 967 |
|
|---|
| 968 | if (msg == WM_LBUTTONUP)
|
|---|
| 969 | {
|
|---|
| 970 | hittest = SCROLL_trackHitTest;
|
|---|
| 971 | SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */
|
|---|
| 972 |
|
|---|
| 973 | if (hittest == SCROLL_THUMB)
|
|---|
| 974 | {
|
|---|
| 975 | UINT val = SCROLL_GetThumbVal( infoPtr, &rect, vertical,
|
|---|
| 976 | trackThumbPos + lastMousePos - lastClickPos );
|
|---|
| 977 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 978 | MAKEWPARAM( SB_THUMBPOSITION, val ), hwndCtl );
|
|---|
| 979 | }
|
|---|
| 980 | else
|
|---|
| 981 | SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
|
|---|
| 982 | SB_ENDSCROLL, hwndCtl );
|
|---|
| 983 | }
|
|---|
| 984 |
|
|---|
| 985 | ReleaseDC( hwnd, hdc );
|
|---|
| 986 | }
|
|---|
| 987 |
|
|---|
| 988 |
|
|---|
| 989 | /***********************************************************************
|
|---|
| 990 | * ScrollBarWndProc
|
|---|
| 991 | */
|
|---|
| 992 | LRESULT WINAPI ScrollBarWndProc( HWND hwnd, UINT message, WPARAM wParam,
|
|---|
| 993 | LPARAM lParam )
|
|---|
| 994 | {
|
|---|
| 995 | switch(message)
|
|---|
| 996 | {
|
|---|
| 997 | case WM_CREATE:
|
|---|
| 998 | {
|
|---|
| 999 | CREATESTRUCTA *lpCreat = (CREATESTRUCTA *)lParam;
|
|---|
| 1000 | if (lpCreat->style & SBS_SIZEBOX)
|
|---|
| 1001 | {
|
|---|
| 1002 | //FIXME("Unimplemented style SBS_SIZEBOX.\n" );
|
|---|
| 1003 | return 0;
|
|---|
| 1004 | }
|
|---|
| 1005 |
|
|---|
| 1006 | if (lpCreat->style & SBS_VERT)
|
|---|
| 1007 | {
|
|---|
| 1008 | if (lpCreat->style & SBS_LEFTALIGN)
|
|---|
| 1009 | MoveWindow( hwnd, lpCreat->x, lpCreat->y,
|
|---|
| 1010 | GetSystemMetrics(SM_CXVSCROLL)+1, lpCreat->cy, FALSE );
|
|---|
| 1011 | else if (lpCreat->style & SBS_RIGHTALIGN)
|
|---|
| 1012 | MoveWindow( hwnd,
|
|---|
| 1013 | lpCreat->x+lpCreat->cx-GetSystemMetrics(SM_CXVSCROLL)-1,
|
|---|
| 1014 | lpCreat->y,
|
|---|
| 1015 | GetSystemMetrics(SM_CXVSCROLL)+1, lpCreat->cy, FALSE );
|
|---|
| 1016 | }
|
|---|
| 1017 | else /* SBS_HORZ */
|
|---|
| 1018 | {
|
|---|
| 1019 | if (lpCreat->style & SBS_TOPALIGN)
|
|---|
| 1020 | MoveWindow( hwnd, lpCreat->x, lpCreat->y,
|
|---|
| 1021 | lpCreat->cx, GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
|
|---|
| 1022 | else if (lpCreat->style & SBS_BOTTOMALIGN)
|
|---|
| 1023 | MoveWindow( hwnd,
|
|---|
| 1024 | lpCreat->x,
|
|---|
| 1025 | lpCreat->y+lpCreat->cy-GetSystemMetrics(SM_CYHSCROLL)-1,
|
|---|
| 1026 | lpCreat->cx, GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
|
|---|
| 1027 | }
|
|---|
| 1028 | }
|
|---|
| 1029 | if (!hUpArrow) SCROLL_LoadBitmaps();
|
|---|
| 1030 | //TRACE("ScrollBar creation, hwnd=%04x\n", hwnd );
|
|---|
| 1031 | return 0;
|
|---|
| 1032 |
|
|---|
| 1033 | case WM_LBUTTONDOWN:
|
|---|
| 1034 | case WM_LBUTTONUP:
|
|---|
| 1035 | case WM_MOUSEMOVE:
|
|---|
| 1036 | case WM_SYSTIMER:
|
|---|
| 1037 | {
|
|---|
| 1038 | POINT pt;
|
|---|
| 1039 | CONV_POINT16TO32( (POINT16 *)&lParam, &pt );
|
|---|
| 1040 | SCROLL_HandleScrollEvent( hwnd, SB_CTL, message, pt );
|
|---|
| 1041 | }
|
|---|
| 1042 | break;
|
|---|
| 1043 |
|
|---|
| 1044 | case WM_KEYDOWN:
|
|---|
| 1045 | SCROLL_HandleKbdEvent( hwnd, wParam );
|
|---|
| 1046 | break;
|
|---|
| 1047 |
|
|---|
| 1048 | case WM_ERASEBKGND:
|
|---|
| 1049 | return 1;
|
|---|
| 1050 |
|
|---|
| 1051 | case WM_GETDLGCODE:
|
|---|
| 1052 | return DLGC_WANTARROWS; /* Windows returns this value */
|
|---|
| 1053 |
|
|---|
| 1054 | case WM_PAINT:
|
|---|
| 1055 | {
|
|---|
| 1056 | PAINTSTRUCT ps;
|
|---|
| 1057 | HDC hdc = BeginPaint( hwnd, &ps );
|
|---|
| 1058 | SCROLL_DrawScrollBar( hwnd, hdc, SB_CTL, TRUE, TRUE );
|
|---|
| 1059 | EndPaint( hwnd, &ps );
|
|---|
| 1060 | }
|
|---|
| 1061 | break;
|
|---|
| 1062 |
|
|---|
| 1063 | case SBM_SETPOS:
|
|---|
| 1064 | return SetScrollPos( hwnd, SB_CTL, wParam, (BOOL)lParam );
|
|---|
| 1065 |
|
|---|
| 1066 | case SBM_GETPOS:
|
|---|
| 1067 | return GetScrollPos( hwnd, SB_CTL );
|
|---|
| 1068 |
|
|---|
| 1069 | case SBM_SETRANGE:
|
|---|
| 1070 | SetScrollRange( hwnd, SB_CTL, wParam, lParam, FALSE );
|
|---|
| 1071 | return 0; /* FIXME: return previous position */
|
|---|
| 1072 |
|
|---|
| 1073 | case SBM_GETRANGE:
|
|---|
| 1074 | GetScrollRange( hwnd, SB_CTL, (LPINT)wParam, (LPINT)lParam );
|
|---|
| 1075 | return 0;
|
|---|
| 1076 |
|
|---|
| 1077 | case SBM_ENABLE_ARROWS:
|
|---|
| 1078 | return EnableScrollBar( hwnd, SB_CTL, wParam );
|
|---|
| 1079 |
|
|---|
| 1080 | case SBM_SETRANGEREDRAW:
|
|---|
| 1081 | SetScrollRange( hwnd, SB_CTL, wParam, lParam, TRUE );
|
|---|
| 1082 | return 0; /* FIXME: return previous position */
|
|---|
| 1083 |
|
|---|
| 1084 | case SBM_SETSCROLLINFO:
|
|---|
| 1085 | return SetScrollInfo( hwnd, SB_CTL, (SCROLLINFO *)lParam, wParam );
|
|---|
| 1086 |
|
|---|
| 1087 | case SBM_GETSCROLLINFO:
|
|---|
| 1088 | return GetScrollInfo( hwnd, SB_CTL, (SCROLLINFO *)lParam );
|
|---|
| 1089 |
|
|---|
| 1090 | case 0x00e5:
|
|---|
| 1091 | case 0x00e7:
|
|---|
| 1092 | case 0x00e8:
|
|---|
| 1093 | case 0x00eb:
|
|---|
| 1094 | case 0x00ec:
|
|---|
| 1095 | case 0x00ed:
|
|---|
| 1096 | case 0x00ee:
|
|---|
| 1097 | case 0x00ef:
|
|---|
| 1098 | //ERR("unknown Win32 msg %04x wp=%08x lp=%08lx\n",
|
|---|
| 1099 | // message, wParam, lParam );
|
|---|
| 1100 | break;
|
|---|
| 1101 |
|
|---|
| 1102 | default:
|
|---|
| 1103 | if (message >= WM_USER)
|
|---|
| 1104 | //WARN("unknown msg %04x wp=%04x lp=%08lx\n",
|
|---|
| 1105 | // message, wParam, lParam );
|
|---|
| 1106 | return DefWindowProcA( hwnd, message, wParam, lParam );
|
|---|
| 1107 | }
|
|---|
| 1108 | return 0;
|
|---|
| 1109 | }
|
|---|
| 1110 |
|
|---|
| 1111 |
|
|---|
| 1112 | /*************************************************************************
|
|---|
| 1113 | * SetScrollInfo32 (USER32.501)
|
|---|
| 1114 | * SetScrollInfo32 can be used to set the position, upper bound,
|
|---|
| 1115 | * lower bound, and page size of a scrollbar control.
|
|---|
| 1116 | *
|
|---|
| 1117 | * RETURNS
|
|---|
| 1118 | * Scrollbar position
|
|---|
| 1119 | *
|
|---|
| 1120 | * NOTE
|
|---|
| 1121 | * For 100 lines of text to be displayed in a window of 25 lines,
|
|---|
| 1122 | * one would for instance use info->nMin=0, info->nMax=75
|
|---|
| 1123 | * (corresponding to the 76 different positions of the window on
|
|---|
| 1124 | * the text), and info->nPage=25.
|
|---|
| 1125 | */
|
|---|
| 1126 | /* CB:
|
|---|
| 1127 |
|
|---|
| 1128 | INT WINAPI SetScrollInfo(
|
|---|
| 1129 | HWND hwnd / * [I] Handle of window whose scrollbar will be affected * /,
|
|---|
| 1130 | INT nBar / * [I] One of SB_HORZ, SB_VERT, or SB_CTL * /,
|
|---|
| 1131 | const SCROLLINFO *info / * [I] Specifies what to change and new values * /,
|
|---|
| 1132 | BOOL bRedraw / * [I] Should scrollbar be redrawn afterwards ? * /)
|
|---|
| 1133 | {
|
|---|
| 1134 | INT action;
|
|---|
| 1135 | INT retVal = SCROLL_SetScrollInfo( hwnd, nBar, info, &action );
|
|---|
| 1136 |
|
|---|
| 1137 | if( action & SA_SSI_HIDE )
|
|---|
| 1138 | SCROLL_ShowScrollBar( hwnd, nBar, FALSE, FALSE );
|
|---|
| 1139 | else
|
|---|
| 1140 | {
|
|---|
| 1141 | if( action & SA_SSI_SHOW )
|
|---|
| 1142 | if( SCROLL_ShowScrollBar( hwnd, nBar, TRUE, TRUE ) )
|
|---|
| 1143 | return retVal; / * SetWindowPos() already did the painting * /
|
|---|
| 1144 |
|
|---|
| 1145 | if( bRedraw && (action & SA_SSI_REFRESH))
|
|---|
| 1146 | SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
|
|---|
| 1147 | else if( action & SA_SSI_REPAINT_ARROWS )
|
|---|
| 1148 | SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, FALSE );
|
|---|
| 1149 | }
|
|---|
| 1150 | return retVal;
|
|---|
| 1151 | } */
|
|---|
| 1152 |
|
|---|
| 1153 | INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar,
|
|---|
| 1154 | const SCROLLINFO *info, INT *action )
|
|---|
| 1155 | {
|
|---|
| 1156 | /* Update the scrollbar state and set action flags according to
|
|---|
| 1157 | * what has to be done graphics wise. */
|
|---|
| 1158 |
|
|---|
| 1159 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1160 | UINT new_flags;
|
|---|
| 1161 |
|
|---|
| 1162 | //dbg_decl_str(scroll, 256);
|
|---|
| 1163 |
|
|---|
| 1164 | *action = 0;
|
|---|
| 1165 |
|
|---|
| 1166 | if (!(infoPtr = SCROLL_GetScrollInfo(hwnd, nBar))) return 0;
|
|---|
| 1167 | if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return 0;
|
|---|
| 1168 | if ((info->cbSize != sizeof(*info)) &&
|
|---|
| 1169 | (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return 0;
|
|---|
| 1170 |
|
|---|
| 1171 | /* Set the page size */
|
|---|
| 1172 |
|
|---|
| 1173 | if (info->fMask & SIF_PAGE)
|
|---|
| 1174 | {
|
|---|
| 1175 | //dsprintf(scroll, " page=%d", info->nPage );
|
|---|
| 1176 | if( infoPtr->Page != info->nPage )
|
|---|
| 1177 | {
|
|---|
| 1178 | infoPtr->Page = info->nPage;
|
|---|
| 1179 | *action |= SA_SSI_REFRESH;
|
|---|
| 1180 | }
|
|---|
| 1181 | }
|
|---|
| 1182 |
|
|---|
| 1183 | /* Set the scroll pos */
|
|---|
| 1184 |
|
|---|
| 1185 | if (info->fMask & SIF_POS)
|
|---|
| 1186 | {
|
|---|
| 1187 | //dsprintf(scroll, " pos=%d", info->nPos );
|
|---|
| 1188 | if( infoPtr->CurVal != info->nPos )
|
|---|
| 1189 | {
|
|---|
| 1190 | infoPtr->CurVal = info->nPos;
|
|---|
| 1191 | *action |= SA_SSI_REFRESH;
|
|---|
| 1192 | }
|
|---|
| 1193 | }
|
|---|
| 1194 |
|
|---|
| 1195 | /* Set the scroll range */
|
|---|
| 1196 |
|
|---|
| 1197 | if (info->fMask & SIF_RANGE)
|
|---|
| 1198 | {
|
|---|
| 1199 | //dsprintf(scroll, " min=%d max=%d", info->nMin, info->nMax );
|
|---|
| 1200 |
|
|---|
| 1201 | /* Invalid range -> range is set to (0,0) */
|
|---|
| 1202 | if ((info->nMin > info->nMax) ||
|
|---|
| 1203 | ((UINT)(info->nMax - info->nMin) >= 0x80000000))
|
|---|
| 1204 | {
|
|---|
| 1205 | infoPtr->MinVal = 0;
|
|---|
| 1206 | infoPtr->MaxVal = 0;
|
|---|
| 1207 | }
|
|---|
| 1208 | else
|
|---|
| 1209 | {
|
|---|
| 1210 | if( infoPtr->MinVal != info->nMin ||
|
|---|
| 1211 | infoPtr->MaxVal != info->nMax )
|
|---|
| 1212 | {
|
|---|
| 1213 | *action |= SA_SSI_REFRESH;
|
|---|
| 1214 | infoPtr->MinVal = info->nMin;
|
|---|
| 1215 | infoPtr->MaxVal = info->nMax;
|
|---|
| 1216 | }
|
|---|
| 1217 | }
|
|---|
| 1218 | }
|
|---|
| 1219 |
|
|---|
| 1220 | //TRACE("hwnd=%04x bar=%d %s\n",
|
|---|
| 1221 | // hwnd, nBar, dbg_str(scroll));
|
|---|
| 1222 |
|
|---|
| 1223 | /* Make sure the page size is valid */
|
|---|
| 1224 |
|
|---|
| 1225 | if (infoPtr->Page < 0) infoPtr->Page = 0;
|
|---|
| 1226 | else if (infoPtr->Page > infoPtr->MaxVal - infoPtr->MinVal + 1 )
|
|---|
| 1227 | infoPtr->Page = infoPtr->MaxVal - infoPtr->MinVal + 1;
|
|---|
| 1228 |
|
|---|
| 1229 | /* Make sure the pos is inside the range */
|
|---|
| 1230 |
|
|---|
| 1231 | if (infoPtr->CurVal < infoPtr->MinVal)
|
|---|
| 1232 | infoPtr->CurVal = infoPtr->MinVal;
|
|---|
| 1233 | else if (infoPtr->CurVal > infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
|
|---|
| 1234 | infoPtr->CurVal = infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 );
|
|---|
| 1235 |
|
|---|
| 1236 | //TRACE(" new values: page=%d pos=%d min=%d max=%d\n",
|
|---|
| 1237 | // infoPtr->Page, infoPtr->CurVal,
|
|---|
| 1238 | // infoPtr->MinVal, infoPtr->MaxVal );
|
|---|
| 1239 |
|
|---|
| 1240 | /* Check if the scrollbar should be hidden or disabled */
|
|---|
| 1241 |
|
|---|
| 1242 | if (info->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
|
|---|
| 1243 | {
|
|---|
| 1244 | new_flags = infoPtr->flags;
|
|---|
| 1245 | if (infoPtr->MinVal >= infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
|
|---|
| 1246 | {
|
|---|
| 1247 | /* Hide or disable scroll-bar */
|
|---|
| 1248 | if (info->fMask & SIF_DISABLENOSCROLL)
|
|---|
| 1249 | {
|
|---|
| 1250 | new_flags = ESB_DISABLE_BOTH;
|
|---|
| 1251 | *action |= SA_SSI_REFRESH;
|
|---|
| 1252 | }
|
|---|
| 1253 | else if (nBar != SB_CTL)
|
|---|
| 1254 | {
|
|---|
| 1255 | *action = SA_SSI_HIDE;
|
|---|
| 1256 | goto done;
|
|---|
| 1257 | }
|
|---|
| 1258 | }
|
|---|
| 1259 | else /* Show and enable scroll-bar */
|
|---|
| 1260 | {
|
|---|
| 1261 | new_flags = 0;
|
|---|
| 1262 | if (nBar != SB_CTL)
|
|---|
| 1263 | *action |= SA_SSI_SHOW;
|
|---|
| 1264 | }
|
|---|
| 1265 |
|
|---|
| 1266 | if (infoPtr->flags != new_flags) /* check arrow flags */
|
|---|
| 1267 | {
|
|---|
| 1268 | infoPtr->flags = new_flags;
|
|---|
| 1269 | *action |= SA_SSI_REPAINT_ARROWS;
|
|---|
| 1270 | }
|
|---|
| 1271 | }
|
|---|
| 1272 |
|
|---|
| 1273 | done:
|
|---|
| 1274 | /* Return current position */
|
|---|
| 1275 |
|
|---|
| 1276 | return infoPtr->CurVal;
|
|---|
| 1277 | }
|
|---|
| 1278 |
|
|---|
| 1279 |
|
|---|
| 1280 | /*************************************************************************
|
|---|
| 1281 | * GetScrollInfo32 (USER32.284)
|
|---|
| 1282 | * GetScrollInfo32 can be used to retrieve the position, upper bound,
|
|---|
| 1283 | * lower bound, and page size of a scrollbar control.
|
|---|
| 1284 | *
|
|---|
| 1285 | * RETURNS STD
|
|---|
| 1286 | */
|
|---|
| 1287 | /* CB:
|
|---|
| 1288 | BOOL WINAPI GetScrollInfo(
|
|---|
| 1289 | HWND hwnd / * [I] Handle of window * / ,
|
|---|
| 1290 | INT nBar / * [I] One of SB_HORZ, SB_VERT, or SB_CTL * /,
|
|---|
| 1291 | LPSCROLLINFO info / * [IO] (info.fMask [I] specifies which values are to retrieve) * /)
|
|---|
| 1292 | {
|
|---|
| 1293 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1294 |
|
|---|
| 1295 | if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
|
|---|
| 1296 | if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return FALSE;
|
|---|
| 1297 | if ((info->cbSize != sizeof(*info)) &&
|
|---|
| 1298 | (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return FALSE;
|
|---|
| 1299 |
|
|---|
| 1300 | if (info->fMask & SIF_PAGE) info->nPage = infoPtr->Page;
|
|---|
| 1301 | if (info->fMask & SIF_POS) info->nPos = infoPtr->CurVal;
|
|---|
| 1302 | if ((info->fMask & SIF_TRACKPOS) && (info->cbSize == sizeof(*info)))
|
|---|
| 1303 | info->nTrackPos = (SCROLL_TrackingWin==hwnd) ? SCROLL_TrackingVal : infoPtr->CurVal;
|
|---|
| 1304 | if (info->fMask & SIF_RANGE)
|
|---|
| 1305 | {
|
|---|
| 1306 | info->nMin = infoPtr->MinVal;
|
|---|
| 1307 | info->nMax = infoPtr->MaxVal;
|
|---|
| 1308 | }
|
|---|
| 1309 | return (info->fMask & SIF_ALL) != 0;
|
|---|
| 1310 | } */
|
|---|
| 1311 |
|
|---|
| 1312 |
|
|---|
| 1313 | /*************************************************************************
|
|---|
| 1314 | * SetScrollPos32 (USER32.502)
|
|---|
| 1315 | *
|
|---|
| 1316 | * RETURNS
|
|---|
| 1317 | * Success: Scrollbar position
|
|---|
| 1318 | * Failure: 0
|
|---|
| 1319 | *
|
|---|
| 1320 | * REMARKS
|
|---|
| 1321 | * Note the ambiguity when 0 is returned. Use GetLastError
|
|---|
| 1322 | * to make sure there was an error (and to know which one).
|
|---|
| 1323 | */
|
|---|
| 1324 | /* CB:
|
|---|
| 1325 | INT WINAPI SetScrollPos(
|
|---|
| 1326 | HWND hwnd / * [I] Handle of window whose scrollbar will be affected * /,
|
|---|
| 1327 | INT nBar / * [I] One of SB_HORZ, SB_VERT, or SB_CTL * /,
|
|---|
| 1328 | INT nPos / * [I] New value * /,
|
|---|
| 1329 | BOOL bRedraw / * [I] Should scrollbar be redrawn afterwards ? * / )
|
|---|
| 1330 | {
|
|---|
| 1331 | SCROLLINFO info;
|
|---|
| 1332 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1333 | INT oldPos;
|
|---|
| 1334 |
|
|---|
| 1335 | if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
|
|---|
| 1336 | oldPos = infoPtr->CurVal;
|
|---|
| 1337 | info.cbSize = sizeof(info);
|
|---|
| 1338 | info.nPos = nPos;
|
|---|
| 1339 | info.fMask = SIF_POS;
|
|---|
| 1340 | SetScrollInfo( hwnd, nBar, &info, bRedraw );
|
|---|
| 1341 | return oldPos;
|
|---|
| 1342 | } */
|
|---|
| 1343 |
|
|---|
| 1344 |
|
|---|
| 1345 | /*************************************************************************
|
|---|
| 1346 | * GetScrollPos32 (USER32.285)
|
|---|
| 1347 | *
|
|---|
| 1348 | * RETURNS
|
|---|
| 1349 | * Success: Current position
|
|---|
| 1350 | * Failure: 0
|
|---|
| 1351 | *
|
|---|
| 1352 | * REMARKS
|
|---|
| 1353 | * Note the ambiguity when 0 is returned. Use GetLastError
|
|---|
| 1354 | * to make sure there was an error (and to know which one).
|
|---|
| 1355 | */
|
|---|
| 1356 | /* CB:
|
|---|
| 1357 | INT WINAPI GetScrollPos(
|
|---|
| 1358 | HWND hwnd, / * [I] Handle of window * /
|
|---|
| 1359 | INT nBar / * [I] One of SB_HORZ, SB_VERT, or SB_CTL * /)
|
|---|
| 1360 | {
|
|---|
| 1361 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1362 |
|
|---|
| 1363 | if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
|
|---|
| 1364 | return infoPtr->CurVal;
|
|---|
| 1365 | } */
|
|---|
| 1366 |
|
|---|
| 1367 |
|
|---|
| 1368 | /*************************************************************************
|
|---|
| 1369 | * SetScrollRange32 (USER32.503)
|
|---|
| 1370 | *
|
|---|
| 1371 | * RETURNS STD
|
|---|
| 1372 | */
|
|---|
| 1373 | /* CB:
|
|---|
| 1374 | BOOL WINAPI SetScrollRange(
|
|---|
| 1375 | HWND hwnd, / * [I] Handle of window whose scrollbar will be affected * /
|
|---|
| 1376 | INT nBar, / * [I] One of SB_HORZ, SB_VERT, or SB_CTL * /
|
|---|
| 1377 | INT MinVal, / * [I] New minimum value * /
|
|---|
| 1378 | INT MaxVal, / * [I] New maximum value * /
|
|---|
| 1379 | BOOL bRedraw / * [I] Should scrollbar be redrawn afterwards ? * /)
|
|---|
| 1380 | {
|
|---|
| 1381 | SCROLLINFO info;
|
|---|
| 1382 |
|
|---|
| 1383 | info.cbSize = sizeof(info);
|
|---|
| 1384 | info.nMin = MinVal;
|
|---|
| 1385 | info.nMax = MaxVal;
|
|---|
| 1386 | info.fMask = SIF_RANGE;
|
|---|
| 1387 | SetScrollInfo( hwnd, nBar, &info, bRedraw );
|
|---|
| 1388 | return TRUE;
|
|---|
| 1389 | } */
|
|---|
| 1390 |
|
|---|
| 1391 |
|
|---|
| 1392 | /*************************************************************************
|
|---|
| 1393 | * SCROLL_SetNCSbState
|
|---|
| 1394 | *
|
|---|
| 1395 | * Updates both scrollbars at the same time. Used by MDI CalcChildScroll().
|
|---|
| 1396 | */
|
|---|
| 1397 | INT SCROLL_SetNCSbState(HWND hwnd, int vMin, int vMax, int vPos,
|
|---|
| 1398 | int hMin, int hMax, int hPos)
|
|---|
| 1399 | {
|
|---|
| 1400 | INT vA, hA;
|
|---|
| 1401 | SCROLLINFO vInfo, hInfo;
|
|---|
| 1402 |
|
|---|
| 1403 | vInfo.cbSize = hInfo.cbSize = sizeof(SCROLLINFO);
|
|---|
| 1404 | vInfo.nMin = vMin; hInfo.nMin = hMin;
|
|---|
| 1405 | vInfo.nMax = vMax; hInfo.nMax = hMax;
|
|---|
| 1406 | vInfo.nPos = vPos; hInfo.nPos = hPos;
|
|---|
| 1407 | vInfo.fMask = hInfo.fMask = SIF_RANGE | SIF_POS;
|
|---|
| 1408 |
|
|---|
| 1409 | SCROLL_SetScrollInfo( hwnd, SB_VERT, &vInfo, &vA );
|
|---|
| 1410 | SCROLL_SetScrollInfo( hwnd, SB_HORZ, &hInfo, &hA );
|
|---|
| 1411 |
|
|---|
| 1412 | if( !SCROLL_ShowScrollBar( hwnd, SB_BOTH,
|
|---|
| 1413 | (hA & SA_SSI_SHOW),(vA & SA_SSI_SHOW) ) )
|
|---|
| 1414 | {
|
|---|
| 1415 | /* SetWindowPos() wasn't called, just redraw the scrollbars if needed */
|
|---|
| 1416 | if( vA & SA_SSI_REFRESH )
|
|---|
| 1417 | SCROLL_RefreshScrollBar( hwnd, SB_VERT, FALSE, TRUE );
|
|---|
| 1418 |
|
|---|
| 1419 | if( hA & SA_SSI_REFRESH )
|
|---|
| 1420 | SCROLL_RefreshScrollBar( hwnd, SB_HORZ, FALSE, TRUE );
|
|---|
| 1421 | }
|
|---|
| 1422 | return 0;
|
|---|
| 1423 | }
|
|---|
| 1424 |
|
|---|
| 1425 |
|
|---|
| 1426 | /*************************************************************************
|
|---|
| 1427 | * GetScrollRange32 (USER32.286)
|
|---|
| 1428 | *
|
|---|
| 1429 | * RETURNS STD
|
|---|
| 1430 | */
|
|---|
| 1431 | /* CB:
|
|---|
| 1432 | BOOL WINAPI GetScrollRange(
|
|---|
| 1433 | HWND hwnd, / * [I] Handle of window * /
|
|---|
| 1434 | INT nBar, / * [I] One of SB_HORZ, SB_VERT, or SB_CTL * /
|
|---|
| 1435 | LPINT lpMin, / * [O] Where to store minimum value * /
|
|---|
| 1436 | LPINT lpMax / * [O] Where to store maximum value * /)
|
|---|
| 1437 | {
|
|---|
| 1438 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1439 |
|
|---|
| 1440 | if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar )))
|
|---|
| 1441 | {
|
|---|
| 1442 | if (lpMin) lpMin = 0;
|
|---|
| 1443 | if (lpMax) lpMax = 0;
|
|---|
| 1444 | return FALSE;
|
|---|
| 1445 | }
|
|---|
| 1446 | if (lpMin) *lpMin = infoPtr->MinVal;
|
|---|
| 1447 | if (lpMax) *lpMax = infoPtr->MaxVal;
|
|---|
| 1448 | return TRUE;
|
|---|
| 1449 | }*/
|
|---|
| 1450 |
|
|---|
| 1451 |
|
|---|
| 1452 | /*************************************************************************
|
|---|
| 1453 | * SCROLL_ShowScrollBar()
|
|---|
| 1454 | *
|
|---|
| 1455 | * Back-end for ShowScrollBar(). Returns FALSE if no action was taken.
|
|---|
| 1456 | * NOTE: fShowV/fShowH must be zero when nBar is SB_HORZ/SB_VERT.
|
|---|
| 1457 | */
|
|---|
| 1458 | BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
|
|---|
| 1459 | BOOL fShowH, BOOL fShowV )
|
|---|
| 1460 | {
|
|---|
| 1461 | BOOL retvalue = FALSE;
|
|---|
| 1462 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 1463 |
|
|---|
| 1464 | //TRACE("hwnd=%04x bar=%d horz=%d, vert=%d\n",
|
|---|
| 1465 | // hwnd, nBar, fShowH, fShowV );
|
|---|
| 1466 |
|
|---|
| 1467 | switch(nBar)
|
|---|
| 1468 | {
|
|---|
| 1469 | case SB_CTL:
|
|---|
| 1470 | ShowWindow( hwnd, fShowH ? SW_SHOW : SW_HIDE );
|
|---|
| 1471 | retvalue = TRUE;
|
|---|
| 1472 | goto END;
|
|---|
| 1473 |
|
|---|
| 1474 | case SB_BOTH:
|
|---|
| 1475 | case SB_HORZ:
|
|---|
| 1476 | if (fShowH)
|
|---|
| 1477 | {
|
|---|
| 1478 | fShowH = !(dwStyle & WS_HSCROLL);
|
|---|
| 1479 | dwStyle |= WS_HSCROLL;
|
|---|
| 1480 | }
|
|---|
| 1481 | else /* hide it */
|
|---|
| 1482 | {
|
|---|
| 1483 | fShowH = (dwStyle & WS_HSCROLL);
|
|---|
| 1484 | dwStyle &= ~WS_HSCROLL;
|
|---|
| 1485 | }
|
|---|
| 1486 | SetWindowLongA(hwnd,GWL_STYLE,dwStyle);
|
|---|
| 1487 | if( nBar == SB_HORZ ) {
|
|---|
| 1488 | fShowV = FALSE;
|
|---|
| 1489 | break;
|
|---|
| 1490 | }
|
|---|
| 1491 | /* fall through */
|
|---|
| 1492 |
|
|---|
| 1493 | case SB_VERT:
|
|---|
| 1494 | if (fShowV)
|
|---|
| 1495 | {
|
|---|
| 1496 | fShowV = !(dwStyle & WS_VSCROLL);
|
|---|
| 1497 | dwStyle |= WS_VSCROLL;
|
|---|
| 1498 | }
|
|---|
| 1499 | else /* hide it */
|
|---|
| 1500 | {
|
|---|
| 1501 | fShowV = (dwStyle & WS_VSCROLL);
|
|---|
| 1502 | dwStyle &= ~WS_VSCROLL;
|
|---|
| 1503 | }
|
|---|
| 1504 | SetWindowLongA(hwnd,GWL_STYLE,dwStyle);
|
|---|
| 1505 | if ( nBar == SB_VERT )
|
|---|
| 1506 | fShowH = FALSE;
|
|---|
| 1507 | break;
|
|---|
| 1508 |
|
|---|
| 1509 | default:
|
|---|
| 1510 | retvalue = FALSE; /* Nothing to do! */
|
|---|
| 1511 | goto END;
|
|---|
| 1512 | }
|
|---|
| 1513 |
|
|---|
| 1514 | if( fShowH || fShowV ) /* frame has been changed, let the window redraw itself */
|
|---|
| 1515 | {
|
|---|
| 1516 | SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
|
|---|
| 1517 | | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
|
|---|
| 1518 | retvalue = TRUE;
|
|---|
| 1519 | goto END;
|
|---|
| 1520 | }
|
|---|
| 1521 |
|
|---|
| 1522 | retvalue = FALSE; /* no frame changes */
|
|---|
| 1523 | END:
|
|---|
| 1524 | return retvalue;
|
|---|
| 1525 | }
|
|---|
| 1526 |
|
|---|
| 1527 |
|
|---|
| 1528 | /*************************************************************************
|
|---|
| 1529 | * ShowScrollBar32 (USER32.532)
|
|---|
| 1530 | *
|
|---|
| 1531 | * RETURNS STD
|
|---|
| 1532 | */
|
|---|
| 1533 | /* CB:
|
|---|
| 1534 | BOOL WINAPI ShowScrollBar(
|
|---|
| 1535 | HWND hwnd, / * [I] Handle of window whose scrollbar(s) will be affected * /
|
|---|
| 1536 | INT nBar, / * [I] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL * /
|
|---|
| 1537 | BOOL fShow / * [I] TRUE = show, FALSE = hide * /)
|
|---|
| 1538 | {
|
|---|
| 1539 | SCROLL_ShowScrollBar( hwnd, nBar, (nBar == SB_VERT) ? 0 : fShow,
|
|---|
| 1540 | (nBar == SB_HORZ) ? 0 : fShow );
|
|---|
| 1541 | return TRUE;
|
|---|
| 1542 | }*/
|
|---|
| 1543 |
|
|---|
| 1544 |
|
|---|
| 1545 | /*************************************************************************
|
|---|
| 1546 | * EnableScrollBar32 (USER32.171)
|
|---|
| 1547 | */
|
|---|
| 1548 | /* CB_
|
|---|
| 1549 | BOOL WINAPI EnableScrollBar( HWND hwnd, INT nBar, UINT flags )
|
|---|
| 1550 | {
|
|---|
| 1551 | BOOL bFineWithMe;
|
|---|
| 1552 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1553 |
|
|---|
| 1554 | //TRACE("%04x %d %d\n", hwnd, nBar, flags );
|
|---|
| 1555 |
|
|---|
| 1556 | flags &= ESB_DISABLE_BOTH;
|
|---|
| 1557 |
|
|---|
| 1558 | if (nBar == SB_BOTH)
|
|---|
| 1559 | {
|
|---|
| 1560 | if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, SB_VERT ))) return FALSE;
|
|---|
| 1561 | if (!(bFineWithMe = (infoPtr->flags == flags)) )
|
|---|
| 1562 | {
|
|---|
| 1563 | infoPtr->flags = flags;
|
|---|
| 1564 | SCROLL_RefreshScrollBar( hwnd, SB_VERT, TRUE, TRUE );
|
|---|
| 1565 | }
|
|---|
| 1566 | nBar = SB_HORZ;
|
|---|
| 1567 | }
|
|---|
| 1568 | else
|
|---|
| 1569 | bFineWithMe = TRUE;
|
|---|
| 1570 |
|
|---|
| 1571 | if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
|
|---|
| 1572 | if (bFineWithMe && infoPtr->flags == flags) return FALSE;
|
|---|
| 1573 | infoPtr->flags = flags;
|
|---|
| 1574 |
|
|---|
| 1575 | SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
|
|---|
| 1576 | return TRUE;
|
|---|
| 1577 | }*/
|
|---|
| 1578 |
|
|---|
| 1579 | BOOL SCROLLBAR_Register()
|
|---|
| 1580 | {
|
|---|
| 1581 | WNDCLASSA wndClass;
|
|---|
| 1582 |
|
|---|
| 1583 | if (GlobalFindAtomA(SCROLLBARCLASSNAME)) return FALSE;
|
|---|
| 1584 |
|
|---|
| 1585 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
|---|
| 1586 | wndClass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_PARENTDC;
|
|---|
| 1587 | wndClass.lpfnWndProc = (WNDPROC)ScrollBarWndProc;
|
|---|
| 1588 | wndClass.cbClsExtra = 0;
|
|---|
| 1589 | wndClass.cbWndExtra = sizeof(SCROLLBAR_INFO);
|
|---|
| 1590 | wndClass.hCursor = LoadCursorA(0,IDC_ARROWA);
|
|---|
| 1591 | wndClass.hbrBackground = (HBRUSH)0;
|
|---|
| 1592 | wndClass.lpszClassName = SCROLLBARCLASSNAME;
|
|---|
| 1593 |
|
|---|
| 1594 | return RegisterClassA(&wndClass);
|
|---|
| 1595 | }
|
|---|
| 1596 |
|
|---|
| 1597 |
|
|---|
| 1598 | BOOL SCROLLBAR_Unregister()
|
|---|
| 1599 | {
|
|---|
| 1600 | if (GlobalFindAtomA(SCROLLBARCLASSNAME))
|
|---|
| 1601 | return UnregisterClassA(SCROLLBARCLASSNAME,(HINSTANCE)NULL);
|
|---|
| 1602 | else return FALSE;
|
|---|
| 1603 | }
|
|---|