2 * Interface code to SCROLLBAR widget
4 * Copyright Martin Ayotte, 1993
11 static char Copyright
[] = "Copyright Martin Ayotte, 1993";
15 #include <sys/types.h>
18 #include "sysmetrics.h"
22 #include "prototypes.h"
28 HBITMAP hUpArrowD
= 0;
29 HBITMAP hDnArrowD
= 0;
30 HBITMAP hLfArrowD
= 0;
31 HBITMAP hRgArrowD
= 0;
33 LPHEADSCROLL
ScrollBarGetWindowAndStorage(HWND hWnd
, WND
**wndPtr
);
34 LPHEADSCROLL
ScrollBarGetStorageHeader(HWND hWnd
);
35 LPHEADSCROLL
GetScrollObjectStruct(HWND hWnd
, int nBar
);
36 void ScrollBarButtonDown(HWND hWnd
, int nBar
, int x
, int y
);
37 void ScrollBarButtonUp(HWND hWnd
, int nBar
, int x
, int y
);
38 void ScrollBarMouseMove(HWND hWnd
, int nBar
, WORD wParam
, int x
, int y
);
39 void StdDrawScrollBar(HWND hWnd
, HDC hDC
, int nBar
, LPRECT lprect
, LPHEADSCROLL lphs
);
40 int CreateScrollBarStruct(HWND hWnd
);
41 void NC_CreateScrollBars(HWND hWnd
);
42 LPHEADSCROLL
AllocScrollBar(DWORD dwStyle
, int width
, int height
);
45 /***********************************************************************
46 * WIDGETS_ScrollBarWndProc
48 LONG
ScrollBarWndProc( HWND hWnd
, WORD message
, WORD wParam
, LONG lParam
)
59 LPCREATESTRUCT lpCreat
;
63 lpCreat
= (LPCREATESTRUCT
)lParam
;
64 if (lpCreat
->style
& SBS_VERT
) {
65 if (lpCreat
->style
& SBS_LEFTALIGN
)
66 SetWindowPos(hWnd
, 0, 0, 0, 16, lpCreat
->cy
,
67 SWP_NOZORDER
| SWP_NOMOVE
);
68 if (lpCreat
->style
& SBS_RIGHTALIGN
)
69 SetWindowPos(hWnd
, 0, lpCreat
->x
+ lpCreat
->cx
- 16,
70 lpCreat
->y
, 16, lpCreat
->cy
, SWP_NOZORDER
);
72 if (lpCreat
->style
& SBS_HORZ
) {
73 if (lpCreat
->style
& SBS_TOPALIGN
)
74 SetWindowPos(hWnd
, 0, 0, 0, lpCreat
->cx
, 16,
75 SWP_NOZORDER
| SWP_NOMOVE
);
76 if (lpCreat
->style
& SBS_BOTTOMALIGN
)
77 SetWindowPos(hWnd
, 0, lpCreat
->x
,
78 lpCreat
->y
+ lpCreat
->cy
- 16,
79 lpCreat
->cx
, 16, SWP_NOZORDER
);
81 CreateScrollBarStruct(hWnd
);
83 printf("ScrollBar Creation !\n");
87 lphs
= ScrollBarGetWindowAndStorage(hWnd
, &wndPtr
);
88 if (lphs
== 0) return 0;
90 printf("ScrollBar WM_DESTROY %lX !\n", lphs
);
93 *((LPHEADSCROLL
*)&wndPtr
->wExtra
[1]) = 0;
98 ScrollBarButtonDown(hWnd
, SB_CTL
, LOWORD(lParam
), HIWORD(lParam
));
102 ScrollBarButtonUp(hWnd
, SB_CTL
, LOWORD(lParam
), HIWORD(lParam
));
106 ScrollBarMouseMove(hWnd
, SB_CTL
, wParam
, LOWORD(lParam
), HIWORD(lParam
));
111 lphs
= ScrollBarGetWindowAndStorage(hWnd
, &wndPtr
);
112 return(SendMessage(wndPtr
->hwndParent
, message
, wParam
, lParam
));
116 printf("ScrollBar WM_TIMER wParam=%X lParam=%lX !\n", wParam
, lParam
);
118 lphs
= ScrollBarGetWindowAndStorage(hWnd
, &wndPtr
);
119 KillTimer(hWnd
, wParam
);
120 switch(lphs
->ButtonDown
) {
122 lphs
->TimerPending
= FALSE
;
126 SendMessage(wndPtr
->hwndParent
, lphs
->Direction
,
127 SB_LINEUP
, MAKELONG(0, hWnd
));
131 SendMessage(wndPtr
->hwndParent
, lphs
->Direction
,
132 SB_LINEDOWN
, MAKELONG(0, hWnd
));
135 SendMessage(wndPtr
->hwndParent
, lphs
->Direction
,
136 SB_PAGEUP
, MAKELONG(0, hWnd
));
139 SendMessage(wndPtr
->hwndParent
, lphs
->Direction
,
140 SB_PAGEDOWN
, MAKELONG(0, hWnd
));
143 SetTimer(hWnd
, 1, 100, NULL
);
147 hDC
= BeginPaint(hWnd
, &ps
);
148 lphs
= ScrollBarGetStorageHeader(hWnd
);
150 GetClientRect(hWnd
, &rect
);
151 StdDrawScrollBar(hWnd
, hDC
, SB_CTL
, &rect
, lphs
);
156 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
163 void ScrollBarButtonDown(HWND hWnd
, int nBar
, int x
, int y
)
170 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
171 if (nBar
== SB_CTL
) {
172 hWndParent
= GetParent(hWnd
);
173 dwOwner
= MAKELONG(0, lphs
->hWndOwner
);
175 printf("ScrollBarButtonDown SB_CTL // x=%d y=%d\n", x
, y
);
182 printf("ScrollBarButtonDown SB_?SCROLL // x=%d y=%d\n", x
, y
);
186 SetFocus(lphs->hWndOwner);
188 CopyRect(&rect
, &lphs
->rect
);
190 printf("ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n",
191 x
, y
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
193 if (lphs
->Direction
== WM_VSCROLL
) {
194 width
= rect
.right
- rect
.left
;
195 if (y
<= lphs
->rectUp
.bottom
) {
196 lphs
->ButtonDown
= 1;
197 InvalidateRect(lphs
->hWndOwner
, &lphs
->rectUp
, TRUE
);
199 printf("ScrollBarButtonDown send SB_LINEUP\n");
201 SendMessage(hWndParent
, lphs
->Direction
,
204 if (y
>= lphs
->rectDown
.top
) {
205 lphs
->ButtonDown
= 2;
206 InvalidateRect(lphs
->hWndOwner
, &lphs
->rectDown
, TRUE
);
208 printf("ScrollBarButtonDown send SB_LINEDOWN\n");
210 SendMessage(hWndParent
, lphs
->Direction
,
211 SB_LINEDOWN
, dwOwner
);
213 if (y
> lphs
->rectUp
.bottom
&& y
< (lphs
->CurPix
+ width
)) {
214 lphs
->ButtonDown
= 5;
216 printf("ScrollBarButtonDown send SB_PAGEUP\n");
218 SendMessage(hWndParent
, lphs
->Direction
,
221 if (y
< lphs
->rectDown
.top
&& y
> (lphs
->CurPix
+ (width
<< 1))) {
222 lphs
->ButtonDown
= 6;
224 printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
226 SendMessage(hWndParent
, lphs
->Direction
,
227 SB_PAGEDOWN
, dwOwner
);
229 if (lphs
->MaxPix
> 0 && y
> (lphs
->CurPix
+ width
) &&
230 y
< (lphs
->CurPix
+ (width
<< 1))) {
231 lphs
->ThumbActive
= TRUE
;
233 printf("THUMB DOWN !\n");
238 height
= rect
.bottom
- rect
.top
;
239 if (x
<= lphs
->rectUp
.right
) {
240 lphs
->ButtonDown
= 3;
241 InvalidateRect(lphs
->hWndOwner
, &lphs
->rectUp
, TRUE
);
243 printf("ScrollBarButtonDown send SB_LINEUP\n");
245 SendMessage(hWndParent
, lphs
->Direction
,
248 if (x
>= lphs
->rectDown
.left
) {
249 lphs
->ButtonDown
= 4;
250 InvalidateRect(lphs
->hWndOwner
, &lphs
->rectDown
, TRUE
);
252 printf("ScrollBarButtonDown send SB_LINEDOWN\n");
254 SendMessage(hWndParent
, lphs
->Direction
,
255 SB_LINEDOWN
, dwOwner
);
257 if (x
> lphs
->rectUp
.right
&& x
< (lphs
->CurPix
+ height
)) {
258 lphs
->ButtonDown
= 5;
260 printf("ScrollBarButtonDown send SB_PAGEUP\n");
262 SendMessage(hWndParent
, lphs
->Direction
,
265 if (x
< lphs
->rectDown
.left
&& x
> (lphs
->CurPix
+ (height
<< 1))) {
266 lphs
->ButtonDown
= 6;
268 printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
270 SendMessage(hWndParent
, lphs
->Direction
,
271 SB_PAGEDOWN
, dwOwner
);
273 if (lphs
->MaxPix
> 0 && x
> (lphs
->CurPix
+ height
) &&
274 x
< (lphs
->CurPix
+ (height
<< 1))) {
275 lphs
->ThumbActive
= TRUE
;
277 printf("THUMB DOWN !\n");
281 if (lphs
->ButtonDown
!= 0) {
282 UpdateWindow(lphs
->hWndOwner
);
283 if (!lphs
->TimerPending
&& nBar
== SB_CTL
) {
284 lphs
->TimerPending
= TRUE
;
285 SetTimer(lphs
->hWndOwner
, 1, 500, NULL
);
291 void ScrollBarButtonUp(HWND hWnd
, int nBar
, int x
, int y
)
297 printf("ScrollBarButtonUp // x=%d y=%d\n", x
, y
);
299 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
300 lphs
->ThumbActive
= FALSE
;
301 if (lphs
->ButtonDown
!= 0) {
302 lphs
->ButtonDown
= 0;
303 if (nBar
== SB_CTL
) {
304 GetClientRect(lphs
->hWndOwner
, &rect
);
305 InvalidateRect(lphs
->hWndOwner
, &rect
, TRUE
);
306 UpdateWindow(lphs
->hWndOwner
);
309 hDC
= GetWindowDC(lphs
->hWndOwner
);
310 StdDrawScrollBar(lphs
->hWndOwner
, hDC
, nBar
, &lphs
->rect
, lphs
);
311 ReleaseDC(lphs
->hWndOwner
, hDC
);
317 void ScrollBarMouseMove(HWND hWnd
, int nBar
, WORD wParam
, int x
, int y
)
323 if ((wParam
& MK_LBUTTON
) == 0) return;
324 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
325 if (lphs
->ThumbActive
== 0) return;
326 if (nBar
== SB_CTL
) {
327 hWndParent
= GetParent(hWnd
);
328 hWndOwner
= lphs
->hWndOwner
;
330 printf("ScrollBarButtonMove SB_CTL // x=%d y=%d\n", x
, y
);
337 printf("ScrollBarButtonMove SB_?SCROLL // x=%d y=%d\n", x
, y
);
340 if (lphs
->Direction
== WM_VSCROLL
) {
341 int butsiz
= lphs
->rect
.right
- lphs
->rect
.left
;
342 y
= y
- butsiz
- (butsiz
>> 1);
345 int butsiz
= lphs
->rect
.bottom
- lphs
->rect
.top
;
346 y
= x
- butsiz
- (butsiz
>> 1);
348 x
= (y
* (lphs
->MaxVal
- lphs
->MinVal
) /
349 lphs
->MaxPix
) + lphs
->MinVal
;
351 printf("Scroll WM_MOUSEMOVE val=%d pix=%d\n", x
, y
);
353 SendMessage(hWndParent
, lphs
->Direction
,
354 SB_THUMBTRACK
, MAKELONG(x
, hWndOwner
));
358 LPHEADSCROLL
ScrollBarGetWindowAndStorage(HWND hWnd
, WND
**wndPtr
)
362 *(wndPtr
) = Ptr
= WIN_FindWndPtr(hWnd
);
364 printf("Bad Window handle on ScrollBar !\n");
367 lphs
= *((LPHEADSCROLL
*)&Ptr
->wExtra
[1]);
372 LPHEADSCROLL
ScrollBarGetStorageHeader(HWND hWnd
)
376 wndPtr
= WIN_FindWndPtr(hWnd
);
378 printf("Bad Window handle on ScrollBar !\n");
381 lphs
= *((LPHEADSCROLL
*)&wndPtr
->wExtra
[1]);
387 void StdDrawScrollBar(HWND hWnd
, HDC hDC
, int nBar
, LPRECT lprect
, LPHEADSCROLL lphs
)
394 UINT i
, w
, w2
, h
, h2
, siz
;
396 if (lphs
== NULL
) return;
398 printf("StdDrawScrollBar nBar=%04X !\n", nBar
);
399 if (lphs
->Direction
== WM_VSCROLL
)
400 printf("StdDrawScrollBar Vertical left=%d top=%d right=%d bottom=%d !\n",
401 lprect
->left
, lprect
->top
, lprect
->right
, lprect
->bottom
);
403 printf("StdDrawScrollBar Horizontal left=%d top=%d right=%d bottom=%d !\n",
404 lprect
->left
, lprect
->top
, lprect
->right
, lprect
->bottom
);
407 hWndParent
= GetParent(hWnd
);
409 hWndParent
= lphs
->hWndOwner
;
410 hBrush
= SendMessage(hWndParent
, WM_CTLCOLOR
, (WORD
)hDC
,
411 MAKELONG(hWnd
, CTLCOLOR_SCROLLBAR
));
412 if (hBrush
== (HBRUSH
)NULL
) hBrush
= GetStockObject(LTGRAY_BRUSH
);
413 CopyRect(&lphs
->rect
, lprect
);
414 CopyRect(&lphs
->rectUp
, lprect
);
415 CopyRect(&lphs
->rectDown
, lprect
);
416 CopyRect(&rect
, lprect
);
417 w
= rect
.right
- rect
.left
;
418 h
= rect
.bottom
- rect
.top
;
419 if (w
== 0 || h
== 0) return;
420 if (lphs
->Direction
== WM_VSCROLL
) {
422 lphs
->MaxPix
= h
- 3 * w
;
429 lphs
->rectUp
.bottom
= h2
;
430 lphs
->rectDown
.top
= rect
.bottom
- h2
;
434 lphs
->MaxPix
= w
- 3 * h
;
441 lphs
->rectUp
.right
= w2
;
442 lphs
->rectDown
.left
= rect
.right
- w2
;
444 if (lphs
->MaxVal
!= lphs
->MinVal
)
445 lphs
->CurPix
= lphs
->MaxPix
* (abs((short)lphs
->CurVal
) - abs(lphs
->MinVal
)) /
446 (abs(lphs
->MaxVal
) - abs(lphs
->MinVal
));
447 if (lphs
->CurPix
> lphs
->MaxPix
) lphs
->CurPix
= lphs
->MaxPix
;
448 hMemDC
= CreateCompatibleDC(hDC
);
449 if (lphs
->Direction
== WM_VSCROLL
) {
450 GetObject(hUpArrow
, sizeof(BITMAP
), (LPSTR
)&bm
);
451 if (lphs
->ButtonDown
== 1)
452 SelectObject(hMemDC
, hUpArrowD
);
454 SelectObject(hMemDC
, hUpArrow
);
455 StretchBlt(hDC
, rect
.left
, rect
.top
, w
, h2
, hMemDC
,
456 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
457 GetObject(hDnArrow
, sizeof(BITMAP
), (LPSTR
)&bm
);
458 if (lphs
->ButtonDown
== 2)
459 SelectObject(hMemDC
, hDnArrowD
);
461 SelectObject(hMemDC
, hDnArrow
);
462 StretchBlt(hDC
, rect
.left
, rect
.bottom
- h2
, w
, h2
, hMemDC
,
463 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
468 GetObject(hLfArrow
, sizeof(BITMAP
), (LPSTR
)&bm
);
469 if (lphs
->ButtonDown
== 3)
470 SelectObject(hMemDC
, hLfArrowD
);
472 SelectObject(hMemDC
, hLfArrow
);
473 StretchBlt(hDC
, rect
.left
, rect
.top
, w2
, h
, hMemDC
,
474 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
475 GetObject(hRgArrow
, sizeof(BITMAP
), (LPSTR
)&bm
);
476 if (lphs
->ButtonDown
== 4)
477 SelectObject(hMemDC
, hRgArrowD
);
479 SelectObject(hMemDC
, hRgArrow
);
480 StretchBlt(hDC
, rect
.right
- w2
, rect
.top
, w2
, h
, hMemDC
,
481 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
486 FillRect(hDC
, &rect
, hBrush
);
487 if (lphs
->MaxPix
!= 0) {
488 if (lphs
->Direction
== WM_VSCROLL
)
489 SetRect(&rect
, rect
.left
, rect
.top
+ lphs
->CurPix
,
490 rect
.left
+ w
, rect
.top
+ lphs
->CurPix
+ h2
);
492 SetRect(&rect
, rect
.left
+ lphs
->CurPix
, rect
.top
,
493 rect
.left
+ lphs
->CurPix
+ w2
, rect
.top
+ h
);
494 FrameRect(hDC
, &rect
, GetStockObject(BLACK_BRUSH
));
495 InflateRect(&rect
, -1, -1);
496 FillRect(hDC
, &rect
, GetStockObject(LTGRAY_BRUSH
));
497 DrawReliefRect(hDC
, rect
, 2, 0);
498 InflateRect(&rect
, -3, -3);
499 DrawReliefRect(hDC
, rect
, 1, 1);
505 int CreateScrollBarStruct(HWND hWnd
)
511 wndPtr
= WIN_FindWndPtr(hWnd
);
512 width
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
513 height
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
515 lphs
= AllocScrollBar(WS_VSCROLL
, width
, height
);
517 lphs
= AllocScrollBar(WS_HSCROLL
, width
, height
);
519 printf("CreateScrollBarStruct %lX !\n", lphs
);
521 *((LPHEADSCROLL
*)&wndPtr
->wExtra
[1]) = lphs
;
522 lphs
->hWndOwner
= hWnd
;
523 CopyRect(&lphs
->rect
, &wndPtr
->rectClient
);
529 LPHEADSCROLL
AllocScrollBar(DWORD dwStyle
, int width
, int height
)
532 if (hUpArrow
== (HBITMAP
)NULL
)
533 hUpArrow
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_UPARROWI
));
534 if (hDnArrow
== (HBITMAP
)NULL
)
535 hDnArrow
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_DNARROWI
));
536 if (hLfArrow
== (HBITMAP
)NULL
)
537 hLfArrow
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_LFARROWI
));
538 if (hRgArrow
== (HBITMAP
)NULL
)
539 hRgArrow
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_RGARROWI
));
540 if (hUpArrowD
== (HBITMAP
)NULL
)
541 hUpArrowD
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_UPARROWD
));
542 if (hDnArrowD
== (HBITMAP
)NULL
)
543 hDnArrowD
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_DNARROWD
));
544 if (hLfArrowD
== (HBITMAP
)NULL
)
545 hLfArrowD
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_LFARROWD
));
546 if (hRgArrowD
== (HBITMAP
)NULL
)
547 hRgArrowD
= LoadBitmap((HINSTANCE
)NULL
, MAKEINTRESOURCE(OBM_RGARROWD
));
548 lphs
= (LPHEADSCROLL
)malloc(sizeof(HEADSCROLL
));
550 printf("Bad Memory Alloc on ScrollBar !\n");
553 lphs
->ThumbActive
= FALSE
;
554 lphs
->TimerPending
= FALSE
;
555 lphs
->ButtonDown
= 0;
560 SetRect(&lphs
->rect
, 0, 0, width
, height
);
561 if (dwStyle
& WS_VSCROLL
) {
562 if (height
> 3 * width
)
563 lphs
->MaxPix
= height
- 3 * width
;
566 lphs
->Direction
= WM_VSCROLL
;
569 if (width
> 3 * height
)
570 lphs
->MaxPix
= width
- 3 * height
;
573 lphs
->Direction
= WM_HSCROLL
;
575 if (lphs
->MaxPix
< 1) lphs
->MaxPix
= 1;
580 void NC_CreateScrollBars(HWND hWnd
)
586 wndPtr
= WIN_FindWndPtr(hWnd
);
587 GetWindowRect(hWnd
, &rect
);
588 width
= rect
.right
- rect
.left
;
589 height
= rect
.bottom
- rect
.top
;
590 if (wndPtr
->dwStyle
& WS_VSCROLL
) {
591 if (wndPtr
->dwStyle
& WS_HSCROLL
) height
-= SYSMETRICS_CYHSCROLL
;
592 lphs
= AllocScrollBar(WS_VSCROLL
, SYSMETRICS_CXVSCROLL
, height
);
594 printf("NC_CreateScrollBars Vertical %lX !\n", lphs
);
596 lphs
->rect
.left
= width
- SYSMETRICS_CYVSCROLL
;
597 lphs
->rect
.right
= width
;
598 lphs
->hWndOwner
= hWnd
;
599 wndPtr
->VScroll
= lphs
;
600 if (wndPtr
->dwStyle
& WS_HSCROLL
) height
+= SYSMETRICS_CYHSCROLL
;
602 if (wndPtr
->dwStyle
& WS_HSCROLL
) {
603 if (wndPtr
->dwStyle
& WS_VSCROLL
) width
-= SYSMETRICS_CYVSCROLL
;
604 lphs
= AllocScrollBar(WS_HSCROLL
, width
, SYSMETRICS_CYHSCROLL
);
606 printf("NC_CreateScrollBars Horizontal %lX !\n", lphs
);
608 lphs
->rect
.top
= height
- SYSMETRICS_CYHSCROLL
;
609 lphs
->rect
.bottom
= height
;
610 lphs
->hWndOwner
= hWnd
;
611 wndPtr
->HScroll
= lphs
;
616 /*************************************************************************
617 * GetScrollObjectStruct [internal]
619 LPHEADSCROLL
GetScrollObjectStruct(HWND hWnd
, int nBar
)
622 if (nBar
!= SB_CTL
) {
623 wndPtr
= WIN_FindWndPtr(hWnd
);
624 if (nBar
== SB_VERT
) return (LPHEADSCROLL
)wndPtr
->VScroll
;
625 if (nBar
== SB_HORZ
) return (LPHEADSCROLL
)wndPtr
->HScroll
;
628 return ScrollBarGetStorageHeader(hWnd
);
632 /*************************************************************************
633 * SetScrollPos [USER.62]
635 int SetScrollPos(HWND hWnd
, int nBar
, int nPos
, BOOL bRedraw
)
640 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
641 if (lphs
== NULL
) return 0;
643 lphs
->CurVal
= (short)nPos
;
644 if (lphs
->MaxVal
!= lphs
->MinVal
)
645 lphs
->CurPix
= lphs
->MaxPix
* (abs((short)nPos
) - abs(lphs
->MinVal
)) /
646 (abs(lphs
->MaxVal
) - abs(lphs
->MinVal
));
647 if (lphs
->CurPix
> lphs
->MaxPix
) lphs
->CurPix
= lphs
->MaxPix
;
649 printf("SetScrollPos val=%d pixval=%d pixmax%d\n",
650 (short)nPos
, lphs
->CurPix
, lphs
->MaxPix
);
651 printf("SetScrollPos min=%d max=%d\n",
652 lphs
->MinVal
, lphs
->MaxVal
);
654 if ((bRedraw
) && (IsWindowVisible(lphs
->hWndOwner
))) {
655 if (nBar
== SB_CTL
) {
656 InvalidateRect(lphs
->hWndOwner
, &lphs
->rect
, TRUE
);
657 UpdateWindow(lphs
->hWndOwner
);
660 if (lphs
->rect
.right
!= 0 && lphs
->rect
.bottom
!= 0) {
661 hDC
= GetWindowDC(lphs
->hWndOwner
);
662 StdDrawScrollBar(lphs
->hWndOwner
, hDC
, nBar
, &lphs
->rect
, lphs
);
663 ReleaseDC(lphs
->hWndOwner
, hDC
);
672 /*************************************************************************
673 * GetScrollPos [USER.63]
675 int GetScrollPos(HWND hWnd
, int nBar
)
678 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
679 if (lphs
== NULL
) return 0;
685 /*************************************************************************
686 * SetScrollRange [USER.64]
688 void SetScrollRange(HWND hWnd
, int nBar
, int MinPos
, int MaxPos
, BOOL bRedraw
)
692 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
693 if (lphs
== NULL
) return;
694 lphs
->MinVal
= (short)MinPos
;
695 lphs
->MaxVal
= (short)MaxPos
;
696 if (lphs
->MaxVal
!= lphs
->MinVal
)
697 lphs
->CurPix
= abs(lphs
->MaxVal
) *
698 (abs(lphs
->CurVal
) - abs(lphs
->MinVal
)) /
699 (abs(lphs
->MaxVal
) - abs(lphs
->MinVal
));
700 if (lphs
->CurPix
> lphs
->MaxPix
) lphs
->CurPix
= lphs
->MaxPix
;
702 printf("SetScrollRange min=%d max=%d\n", lphs
->MinVal
, lphs
->MaxVal
);
704 if ((bRedraw
) && (IsWindowVisible(lphs
->hWndOwner
))) {
705 if (nBar
== SB_CTL
) {
706 InvalidateRect(lphs
->hWndOwner
, &lphs
->rect
, TRUE
);
707 UpdateWindow(lphs
->hWndOwner
);
710 if (lphs
->rect
.right
!= 0 && lphs
->rect
.bottom
!= 0) {
711 hDC
= GetWindowDC(lphs
->hWndOwner
);
712 StdDrawScrollBar(lphs
->hWndOwner
, hDC
, nBar
, &lphs
->rect
, lphs
);
713 ReleaseDC(lphs
->hWndOwner
, hDC
);
721 /*************************************************************************
722 * GetScrollRange [USER.65]
724 void GetScrollRange(HWND hWnd
, int nBar
, LPINT lpMin
, LPINT lpMax
)
727 lphs
= GetScrollObjectStruct(hWnd
, nBar
);
728 if (lphs
== NULL
) return;
729 *lpMin
= lphs
->MinVal
;
730 *lpMax
= lphs
->MaxVal
;
735 /*************************************************************************
736 * ShowScrollBar [USER.267]
738 void ShowScrollBar(HWND hWnd
, WORD wBar
, BOOL bFlag
)
742 printf("ShowScrollBar hWnd=%04X wBar=%d bFlag=%d\n", hWnd
, wBar
, bFlag
);
744 if (wBar
== SB_CTL
) {
746 ShowWindow(hWnd
, SW_SHOW
);
748 ShowWindow(hWnd
, SW_HIDE
);
751 wndPtr
= WIN_FindWndPtr(hWnd
);
753 if ((wBar == SB_VERT) || (wBar == SB_BOTH)) {
755 wndPtr->dwStyle |= WS_VSCROLL;
757 wndPtr->dwStyle &= 0xFFFFFFFFL ^ WS_VSCROLL;
759 if ((wBar == SB_HORZ) || (wBar == SB_BOTH)) {
761 wndPtr->dwStyle |= WS_HSCROLL;
763 wndPtr->dwStyle &= 0xFFFFFFFFL ^ WS_HSCROLL;