4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 1998, 1999 Alex Priem
6 * Copyright 2002 Dimitrie O. Paun
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
37 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(trackbar
);
70 #define TB_REFRESH_TIMER 1
71 #define TB_REFRESH_DELAY 500
73 #define TOOLTIP_OFFSET 2 /* distance from ctrl edge to tooltip */
75 #define TB_DEFAULTPAGESIZE 20
77 /* Used by TRACKBAR_Refresh to find out which parts of the control
78 need to be recalculated */
80 #define TB_THUMBPOSCHANGED 0x00000001
81 #define TB_THUMBSIZECHANGED 0x00000002
82 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBSIZECHANGED)
83 #define TB_SELECTIONCHANGED 0x00000004
84 #define TB_DRAG_MODE 0x00000008 /* we're dragging the slider */
85 #define TB_AUTO_PAGE_LEFT 0x00000010
86 #define TB_AUTO_PAGE_RIGHT 0x00000020
87 #define TB_AUTO_PAGE (TB_AUTO_PAGE_LEFT | TB_AUTO_PAGE_RIGHT)
88 #define TB_THUMB_HOT 0x00000040 /* mouse hovers above thumb */
90 /* Page was set with TBM_SETPAGESIZE */
91 #define TB_USER_PAGE 0x00000080
92 #define TB_IS_FOCUSED 0x00000100
94 /* helper defines for TRACKBAR_DrawTic */
96 #define TIC_SELECTIONMARKMAX 0x80
97 #define TIC_SELECTIONMARKMIN 0x100
98 #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
100 static const WCHAR themeClass
[] = { 'T','r','a','c','k','b','a','r',0 };
103 notify_customdraw (const TRACKBAR_INFO
*infoPtr
, NMCUSTOMDRAW
*pnmcd
, int stage
)
105 pnmcd
->dwDrawStage
= stage
;
106 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
107 pnmcd
->hdr
.idFrom
, (LPARAM
)pnmcd
);
110 static LRESULT
notify_hdr (const TRACKBAR_INFO
*infoPtr
, INT code
, LPNMHDR pnmh
)
114 TRACE("(code=%d)\n", code
);
116 pnmh
->hwndFrom
= infoPtr
->hwndSelf
;
117 pnmh
->idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
119 result
= SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, pnmh
->idFrom
, (LPARAM
)pnmh
);
121 TRACE(" <= %ld\n", result
);
126 static inline int notify (const TRACKBAR_INFO
*infoPtr
, INT code
)
129 return notify_hdr(infoPtr
, code
, &nmh
);
132 static void notify_with_scroll (const TRACKBAR_INFO
*infoPtr
, UINT code
)
134 UINT scroll
= infoPtr
->dwStyle
& TBS_VERT
? WM_VSCROLL
: WM_HSCROLL
;
138 SendMessageW (infoPtr
->hwndNotify
, scroll
, code
, (LPARAM
)infoPtr
->hwndSelf
);
141 static void TRACKBAR_RecalculateTics (TRACKBAR_INFO
*infoPtr
)
146 if (infoPtr
->uTicFreq
&& infoPtr
->lRangeMax
>= infoPtr
->lRangeMin
) {
147 nrTics
=(infoPtr
->lRangeMax
- infoPtr
->lRangeMin
)/infoPtr
->uTicFreq
;
148 /* don't add extra tic if there's no remainder */
149 if (nrTics
&& ((infoPtr
->lRangeMax
- infoPtr
->lRangeMin
) % infoPtr
->uTicFreq
== 0))
153 Free (infoPtr
->tics
);
154 infoPtr
->tics
= NULL
;
155 infoPtr
->uNumTics
= 0;
159 if (nrTics
!= infoPtr
->uNumTics
) {
160 infoPtr
->tics
=ReAlloc (infoPtr
->tics
,
161 (nrTics
+1)*sizeof (DWORD
));
162 if (!infoPtr
->tics
) {
163 infoPtr
->uNumTics
= 0;
164 notify(infoPtr
, NM_OUTOFMEMORY
);
167 infoPtr
->uNumTics
= nrTics
;
170 tic
= infoPtr
->lRangeMin
+ infoPtr
->uTicFreq
;
171 for (i
= 0; i
< nrTics
; i
++, tic
+= infoPtr
->uTicFreq
)
172 infoPtr
->tics
[i
] = tic
;
175 /* converts from physical (mouse) position to logical position
176 (in range of trackbar) */
179 TRACKBAR_ConvertPlaceToPosition (const TRACKBAR_INFO
*infoPtr
, int place
)
181 double range
, width
, pos
, offsetthumb
;
183 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
184 if (infoPtr
->dwStyle
& TBS_VERT
) {
185 offsetthumb
= (infoPtr
->rcThumb
.bottom
- infoPtr
->rcThumb
.top
)/2;
186 width
= infoPtr
->rcChannel
.bottom
- infoPtr
->rcChannel
.top
- (offsetthumb
* 2) - 1;
187 pos
= (range
*(place
- infoPtr
->rcChannel
.top
- offsetthumb
)) / width
;
189 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
190 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- (offsetthumb
* 2) - 1;
191 pos
= (range
*(place
- infoPtr
->rcChannel
.left
- offsetthumb
)) / width
;
193 pos
+= infoPtr
->lRangeMin
;
194 if (pos
> infoPtr
->lRangeMax
)
195 pos
= infoPtr
->lRangeMax
;
196 else if (pos
< infoPtr
->lRangeMin
)
197 pos
= infoPtr
->lRangeMin
;
199 TRACE("%.2f\n", pos
);
200 return (LONG
)floor(pos
+ 0.5);
204 /* return: 0> prev, 0 none, >0 next */
206 TRACKBAR_GetAutoPageDirection (const TRACKBAR_INFO
*infoPtr
, POINT clickPoint
)
210 if (infoPtr
->dwStyle
& TBS_VERT
) {
211 pageRect
.top
= infoPtr
->rcChannel
.top
;
212 pageRect
.bottom
= infoPtr
->rcChannel
.bottom
;
213 pageRect
.left
= infoPtr
->rcThumb
.left
;
214 pageRect
.right
= infoPtr
->rcThumb
.right
;
216 pageRect
.top
= infoPtr
->rcThumb
.top
;
217 pageRect
.bottom
= infoPtr
->rcThumb
.bottom
;
218 pageRect
.left
= infoPtr
->rcChannel
.left
;
219 pageRect
.right
= infoPtr
->rcChannel
.right
;
223 if (PtInRect(&pageRect
, clickPoint
))
225 int clickPlace
= (infoPtr
->dwStyle
& TBS_VERT
) ? clickPoint
.y
: clickPoint
.x
;
227 LONG clickPos
= TRACKBAR_ConvertPlaceToPosition(infoPtr
, clickPlace
);
229 return clickPos
- infoPtr
->lPos
;
236 TRACKBAR_PageDown (TRACKBAR_INFO
*infoPtr
)
238 if (infoPtr
->lPos
== infoPtr
->lRangeMax
) return;
240 infoPtr
->lPos
+= infoPtr
->lPageSize
;
241 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
242 infoPtr
->lPos
= infoPtr
->lRangeMax
;
243 notify_with_scroll (infoPtr
, TB_PAGEDOWN
);
248 TRACKBAR_PageUp (TRACKBAR_INFO
*infoPtr
)
250 if (infoPtr
->lPos
== infoPtr
->lRangeMin
) return;
252 infoPtr
->lPos
-= infoPtr
->lPageSize
;
253 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
254 infoPtr
->lPos
= infoPtr
->lRangeMin
;
255 notify_with_scroll (infoPtr
, TB_PAGEUP
);
258 static inline void TRACKBAR_LineUp(TRACKBAR_INFO
*infoPtr
)
260 if (infoPtr
->lPos
== infoPtr
->lRangeMin
) return;
261 infoPtr
->lPos
-= infoPtr
->lLineSize
;
262 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
263 infoPtr
->lPos
= infoPtr
->lRangeMin
;
264 notify_with_scroll (infoPtr
, TB_LINEUP
);
267 static inline void TRACKBAR_LineDown(TRACKBAR_INFO
*infoPtr
)
269 if (infoPtr
->lPos
== infoPtr
->lRangeMax
) return;
270 infoPtr
->lPos
+= infoPtr
->lLineSize
;
271 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
272 infoPtr
->lPos
= infoPtr
->lRangeMax
;
273 notify_with_scroll (infoPtr
, TB_LINEDOWN
);
277 TRACKBAR_CalcChannel (TRACKBAR_INFO
*infoPtr
)
279 INT cyChannel
, offsetthumb
, offsetedge
;
280 RECT lpRect
, *channel
= & infoPtr
->rcChannel
;
282 GetClientRect (infoPtr
->hwndSelf
, &lpRect
);
284 offsetthumb
= infoPtr
->uThumbLen
/ 4;
285 offsetedge
= offsetthumb
+ 3;
286 cyChannel
= (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) ? offsetthumb
*3 : 4;
287 if (infoPtr
->dwStyle
& TBS_VERT
) {
288 channel
->top
= lpRect
.top
+ offsetedge
;
289 channel
->bottom
= lpRect
.bottom
- offsetedge
;
290 if (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)
291 channel
->left
= lpRect
.left
+ ((infoPtr
->uThumbLen
- cyChannel
+ 2) / 2);
293 channel
->left
= lpRect
.left
+ (infoPtr
->uThumbLen
/ 2) - 1;
294 if (infoPtr
->dwStyle
& TBS_BOTH
) {
295 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
300 else if (infoPtr
->dwStyle
& TBS_TOP
) {
301 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
306 channel
->right
= channel
->left
+ cyChannel
;
308 channel
->left
= lpRect
.left
+ offsetedge
;
309 channel
->right
= lpRect
.right
- offsetedge
;
310 if (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)
311 channel
->top
= lpRect
.top
+ ((infoPtr
->uThumbLen
- cyChannel
+ 2) / 2);
313 channel
->top
= lpRect
.top
+ (infoPtr
->uThumbLen
/ 2) - 1;
314 if (infoPtr
->dwStyle
& TBS_BOTH
) {
315 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
320 else if (infoPtr
->dwStyle
& TBS_TOP
) {
321 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
326 channel
->bottom
= channel
->top
+ cyChannel
;
331 TRACKBAR_CalcThumb (const TRACKBAR_INFO
*infoPtr
, LONG lPos
, RECT
*thumb
)
333 int range
, width
, height
, thumbwidth
;
336 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
337 thumbwidth
= (infoPtr
->uThumbLen
/ 2) | 1;
339 if (!range
) range
= 1;
341 GetClientRect(infoPtr
->hwndSelf
, &lpRect
);
342 if (infoPtr
->dwStyle
& TBS_VERT
)
344 height
= infoPtr
->rcChannel
.bottom
- infoPtr
->rcChannel
.top
- thumbwidth
;
346 if ((infoPtr
->dwStyle
& (TBS_BOTH
| TBS_LEFT
)) && !(infoPtr
->dwStyle
& TBS_NOTICKS
))
350 thumb
->right
= thumb
->left
+ infoPtr
->uThumbLen
;
351 thumb
->top
= infoPtr
->rcChannel
.top
+
352 (height
*(lPos
- infoPtr
->lRangeMin
))/range
;
353 thumb
->bottom
= thumb
->top
+ thumbwidth
;
357 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- thumbwidth
;
359 thumb
->left
= infoPtr
->rcChannel
.left
+
360 (width
*(lPos
- infoPtr
->lRangeMin
))/range
;
361 thumb
->right
= thumb
->left
+ thumbwidth
;
362 if ((infoPtr
->dwStyle
& (TBS_BOTH
| TBS_TOP
)) && !(infoPtr
->dwStyle
& TBS_NOTICKS
))
366 thumb
->bottom
= thumb
->top
+ infoPtr
->uThumbLen
;
371 TRACKBAR_UpdateThumb (TRACKBAR_INFO
*infoPtr
)
373 TRACKBAR_CalcThumb(infoPtr
, infoPtr
->lPos
, &infoPtr
->rcThumb
);
377 TRACKBAR_InvalidateAll (const TRACKBAR_INFO
*infoPtr
)
379 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
383 TRACKBAR_InvalidateThumb (const TRACKBAR_INFO
*infoPtr
, LONG thumbPos
)
387 TRACKBAR_CalcThumb(infoPtr
, thumbPos
, &rcThumb
);
388 InflateRect(&rcThumb
, 1, 1);
389 InvalidateRect(infoPtr
->hwndSelf
, &rcThumb
, FALSE
);
393 TRACKBAR_InvalidateThumbMove (const TRACKBAR_INFO
*infoPtr
, LONG oldPos
, LONG newPos
)
395 TRACKBAR_InvalidateThumb (infoPtr
, oldPos
);
396 if (newPos
!= oldPos
)
397 TRACKBAR_InvalidateThumb (infoPtr
, newPos
);
401 TRACKBAR_HasSelection (const TRACKBAR_INFO
*infoPtr
)
403 return infoPtr
->lSelMin
!= infoPtr
->lSelMax
;
407 TRACKBAR_CalcSelection (TRACKBAR_INFO
*infoPtr
)
409 RECT
*selection
= &infoPtr
->rcSelection
;
410 int range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
411 int offsetthumb
, height
, width
;
414 SetRectEmpty (selection
);
416 if (infoPtr
->dwStyle
& TBS_VERT
) {
417 offsetthumb
= (infoPtr
->rcThumb
.bottom
- infoPtr
->rcThumb
.top
)/2;
418 height
= infoPtr
->rcChannel
.bottom
- infoPtr
->rcChannel
.top
- offsetthumb
*2;
419 selection
->top
= infoPtr
->rcChannel
.top
+ offsetthumb
+
420 (height
*infoPtr
->lSelMin
)/range
;
421 selection
->bottom
= infoPtr
->rcChannel
.top
+ offsetthumb
+
422 (height
*infoPtr
->lSelMax
)/range
;
423 selection
->left
= infoPtr
->rcChannel
.left
+ 3;
424 selection
->right
= infoPtr
->rcChannel
.right
- 3;
426 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
427 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- offsetthumb
*2;
428 selection
->left
= infoPtr
->rcChannel
.left
+ offsetthumb
+
429 (width
*infoPtr
->lSelMin
)/range
;
430 selection
->right
= infoPtr
->rcChannel
.left
+ offsetthumb
+
431 (width
*infoPtr
->lSelMax
)/range
;
432 selection
->top
= infoPtr
->rcChannel
.top
+ 3;
433 selection
->bottom
= infoPtr
->rcChannel
.bottom
- 3;
437 TRACE("selection[%s]\n", wine_dbgstr_rect(selection
));
441 TRACKBAR_AutoPage (TRACKBAR_INFO
*infoPtr
, POINT clickPoint
)
443 LONG dir
= TRACKBAR_GetAutoPageDirection(infoPtr
, clickPoint
);
444 LONG prevPos
= infoPtr
->lPos
;
446 TRACE("clickPoint=%s, dir=%d\n", wine_dbgstr_point(&clickPoint
), dir
);
448 if (dir
> 0 && (infoPtr
->flags
& TB_AUTO_PAGE_RIGHT
))
449 TRACKBAR_PageDown(infoPtr
);
450 else if (dir
< 0 && (infoPtr
->flags
& TB_AUTO_PAGE_LEFT
))
451 TRACKBAR_PageUp(infoPtr
);
454 TRACKBAR_UpdateThumb (infoPtr
);
455 TRACKBAR_InvalidateThumbMove (infoPtr
, prevPos
, infoPtr
->lPos
);
460 /* Trackbar drawing code. I like my spaghetti done milanese. */
463 TRACKBAR_DrawChannel (const TRACKBAR_INFO
*infoPtr
, HDC hdc
)
465 RECT rcChannel
= infoPtr
->rcChannel
;
466 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
470 DrawThemeBackground (theme
, hdc
,
471 (infoPtr
->dwStyle
& TBS_VERT
) ?
472 TKP_TRACKVERT
: TKP_TRACK
, TKS_NORMAL
, &rcChannel
, 0);
476 DrawEdge (hdc
, &rcChannel
, EDGE_SUNKEN
, BF_RECT
| BF_ADJUST
);
477 if (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) { /* fill the channel */
478 FillRect (hdc
, &rcChannel
, GetStockObject(WHITE_BRUSH
));
479 if (TRACKBAR_HasSelection(infoPtr
))
480 FillRect (hdc
, &infoPtr
->rcSelection
, GetSysColorBrush(COLOR_HIGHLIGHT
));
486 TRACKBAR_DrawOneTic (const TRACKBAR_INFO
*infoPtr
, HDC hdc
, LONG ticPos
, int flags
)
488 int x
, y
, ox
, oy
, range
, side
, indent
= 0, len
= 3;
492 if (flags
& TBS_VERT
) {
493 offsetthumb
= (infoPtr
->rcThumb
.bottom
- infoPtr
->rcThumb
.top
)/2;
494 SetRect(&rcTics
, infoPtr
->rcThumb
.left
- 2, infoPtr
->rcChannel
.top
+ offsetthumb
,
495 infoPtr
->rcThumb
.right
+ 2, infoPtr
->rcChannel
.bottom
- offsetthumb
- 1);
497 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
498 SetRect(&rcTics
, infoPtr
->rcChannel
.left
+ offsetthumb
, infoPtr
->rcThumb
.top
- 2,
499 infoPtr
->rcChannel
.right
- offsetthumb
- 1, infoPtr
->rcThumb
.bottom
+ 2);
502 if (flags
& (TBS_TOP
| TBS_LEFT
)) {
512 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
514 range
= 1; /* to avoid division by zero */
516 if (flags
& TIC_SELECTIONMARK
) {
517 indent
= (flags
& TIC_SELECTIONMARKMIN
) ? -1 : 1;
518 } else if (flags
& TIC_EDGE
) {
522 if (flags
& TBS_VERT
) {
523 int height
= rcTics
.bottom
- rcTics
.top
;
524 y
= rcTics
.top
+ (height
*(ticPos
- infoPtr
->lRangeMin
))/range
;
526 int width
= rcTics
.right
- rcTics
.left
;
527 x
= rcTics
.left
+ (width
*(ticPos
- infoPtr
->lRangeMin
))/range
;
532 MoveToEx(hdc
, x
, y
, 0);
533 if (flags
& TBS_VERT
) x
+= len
* side
;
534 else y
+= len
* side
;
537 if (flags
& TIC_SELECTIONMARK
) {
538 if (flags
& TBS_VERT
) {
543 MoveToEx(hdc
, x
, y
, 0);
544 if (flags
& TBS_VERT
) {
557 TRACKBAR_DrawTic (const TRACKBAR_INFO
*infoPtr
, HDC hdc
, LONG ticPos
, int flags
)
559 if ((flags
& (TBS_LEFT
| TBS_TOP
)) || (flags
& TBS_BOTH
))
560 TRACKBAR_DrawOneTic (infoPtr
, hdc
, ticPos
, flags
| TBS_LEFT
);
562 if (!(flags
& (TBS_LEFT
| TBS_TOP
)) || (flags
& TBS_BOTH
))
563 TRACKBAR_DrawOneTic (infoPtr
, hdc
, ticPos
, flags
& ~TBS_LEFT
);
567 TRACKBAR_DrawTics (const TRACKBAR_INFO
*infoPtr
, HDC hdc
)
570 int ticFlags
= infoPtr
->dwStyle
& 0x0f;
571 LOGPEN ticPen
= { PS_SOLID
, {1, 0}, GetSysColor (COLOR_3DDKSHADOW
) };
572 HPEN hOldPen
, hTicPen
;
573 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
577 int part
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_TICSVERT
: TKP_TICS
;
578 GetThemeColor (theme
, part
, TSS_NORMAL
, TMT_COLOR
, &ticPen
.lopnColor
);
580 /* create the pen to draw the tics with */
581 hTicPen
= CreatePenIndirect(&ticPen
);
582 hOldPen
= hTicPen
? SelectObject(hdc
, hTicPen
) : 0;
584 /* actually draw the tics */
585 for (i
=0; i
<infoPtr
->uNumTics
; i
++)
586 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->tics
[i
], ticFlags
);
588 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lRangeMin
, ticFlags
| TIC_EDGE
);
589 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lRangeMax
, ticFlags
| TIC_EDGE
);
591 if ((infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) && TRACKBAR_HasSelection(infoPtr
)) {
592 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lSelMin
,
593 ticFlags
| TIC_SELECTIONMARKMIN
);
594 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lSelMax
,
595 ticFlags
| TIC_SELECTIONMARKMAX
);
598 /* clean up the pen, if we created one */
600 SelectObject(hdc
, hOldPen
);
601 DeleteObject(hTicPen
);
606 TRACKBAR_FillThumb (const TRACKBAR_INFO
*infoPtr
, HDC hdc
, HBRUSH hbrush
)
608 const RECT
*thumb
= &infoPtr
->rcThumb
;
613 if (infoPtr
->dwStyle
& TBS_BOTH
)
615 FillRect(hdc
, thumb
, hbrush
);
619 if (infoPtr
->dwStyle
& TBS_VERT
)
621 PointDepth
= (thumb
->bottom
- thumb
->top
) / 2;
622 if (infoPtr
->dwStyle
& TBS_LEFT
)
624 points
[0].x
= thumb
->right
-1;
625 points
[0].y
= thumb
->top
;
626 points
[1].x
= thumb
->right
-1;
627 points
[1].y
= thumb
->bottom
-1;
628 points
[2].x
= thumb
->left
+ PointDepth
;
629 points
[2].y
= thumb
->bottom
-1;
630 points
[3].x
= thumb
->left
;
631 points
[3].y
= thumb
->top
+ PointDepth
;
632 points
[4].x
= thumb
->left
+ PointDepth
;
633 points
[4].y
= thumb
->top
;
634 points
[5].x
= points
[0].x
;
635 points
[5].y
= points
[0].y
;
639 points
[0].x
= thumb
->right
;
640 points
[0].y
= thumb
->top
+ PointDepth
;
641 points
[1].x
= thumb
->right
- PointDepth
;
642 points
[1].y
= thumb
->bottom
-1;
643 points
[2].x
= thumb
->left
;
644 points
[2].y
= thumb
->bottom
-1;
645 points
[3].x
= thumb
->left
;
646 points
[3].y
= thumb
->top
;
647 points
[4].x
= thumb
->right
- PointDepth
;
648 points
[4].y
= thumb
->top
;
649 points
[5].x
= points
[0].x
;
650 points
[5].y
= points
[0].y
;
655 PointDepth
= (thumb
->right
- thumb
->left
) / 2;
656 if (infoPtr
->dwStyle
& TBS_TOP
)
658 points
[0].x
= thumb
->left
+ PointDepth
;
659 points
[0].y
= thumb
->top
+1;
660 points
[1].x
= thumb
->right
-1;
661 points
[1].y
= thumb
->top
+ PointDepth
+ 1;
662 points
[2].x
= thumb
->right
-1;
663 points
[2].y
= thumb
->bottom
-1;
664 points
[3].x
= thumb
->left
;
665 points
[3].y
= thumb
->bottom
-1;
666 points
[4].x
= thumb
->left
;
667 points
[4].y
= thumb
->top
+ PointDepth
+ 1;
668 points
[5].x
= points
[0].x
;
669 points
[5].y
= points
[0].y
;
673 points
[0].x
= thumb
->right
-1;
674 points
[0].y
= thumb
->top
;
675 points
[1].x
= thumb
->right
-1;
676 points
[1].y
= thumb
->bottom
- PointDepth
- 1;
677 points
[2].x
= thumb
->left
+ PointDepth
;
678 points
[2].y
= thumb
->bottom
-1;
679 points
[3].x
= thumb
->left
;
680 points
[3].y
= thumb
->bottom
- PointDepth
- 1;
681 points
[4].x
= thumb
->left
;
682 points
[4].y
= thumb
->top
;
683 points
[5].x
= points
[0].x
;
684 points
[5].y
= points
[0].y
;
688 oldbr
= SelectObject(hdc
, hbrush
);
689 SetPolyFillMode(hdc
, WINDING
);
690 Polygon(hdc
, points
, ARRAY_SIZE(points
));
691 SelectObject(hdc
, oldbr
);
697 TRACKBAR_DrawThumb (TRACKBAR_INFO
*infoPtr
, HDC hdc
)
699 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
707 if (infoPtr
->dwStyle
& TBS_BOTH
)
708 partId
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_THUMBVERT
: TKP_THUMB
;
709 else if (infoPtr
->dwStyle
& TBS_LEFT
)
710 partId
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_THUMBLEFT
: TKP_THUMBTOP
;
712 partId
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_THUMBRIGHT
: TKP_THUMBBOTTOM
;
714 if (infoPtr
->dwStyle
& WS_DISABLED
)
715 stateId
= TUS_DISABLED
;
716 else if (infoPtr
->flags
& TB_DRAG_MODE
)
717 stateId
= TUS_PRESSED
;
718 else if (infoPtr
->flags
& TB_THUMB_HOT
)
721 stateId
= TUS_NORMAL
;
723 DrawThemeBackground (theme
, hdc
, partId
, stateId
, &infoPtr
->rcThumb
, NULL
);
728 if (infoPtr
->dwStyle
& WS_DISABLED
|| infoPtr
->flags
& TB_DRAG_MODE
)
730 if (comctl32_color
.clr3dHilight
== comctl32_color
.clrWindow
)
731 brush
= COMCTL32_hPattern55AABrush
;
733 brush
= GetSysColorBrush(COLOR_SCROLLBAR
);
735 SetTextColor(hdc
, comctl32_color
.clr3dFace
);
736 SetBkColor(hdc
, comctl32_color
.clr3dHilight
);
739 brush
= GetSysColorBrush(COLOR_BTNFACE
);
741 PointDepth
= TRACKBAR_FillThumb(infoPtr
, hdc
, brush
);
743 if (infoPtr
->dwStyle
& TBS_BOTH
)
745 DrawEdge(hdc
, &infoPtr
->rcThumb
, EDGE_RAISED
, BF_RECT
| BF_SOFT
);
750 RECT thumb
= infoPtr
->rcThumb
;
752 if (infoPtr
->dwStyle
& TBS_VERT
)
754 if (infoPtr
->dwStyle
& TBS_LEFT
)
756 /* rectangular part */
757 thumb
.left
+= PointDepth
;
758 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_TOP
| BF_RIGHT
| BF_BOTTOM
| BF_SOFT
);
761 thumb
.left
-= PointDepth
;
762 thumb
.right
= thumb
.left
+ PointDepth
;
763 thumb
.bottom
= infoPtr
->rcThumb
.top
+ PointDepth
+ 1;
764 thumb
.top
= infoPtr
->rcThumb
.top
;
765 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPRIGHT
| BF_SOFT
);
768 thumb
.top
+= PointDepth
;
769 thumb
.bottom
+= PointDepth
;
770 DrawEdge(hdc
, &thumb
, EDGE_SUNKEN
, BF_DIAGONAL_ENDTOPLEFT
| BF_SOFT
);
775 /* rectangular part */
776 thumb
.right
-= PointDepth
;
777 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_TOP
| BF_LEFT
| BF_BOTTOM
| BF_SOFT
);
780 thumb
.left
= thumb
.right
;
781 thumb
.right
+= PointDepth
+ 1;
782 thumb
.bottom
= infoPtr
->rcThumb
.top
+ PointDepth
+ 1;
783 thumb
.top
= infoPtr
->rcThumb
.top
;
784 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPLEFT
| BF_SOFT
);
787 thumb
.top
+= PointDepth
;
788 thumb
.bottom
+= PointDepth
;
789 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDBOTTOMLEFT
| BF_SOFT
);
794 if (infoPtr
->dwStyle
& TBS_TOP
)
796 /* rectangular part */
797 thumb
.top
+= PointDepth
;
798 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_LEFT
| BF_BOTTOM
| BF_RIGHT
| BF_SOFT
);
801 thumb
.left
= infoPtr
->rcThumb
.left
;
802 thumb
.right
= thumb
.left
+ PointDepth
;
803 thumb
.bottom
= infoPtr
->rcThumb
.top
+ PointDepth
+ 1;
804 thumb
.top
-= PointDepth
;
805 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPRIGHT
| BF_SOFT
);
808 thumb
.left
+= PointDepth
;
809 thumb
.right
+= PointDepth
;
810 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDBOTTOMRIGHT
| BF_SOFT
);
814 /* rectangular part */
815 thumb
.bottom
-= PointDepth
;
816 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_LEFT
| BF_TOP
| BF_RIGHT
| BF_SOFT
);
819 thumb
.left
= infoPtr
->rcThumb
.left
;
820 thumb
.right
= thumb
.left
+ PointDepth
;
821 thumb
.top
= infoPtr
->rcThumb
.bottom
- PointDepth
- 1;
822 thumb
.bottom
+= PointDepth
;
823 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPLEFT
| BF_SOFT
);
826 thumb
.left
+= PointDepth
;
827 thumb
.right
+= PointDepth
;
828 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDBOTTOMLEFT
| BF_SOFT
);
836 TRACKBAR_ActivateToolTip (const TRACKBAR_INFO
*infoPtr
, BOOL fShow
)
840 if (!infoPtr
->hwndToolTip
) return;
842 ZeroMemory(&ti
, sizeof(ti
));
843 ti
.cbSize
= sizeof(ti
);
844 ti
.hwnd
= infoPtr
->hwndSelf
;
846 SendMessageW (infoPtr
->hwndToolTip
, TTM_TRACKACTIVATE
, fShow
, (LPARAM
)&ti
);
851 TRACKBAR_UpdateToolTip (const TRACKBAR_INFO
*infoPtr
)
854 static const WCHAR fmt
[] = { '%', 'l', 'd', 0 };
860 if (!infoPtr
->hwndToolTip
) return;
862 ZeroMemory(&ti
, sizeof(ti
));
863 ti
.cbSize
= sizeof(ti
);
864 ti
.hwnd
= infoPtr
->hwndSelf
;
865 ti
.uFlags
= TTF_IDISHWND
| TTF_TRACK
| TTF_ABSOLUTE
;
867 wsprintfW (buf
, fmt
, infoPtr
->lPos
);
869 SendMessageW (infoPtr
->hwndToolTip
, TTM_UPDATETIPTEXTW
, 0, (LPARAM
)&ti
);
871 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
872 size
= SendMessageW (infoPtr
->hwndToolTip
, TTM_GETBUBBLESIZE
, 0, (LPARAM
)&ti
);
873 if (infoPtr
->dwStyle
& TBS_VERT
) {
874 if (infoPtr
->fLocation
== TBTS_LEFT
)
875 pt
.x
= 0 - LOWORD(size
) - TOOLTIP_OFFSET
;
877 pt
.x
= rcClient
.right
+ TOOLTIP_OFFSET
;
878 pt
.y
= (infoPtr
->rcThumb
.top
+ infoPtr
->rcThumb
.bottom
- HIWORD(size
))/2;
880 if (infoPtr
->fLocation
== TBTS_TOP
)
881 pt
.y
= 0 - HIWORD(size
) - TOOLTIP_OFFSET
;
883 pt
.y
= rcClient
.bottom
+ TOOLTIP_OFFSET
;
884 pt
.x
= (infoPtr
->rcThumb
.left
+ infoPtr
->rcThumb
.right
- LOWORD(size
))/2;
886 ClientToScreen(infoPtr
->hwndSelf
, &pt
);
888 SendMessageW (infoPtr
->hwndToolTip
, TTM_TRACKPOSITION
,
889 0, MAKELPARAM(pt
.x
, pt
.y
));
894 TRACKBAR_Refresh (TRACKBAR_INFO
*infoPtr
, HDC hdcDst
)
898 HBITMAP hOldBmp
= 0, hOffScreenBmp
= 0;
902 if (infoPtr
->flags
& TB_THUMBCHANGED
) {
903 TRACKBAR_UpdateThumb (infoPtr
);
904 if (infoPtr
->flags
& TB_THUMBSIZECHANGED
)
905 TRACKBAR_CalcChannel (infoPtr
);
907 if (infoPtr
->flags
& TB_SELECTIONCHANGED
)
908 TRACKBAR_CalcSelection (infoPtr
);
910 if (infoPtr
->flags
& TB_DRAG_MODE
)
911 TRACKBAR_UpdateToolTip (infoPtr
);
913 infoPtr
->flags
&= ~ (TB_THUMBCHANGED
| TB_SELECTIONCHANGED
);
915 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
917 /* try to render offscreen, if we fail, carrry onscreen */
918 hdc
= CreateCompatibleDC(hdcDst
);
920 hOffScreenBmp
= CreateCompatibleBitmap(hdcDst
, rcClient
.right
, rcClient
.bottom
);
922 hOldBmp
= SelectObject(hdc
, hOffScreenBmp
);
931 ZeroMemory(&nmcd
, sizeof(nmcd
));
932 nmcd
.hdr
.hwndFrom
= infoPtr
->hwndSelf
;
933 nmcd
.hdr
.idFrom
= GetWindowLongPtrW (infoPtr
->hwndSelf
, GWLP_ID
);
934 nmcd
.hdr
.code
= NM_CUSTOMDRAW
;
937 /* start the paint cycle */
939 gcdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_PREPAINT
);
940 if (gcdrf
& CDRF_SKIPDEFAULT
) goto cleanup
;
942 /* Erase background */
943 if (gcdrf
== CDRF_DODEFAULT
||
944 notify_customdraw(infoPtr
, &nmcd
, CDDS_PREERASE
) != CDRF_SKIPDEFAULT
) {
945 if (GetWindowTheme (infoPtr
->hwndSelf
)) {
946 DrawThemeParentBackground (infoPtr
->hwndSelf
, hdc
, 0);
949 HBRUSH brush
= (HBRUSH
)SendMessageW(infoPtr
->hwndNotify
, WM_CTLCOLORSTATIC
,
950 (WPARAM
)hdc
, (LPARAM
)infoPtr
->hwndSelf
);
951 FillRect (hdc
, &rcClient
, brush
? brush
: GetSysColorBrush(COLOR_BTNFACE
));
953 if (gcdrf
!= CDRF_DODEFAULT
)
954 notify_customdraw(infoPtr
, &nmcd
, CDDS_POSTERASE
);
958 if (gcdrf
& CDRF_NOTIFYITEMDRAW
) {
959 nmcd
.dwItemSpec
= TBCD_CHANNEL
;
960 nmcd
.uItemState
= CDIS_DEFAULT
;
961 nmcd
.rc
= infoPtr
->rcChannel
;
962 icdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPREPAINT
);
963 } else icdrf
= CDRF_DODEFAULT
;
964 if ( !(icdrf
& CDRF_SKIPDEFAULT
) ) {
965 TRACKBAR_DrawChannel (infoPtr
, hdc
);
966 if (icdrf
& CDRF_NOTIFYPOSTPAINT
)
967 notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPOSTPAINT
);
972 if (!(infoPtr
->dwStyle
& TBS_NOTICKS
)) {
973 if (gcdrf
& CDRF_NOTIFYITEMDRAW
) {
974 nmcd
.dwItemSpec
= TBCD_TICS
;
975 nmcd
.uItemState
= CDIS_DEFAULT
;
977 icdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPREPAINT
);
978 } else icdrf
= CDRF_DODEFAULT
;
979 if ( !(icdrf
& CDRF_SKIPDEFAULT
) ) {
980 TRACKBAR_DrawTics (infoPtr
, hdc
);
981 if (icdrf
& CDRF_NOTIFYPOSTPAINT
)
982 notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPOSTPAINT
);
987 if (!(infoPtr
->dwStyle
& TBS_NOTHUMB
)) {
988 if (gcdrf
& CDRF_NOTIFYITEMDRAW
) {
989 nmcd
.dwItemSpec
= TBCD_THUMB
;
990 nmcd
.uItemState
= infoPtr
->flags
& TB_DRAG_MODE
? CDIS_HOT
: CDIS_DEFAULT
;
991 nmcd
.rc
= infoPtr
->rcThumb
;
992 icdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPREPAINT
);
993 } else icdrf
= CDRF_DODEFAULT
;
994 if ( !(icdrf
& CDRF_SKIPDEFAULT
) ) {
995 TRACKBAR_DrawThumb(infoPtr
, hdc
);
996 if (icdrf
& CDRF_NOTIFYPOSTPAINT
)
997 notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPOSTPAINT
);
1001 /* draw focus rectangle */
1002 if (infoPtr
->flags
& TB_IS_FOCUSED
) {
1003 DrawFocusRect(hdc
, &rcClient
);
1006 /* finish up the painting */
1007 if (gcdrf
& CDRF_NOTIFYPOSTPAINT
)
1008 notify_customdraw(infoPtr
, &nmcd
, CDDS_POSTPAINT
);
1011 /* cleanup, if we rendered offscreen */
1012 if (hdc
!= hdcDst
) {
1013 BitBlt(hdcDst
, 0, 0, rcClient
.right
, rcClient
.bottom
, hdc
, 0, 0, SRCCOPY
);
1014 SelectObject(hdc
, hOldBmp
);
1015 DeleteObject(hOffScreenBmp
);
1022 TRACKBAR_AlignBuddies (const TRACKBAR_INFO
*infoPtr
)
1024 HWND hwndParent
= GetParent (infoPtr
->hwndSelf
);
1025 RECT rcSelf
, rcBuddy
;
1028 GetWindowRect (infoPtr
->hwndSelf
, &rcSelf
);
1029 MapWindowPoints (HWND_DESKTOP
, hwndParent
, (LPPOINT
)&rcSelf
, 2);
1031 /* align buddy left or above */
1032 if (infoPtr
->hwndBuddyLA
) {
1033 GetWindowRect (infoPtr
->hwndBuddyLA
, &rcBuddy
);
1034 MapWindowPoints (HWND_DESKTOP
, hwndParent
, (LPPOINT
)&rcBuddy
, 2);
1036 if (infoPtr
->dwStyle
& TBS_VERT
) {
1037 x
= (infoPtr
->rcChannel
.right
+ infoPtr
->rcChannel
.left
) / 2 -
1038 (rcBuddy
.right
- rcBuddy
.left
) / 2 + rcSelf
.left
;
1039 y
= rcSelf
.top
- (rcBuddy
.bottom
- rcBuddy
.top
);
1042 x
= rcSelf
.left
- (rcBuddy
.right
- rcBuddy
.left
);
1043 y
= (infoPtr
->rcChannel
.bottom
+ infoPtr
->rcChannel
.top
) / 2 -
1044 (rcBuddy
.bottom
- rcBuddy
.top
) / 2 + rcSelf
.top
;
1047 SetWindowPos (infoPtr
->hwndBuddyLA
, 0, x
, y
, 0, 0,
1048 SWP_NOZORDER
| SWP_NOSIZE
);
1052 /* align buddy right or below */
1053 if (infoPtr
->hwndBuddyRB
) {
1054 GetWindowRect (infoPtr
->hwndBuddyRB
, &rcBuddy
);
1055 MapWindowPoints (HWND_DESKTOP
, hwndParent
, (LPPOINT
)&rcBuddy
, 2);
1057 if (infoPtr
->dwStyle
& TBS_VERT
) {
1058 x
= (infoPtr
->rcChannel
.right
+ infoPtr
->rcChannel
.left
) / 2 -
1059 (rcBuddy
.right
- rcBuddy
.left
) / 2 + rcSelf
.left
;
1064 y
= (infoPtr
->rcChannel
.bottom
+ infoPtr
->rcChannel
.top
) / 2 -
1065 (rcBuddy
.bottom
- rcBuddy
.top
) / 2 + rcSelf
.top
;
1067 SetWindowPos (infoPtr
->hwndBuddyRB
, 0, x
, y
, 0, 0,
1068 SWP_NOZORDER
| SWP_NOSIZE
);
1074 TRACKBAR_ClearSel (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
)
1076 infoPtr
->lSelMin
= 0;
1077 infoPtr
->lSelMax
= 0;
1078 infoPtr
->flags
|= TB_SELECTIONCHANGED
;
1080 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1087 TRACKBAR_ClearTics (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
)
1089 if (infoPtr
->tics
) {
1090 Free (infoPtr
->tics
);
1091 infoPtr
->tics
= NULL
;
1092 infoPtr
->uNumTics
= 0;
1095 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1101 static inline LRESULT
1102 TRACKBAR_GetChannelRect (const TRACKBAR_INFO
*infoPtr
, LPRECT lprc
)
1104 if (lprc
== NULL
) return 0;
1106 lprc
->left
= infoPtr
->rcChannel
.left
;
1107 lprc
->right
= infoPtr
->rcChannel
.right
;
1108 lprc
->bottom
= infoPtr
->rcChannel
.bottom
;
1109 lprc
->top
= infoPtr
->rcChannel
.top
;
1116 TRACKBAR_GetNumTics (const TRACKBAR_INFO
*infoPtr
)
1118 if (infoPtr
->dwStyle
& TBS_NOTICKS
) return 0;
1120 return infoPtr
->uNumTics
+ 2;
1124 static int comp_tics (const void *ap
, const void *bp
)
1126 const DWORD a
= *(const DWORD
*)ap
;
1127 const DWORD b
= *(const DWORD
*)bp
;
1129 TRACE("(a=%d, b=%d)\n", a
, b
);
1130 if (a
< b
) return -1;
1131 if (a
> b
) return 1;
1137 TRACKBAR_GetTic (const TRACKBAR_INFO
*infoPtr
, INT iTic
)
1139 if ((iTic
< 0) || (iTic
>= infoPtr
->uNumTics
) || !infoPtr
->tics
)
1142 qsort(infoPtr
->tics
, infoPtr
->uNumTics
, sizeof(DWORD
), comp_tics
);
1143 return infoPtr
->tics
[iTic
];
1148 TRACKBAR_GetTicPos (const TRACKBAR_INFO
*infoPtr
, INT iTic
)
1150 LONG range
, width
, pos
, tic
;
1153 if ((iTic
< 0) || (iTic
>= infoPtr
->uNumTics
) || !infoPtr
->tics
)
1156 tic
= TRACKBAR_GetTic (infoPtr
, iTic
);
1157 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
1158 if (range
<= 0) range
= 1;
1159 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
1160 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- offsetthumb
*2;
1161 pos
= infoPtr
->rcChannel
.left
+ offsetthumb
+ (width
* tic
) / range
;
1168 TRACKBAR_SetBuddy (TRACKBAR_INFO
*infoPtr
, BOOL fLocation
, HWND hwndBuddy
)
1173 /* buddy is left or above */
1174 hwndTemp
= infoPtr
->hwndBuddyLA
;
1175 infoPtr
->hwndBuddyLA
= hwndBuddy
;
1178 /* buddy is right or below */
1179 hwndTemp
= infoPtr
->hwndBuddyRB
;
1180 infoPtr
->hwndBuddyRB
= hwndBuddy
;
1183 TRACKBAR_AlignBuddies (infoPtr
);
1190 TRACKBAR_SetLineSize (TRACKBAR_INFO
*infoPtr
, LONG lLineSize
)
1192 LONG lTemp
= infoPtr
->lLineSize
;
1194 infoPtr
->lLineSize
= lLineSize
;
1199 static void TRACKBAR_UpdatePageSize(TRACKBAR_INFO
*infoPtr
)
1201 if (infoPtr
->flags
& TB_USER_PAGE
)
1204 infoPtr
->lPageSize
= (infoPtr
->lRangeMax
- infoPtr
->lRangeMin
) / 5;
1205 if (infoPtr
->lPageSize
== 0) infoPtr
->lPageSize
= 1;
1209 TRACKBAR_SetPageSize (TRACKBAR_INFO
*infoPtr
, LONG lPageSize
)
1211 LONG lTemp
= infoPtr
->lPageSize
;
1213 if (lPageSize
== -1)
1215 infoPtr
->flags
&= ~TB_USER_PAGE
;
1216 TRACKBAR_UpdatePageSize(infoPtr
);
1220 infoPtr
->flags
|= TB_USER_PAGE
;
1221 infoPtr
->lPageSize
= lPageSize
;
1228 static inline LRESULT
1229 TRACKBAR_SetPos (TRACKBAR_INFO
*infoPtr
, BOOL fPosition
, LONG lPosition
)
1231 LONG oldPos
= infoPtr
->lPos
;
1232 infoPtr
->lPos
= lPosition
;
1234 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
1235 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1237 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
1238 infoPtr
->lPos
= infoPtr
->lRangeMax
;
1240 if (fPosition
&& oldPos
!= lPosition
)
1242 TRACKBAR_UpdateThumb(infoPtr
);
1243 TRACKBAR_InvalidateThumbMove(infoPtr
, oldPos
, lPosition
);
1249 static inline LRESULT
1250 TRACKBAR_SetRange (TRACKBAR_INFO
*infoPtr
, BOOL redraw
, LONG range
)
1252 BOOL changed
= infoPtr
->lRangeMin
!= (SHORT
)LOWORD(range
) ||
1253 infoPtr
->lRangeMax
!= (SHORT
)HIWORD(range
);
1255 infoPtr
->lRangeMin
= (SHORT
)LOWORD(range
);
1256 infoPtr
->lRangeMax
= (SHORT
)HIWORD(range
);
1258 /* clip position to new min/max limit */
1259 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
1260 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1262 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
1263 infoPtr
->lPos
= infoPtr
->lRangeMax
;
1265 TRACKBAR_UpdatePageSize(infoPtr
);
1268 if (infoPtr
->dwStyle
& TBS_AUTOTICKS
)
1269 TRACKBAR_RecalculateTics (infoPtr
);
1270 infoPtr
->flags
|= TB_THUMBPOSCHANGED
;
1273 if (redraw
) TRACKBAR_InvalidateAll(infoPtr
);
1279 static inline LRESULT
1280 TRACKBAR_SetRangeMax (TRACKBAR_INFO
*infoPtr
, BOOL redraw
, LONG lMax
)
1282 BOOL changed
= infoPtr
->lRangeMax
!= lMax
;
1283 LONG rightmost
= max(lMax
, infoPtr
->lRangeMin
);
1285 infoPtr
->lRangeMax
= lMax
;
1286 if (infoPtr
->lPos
> rightmost
) {
1287 infoPtr
->lPos
= rightmost
;
1288 infoPtr
->flags
|= TB_THUMBPOSCHANGED
;
1291 TRACKBAR_UpdatePageSize(infoPtr
);
1293 if (changed
&& (infoPtr
->dwStyle
& TBS_AUTOTICKS
))
1294 TRACKBAR_RecalculateTics (infoPtr
);
1296 if (redraw
) TRACKBAR_InvalidateAll(infoPtr
);
1302 static inline LRESULT
1303 TRACKBAR_SetRangeMin (TRACKBAR_INFO
*infoPtr
, BOOL redraw
, LONG lMin
)
1305 BOOL changed
= infoPtr
->lRangeMin
!= lMin
;
1307 infoPtr
->lRangeMin
= lMin
;
1308 if (infoPtr
->lPos
< infoPtr
->lRangeMin
) {
1309 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1310 infoPtr
->flags
|= TB_THUMBPOSCHANGED
;
1313 TRACKBAR_UpdatePageSize(infoPtr
);
1315 if (changed
&& (infoPtr
->dwStyle
& TBS_AUTOTICKS
))
1316 TRACKBAR_RecalculateTics (infoPtr
);
1318 if (redraw
) TRACKBAR_InvalidateAll(infoPtr
);
1324 static inline LRESULT
1325 TRACKBAR_SetSel (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
, LONG lSel
)
1327 if (!(infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)){
1328 infoPtr
->lSelMin
= 0;
1329 infoPtr
->lSelMax
= 0;
1333 infoPtr
->lSelMin
= (SHORT
)LOWORD(lSel
);
1334 infoPtr
->lSelMax
= (SHORT
)HIWORD(lSel
);
1335 infoPtr
->flags
|= TB_SELECTIONCHANGED
;
1337 if (infoPtr
->lSelMin
< infoPtr
->lRangeMin
)
1338 infoPtr
->lSelMin
= infoPtr
->lRangeMin
;
1339 if (infoPtr
->lSelMax
> infoPtr
->lRangeMax
)
1340 infoPtr
->lSelMax
= infoPtr
->lRangeMax
;
1342 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1348 static inline LRESULT
1349 TRACKBAR_SetSelEnd (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
, LONG lEnd
)
1351 if (!(infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)){
1352 infoPtr
->lSelMax
= 0;
1356 infoPtr
->lSelMax
= lEnd
;
1357 infoPtr
->flags
|= TB_SELECTIONCHANGED
;
1359 if (infoPtr
->lSelMax
> infoPtr
->lRangeMax
)
1360 infoPtr
->lSelMax
= infoPtr
->lRangeMax
;
1362 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1368 static inline LRESULT
1369 TRACKBAR_SetSelStart (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
, LONG lStart
)
1371 if (!(infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)){
1372 infoPtr
->lSelMin
= 0;
1376 infoPtr
->lSelMin
= lStart
;
1377 infoPtr
->flags
|=TB_SELECTIONCHANGED
;
1379 if (infoPtr
->lSelMin
< infoPtr
->lRangeMin
)
1380 infoPtr
->lSelMin
= infoPtr
->lRangeMin
;
1382 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1388 static inline LRESULT
1389 TRACKBAR_SetThumbLength (TRACKBAR_INFO
*infoPtr
, UINT iLength
)
1391 if (infoPtr
->dwStyle
& TBS_FIXEDLENGTH
) {
1392 /* We're not supposed to check if it's really changed or not,
1393 just repaint in any case. */
1394 infoPtr
->uThumbLen
= iLength
;
1395 infoPtr
->flags
|= TB_THUMBSIZECHANGED
;
1396 TRACKBAR_InvalidateAll(infoPtr
);
1403 static inline LRESULT
1404 TRACKBAR_SetTic (TRACKBAR_INFO
*infoPtr
, LONG lPos
)
1406 if ((lPos
< infoPtr
->lRangeMin
) || (lPos
> infoPtr
->lRangeMax
))
1409 TRACE("lPos=%d\n", lPos
);
1411 infoPtr
->uNumTics
++;
1412 infoPtr
->tics
=ReAlloc( infoPtr
->tics
,
1413 (infoPtr
->uNumTics
)*sizeof (DWORD
));
1414 if (!infoPtr
->tics
) {
1415 infoPtr
->uNumTics
= 0;
1416 notify(infoPtr
, NM_OUTOFMEMORY
);
1419 infoPtr
->tics
[infoPtr
->uNumTics
-1] = lPos
;
1421 TRACKBAR_InvalidateAll(infoPtr
);
1427 static inline LRESULT
1428 TRACKBAR_SetTicFreq (TRACKBAR_INFO
*infoPtr
, WORD wFreq
)
1430 if (infoPtr
->dwStyle
& TBS_AUTOTICKS
) {
1431 infoPtr
->uTicFreq
= wFreq
;
1432 TRACKBAR_RecalculateTics (infoPtr
);
1433 TRACKBAR_InvalidateAll(infoPtr
);
1436 TRACKBAR_UpdateThumb (infoPtr
);
1442 TRACKBAR_SetTipSide (TRACKBAR_INFO
*infoPtr
, INT fLocation
)
1444 INT fTemp
= infoPtr
->fLocation
;
1446 infoPtr
->fLocation
= fLocation
;
1452 static inline LRESULT
1453 TRACKBAR_SetToolTips (TRACKBAR_INFO
*infoPtr
, HWND hwndTT
)
1455 infoPtr
->hwndToolTip
= hwndTT
;
1462 TRACKBAR_SetUnicodeFormat (TRACKBAR_INFO
*infoPtr
, BOOL fUnicode
)
1464 BOOL bTemp
= infoPtr
->bUnicode
;
1466 infoPtr
->bUnicode
= fUnicode
;
1471 static int get_scaled_metric(const TRACKBAR_INFO
*infoPtr
, int value
)
1473 return MulDiv(value
, GetDpiForWindow(infoPtr
->hwndSelf
), 96);
1477 TRACKBAR_InitializeThumb (TRACKBAR_INFO
*infoPtr
)
1482 infoPtr
->uThumbLen
= get_scaled_metric(infoPtr
, infoPtr
->dwStyle
& TBS_ENABLESELRANGE
? 23 : 21);
1484 GetClientRect(infoPtr
->hwndSelf
,&rect
);
1485 if (infoPtr
->dwStyle
& TBS_VERT
)
1486 client_size
= rect
.right
- rect
.left
;
1488 client_size
= rect
.bottom
- rect
.top
;
1490 if (client_size
< infoPtr
->uThumbLen
)
1491 infoPtr
->uThumbLen
= client_size
> get_scaled_metric(infoPtr
, 9) ?
1492 client_size
- get_scaled_metric(infoPtr
, 5) : get_scaled_metric(infoPtr
, 4);
1494 TRACKBAR_CalcChannel (infoPtr
);
1495 TRACKBAR_UpdateThumb (infoPtr
);
1496 infoPtr
->flags
&= ~TB_SELECTIONCHANGED
;
1503 TRACKBAR_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
1505 TRACKBAR_INFO
*infoPtr
;
1507 infoPtr
= Alloc (sizeof(TRACKBAR_INFO
));
1508 if (!infoPtr
) return -1;
1509 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
1511 /* set default values */
1512 infoPtr
->hwndSelf
= hwnd
;
1513 infoPtr
->dwStyle
= lpcs
->style
;
1514 infoPtr
->lRangeMin
= 0;
1515 infoPtr
->lRangeMax
= 100;
1516 infoPtr
->lLineSize
= 1;
1517 infoPtr
->lPageSize
= TB_DEFAULTPAGESIZE
;
1518 infoPtr
->lSelMin
= 0;
1519 infoPtr
->lSelMax
= 0;
1521 infoPtr
->fLocation
= TBTS_TOP
;
1522 infoPtr
->uNumTics
= 0; /* start and end tic are not included in count*/
1523 infoPtr
->uTicFreq
= 1;
1524 infoPtr
->tics
= NULL
;
1525 infoPtr
->hwndNotify
= lpcs
->hwndParent
;
1527 TRACKBAR_InitializeThumb (infoPtr
);
1529 /* Create tooltip control */
1530 if (infoPtr
->dwStyle
& TBS_TOOLTIPS
) {
1532 infoPtr
->hwndToolTip
=
1533 CreateWindowExW (0, TOOLTIPS_CLASSW
, NULL
, WS_POPUP
,
1534 CW_USEDEFAULT
, CW_USEDEFAULT
,
1535 CW_USEDEFAULT
, CW_USEDEFAULT
,
1538 if (infoPtr
->hwndToolTip
) {
1541 ZeroMemory (&ti
, sizeof(ti
));
1542 ti
.cbSize
= sizeof(ti
);
1543 ti
.uFlags
= TTF_IDISHWND
| TTF_TRACK
| TTF_ABSOLUTE
;
1545 ti
.lpszText
= &wEmpty
;
1547 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
, 0, (LPARAM
)&ti
);
1551 OpenThemeData (hwnd
, themeClass
);
1558 TRACKBAR_Destroy (TRACKBAR_INFO
*infoPtr
)
1560 /* delete tooltip control */
1561 if (infoPtr
->hwndToolTip
)
1562 DestroyWindow (infoPtr
->hwndToolTip
);
1564 Free (infoPtr
->tics
);
1565 infoPtr
->tics
= NULL
;
1567 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
1568 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
1576 TRACKBAR_KillFocus (TRACKBAR_INFO
*infoPtr
)
1579 infoPtr
->flags
&= ~TB_IS_FOCUSED
;
1580 TRACKBAR_InvalidateAll(infoPtr
);
1586 TRACKBAR_LButtonDown (TRACKBAR_INFO
*infoPtr
, INT x
, INT y
)
1593 SetFocus(infoPtr
->hwndSelf
);
1595 if (PtInRect(&infoPtr
->rcThumb
, clickPoint
)) {
1596 infoPtr
->flags
|= TB_DRAG_MODE
;
1597 SetCapture (infoPtr
->hwndSelf
);
1598 TRACKBAR_UpdateToolTip (infoPtr
);
1599 TRACKBAR_ActivateToolTip (infoPtr
, TRUE
);
1600 TRACKBAR_InvalidateThumb(infoPtr
, infoPtr
->lPos
);
1602 LONG dir
= TRACKBAR_GetAutoPageDirection(infoPtr
, clickPoint
);
1603 if (dir
== 0) return 0;
1604 infoPtr
->flags
|= (dir
< 0) ? TB_AUTO_PAGE_LEFT
: TB_AUTO_PAGE_RIGHT
;
1605 TRACKBAR_AutoPage (infoPtr
, clickPoint
);
1606 SetCapture (infoPtr
->hwndSelf
);
1607 SetTimer(infoPtr
->hwndSelf
, TB_REFRESH_TIMER
, TB_REFRESH_DELAY
, 0);
1615 TRACKBAR_LButtonUp (TRACKBAR_INFO
*infoPtr
)
1617 if (infoPtr
->flags
& TB_DRAG_MODE
) {
1618 notify_with_scroll (infoPtr
, TB_THUMBPOSITION
| (infoPtr
->lPos
<<16));
1619 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1620 infoPtr
->flags
&= ~TB_DRAG_MODE
;
1622 notify(infoPtr
, NM_RELEASEDCAPTURE
);
1623 TRACKBAR_ActivateToolTip(infoPtr
, FALSE
);
1624 TRACKBAR_InvalidateThumb(infoPtr
, infoPtr
->lPos
);
1626 if (infoPtr
->flags
& TB_AUTO_PAGE
) {
1627 KillTimer (infoPtr
->hwndSelf
, TB_REFRESH_TIMER
);
1628 infoPtr
->flags
&= ~TB_AUTO_PAGE
;
1629 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1631 notify(infoPtr
, NM_RELEASEDCAPTURE
);
1639 TRACKBAR_CaptureChanged (const TRACKBAR_INFO
*infoPtr
)
1641 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1647 TRACKBAR_Paint (TRACKBAR_INFO
*infoPtr
, HDC hdc
)
1650 TRACKBAR_Refresh(infoPtr
, hdc
);
1653 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
1654 TRACKBAR_Refresh (infoPtr
, hdc
);
1655 EndPaint (infoPtr
->hwndSelf
, &ps
);
1663 TRACKBAR_SetFocus (TRACKBAR_INFO
*infoPtr
)
1666 infoPtr
->flags
|= TB_IS_FOCUSED
;
1667 TRACKBAR_InvalidateAll(infoPtr
);
1674 TRACKBAR_Size (TRACKBAR_INFO
*infoPtr
)
1676 if (infoPtr
->dwStyle
& TBS_FIXEDLENGTH
)
1678 TRACKBAR_CalcChannel(infoPtr
);
1679 TRACKBAR_UpdateThumb(infoPtr
);
1682 TRACKBAR_InitializeThumb(infoPtr
);
1683 TRACKBAR_AlignBuddies (infoPtr
);
1684 TRACKBAR_InvalidateAll(infoPtr
);
1690 TRACKBAR_StyleChanged (TRACKBAR_INFO
*infoPtr
, WPARAM wStyleType
,
1691 const STYLESTRUCT
*lpss
)
1693 if (wStyleType
!= GWL_STYLE
) return 0;
1695 infoPtr
->dwStyle
= lpss
->styleNew
;
1701 TRACKBAR_Timer (TRACKBAR_INFO
*infoPtr
)
1703 if (infoPtr
->flags
& TB_AUTO_PAGE
) {
1705 if (GetCursorPos(&pt
))
1706 if (ScreenToClient(infoPtr
->hwndSelf
, &pt
))
1707 TRACKBAR_AutoPage(infoPtr
, pt
);
1713 /* update theme after a WM_THEMECHANGED message */
1714 static LRESULT
theme_changed (const TRACKBAR_INFO
* infoPtr
)
1716 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1717 CloseThemeData (theme
);
1718 OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
1724 TRACKBAR_MouseMove (TRACKBAR_INFO
*infoPtr
, INT x
, INT y
)
1726 INT clickPlace
= (infoPtr
->dwStyle
& TBS_VERT
) ? y
: x
;
1727 LONG dragPos
, oldPos
= infoPtr
->lPos
;
1729 TRACE("(x=%d. y=%d)\n", x
, y
);
1731 if (infoPtr
->flags
& TB_AUTO_PAGE
) {
1735 TRACKBAR_AutoPage (infoPtr
, pt
);
1739 if (!(infoPtr
->flags
& TB_DRAG_MODE
))
1741 if (GetWindowTheme (infoPtr
->hwndSelf
))
1743 DWORD oldFlags
= infoPtr
->flags
;
1747 if (PtInRect (&infoPtr
->rcThumb
, pt
))
1749 TRACKMOUSEEVENT tme
;
1750 tme
.cbSize
= sizeof( tme
);
1751 tme
.dwFlags
= TME_LEAVE
;
1752 tme
.hwndTrack
= infoPtr
->hwndSelf
;
1753 TrackMouseEvent( &tme
);
1754 infoPtr
->flags
|= TB_THUMB_HOT
;
1758 TRACKMOUSEEVENT tme
;
1759 tme
.cbSize
= sizeof( tme
);
1760 tme
.dwFlags
= TME_CANCEL
;
1761 tme
.hwndTrack
= infoPtr
->hwndSelf
;
1762 TrackMouseEvent( &tme
);
1763 infoPtr
->flags
&= ~TB_THUMB_HOT
;
1765 if (oldFlags
!= infoPtr
->flags
) InvalidateRect (infoPtr
->hwndSelf
, &infoPtr
->rcThumb
, FALSE
);
1770 dragPos
= TRACKBAR_ConvertPlaceToPosition (infoPtr
, clickPlace
);
1772 if (dragPos
== oldPos
) return TRUE
;
1774 infoPtr
->lPos
= dragPos
;
1775 TRACKBAR_UpdateThumb (infoPtr
);
1777 notify_with_scroll (infoPtr
, TB_THUMBTRACK
| (infoPtr
->lPos
<<16));
1779 TRACKBAR_InvalidateThumbMove(infoPtr
, oldPos
, dragPos
);
1780 UpdateWindow (infoPtr
->hwndSelf
);
1786 TRACKBAR_KeyDown (TRACKBAR_INFO
*infoPtr
, INT nVirtKey
)
1788 BOOL downIsLeft
= infoPtr
->dwStyle
& TBS_DOWNISLEFT
;
1789 BOOL vert
= infoPtr
->dwStyle
& TBS_VERT
;
1790 LONG pos
= infoPtr
->lPos
;
1792 TRACE("%x\n", nVirtKey
);
1796 if (!vert
&& downIsLeft
) TRACKBAR_LineDown(infoPtr
);
1797 else TRACKBAR_LineUp(infoPtr
);
1800 if (vert
&& downIsLeft
) TRACKBAR_LineDown(infoPtr
);
1801 else TRACKBAR_LineUp(infoPtr
);
1804 if (!vert
&& downIsLeft
) TRACKBAR_LineUp(infoPtr
);
1805 else TRACKBAR_LineDown(infoPtr
);
1808 if (vert
&& downIsLeft
) TRACKBAR_LineUp(infoPtr
);
1809 else TRACKBAR_LineDown(infoPtr
);
1812 if (!vert
&& downIsLeft
) TRACKBAR_PageUp(infoPtr
);
1813 else TRACKBAR_PageDown(infoPtr
);
1816 if (!vert
&& downIsLeft
) TRACKBAR_PageDown(infoPtr
);
1817 else TRACKBAR_PageUp(infoPtr
);
1820 if (infoPtr
->lPos
== infoPtr
->lRangeMin
) return FALSE
;
1821 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1822 notify_with_scroll (infoPtr
, TB_TOP
);
1825 if (infoPtr
->lPos
== infoPtr
->lRangeMax
) return FALSE
;
1826 infoPtr
->lPos
= infoPtr
->lRangeMax
;
1827 notify_with_scroll (infoPtr
, TB_BOTTOM
);
1831 if (pos
!= infoPtr
->lPos
) {
1832 TRACKBAR_UpdateThumb (infoPtr
);
1833 TRACKBAR_InvalidateThumbMove (infoPtr
, pos
, infoPtr
->lPos
);
1841 TRACKBAR_KeyUp (const TRACKBAR_INFO
*infoPtr
, INT nVirtKey
)
1852 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1859 TRACKBAR_Enable (TRACKBAR_INFO
*infoPtr
, BOOL enable
)
1862 infoPtr
->dwStyle
&= ~WS_DISABLED
;
1864 infoPtr
->dwStyle
|= WS_DISABLED
;
1866 InvalidateRect(infoPtr
->hwndSelf
, &infoPtr
->rcThumb
, TRUE
);
1871 static LRESULT WINAPI
1872 TRACKBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1874 TRACKBAR_INFO
*infoPtr
= (TRACKBAR_INFO
*)GetWindowLongPtrW (hwnd
, 0);
1876 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
1878 if (!infoPtr
&& (uMsg
!= WM_CREATE
))
1879 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
1884 return TRACKBAR_ClearSel (infoPtr
, (BOOL
)wParam
);
1887 return TRACKBAR_ClearTics (infoPtr
, (BOOL
)wParam
);
1890 return (LRESULT
)(wParam
? infoPtr
->hwndBuddyLA
: infoPtr
->hwndBuddyRB
);
1892 case TBM_GETCHANNELRECT
:
1893 return TRACKBAR_GetChannelRect (infoPtr
, (LPRECT
)lParam
);
1895 case TBM_GETLINESIZE
:
1896 return infoPtr
->lLineSize
;
1898 case TBM_GETNUMTICS
:
1899 return TRACKBAR_GetNumTics (infoPtr
);
1901 case TBM_GETPAGESIZE
:
1902 return infoPtr
->lPageSize
;
1905 return infoPtr
->lPos
;
1908 return (LRESULT
)infoPtr
->tics
;
1910 case TBM_GETRANGEMAX
:
1911 return infoPtr
->lRangeMax
;
1913 case TBM_GETRANGEMIN
:
1914 return infoPtr
->lRangeMin
;
1917 return infoPtr
->lSelMax
;
1919 case TBM_GETSELSTART
:
1920 return infoPtr
->lSelMin
;
1922 case TBM_GETTHUMBLENGTH
:
1923 return infoPtr
->uThumbLen
;
1925 case TBM_GETTHUMBRECT
:
1926 return CopyRect((LPRECT
)lParam
, &infoPtr
->rcThumb
);
1929 return TRACKBAR_GetTic (infoPtr
, (INT
)wParam
);
1932 return TRACKBAR_GetTicPos (infoPtr
, (INT
)wParam
);
1934 case TBM_GETTOOLTIPS
:
1935 return (LRESULT
)infoPtr
->hwndToolTip
;
1937 case TBM_GETUNICODEFORMAT
:
1938 return infoPtr
->bUnicode
;
1941 return (LRESULT
) TRACKBAR_SetBuddy(infoPtr
, (BOOL
)wParam
, (HWND
)lParam
);
1943 case TBM_SETLINESIZE
:
1944 return TRACKBAR_SetLineSize (infoPtr
, (LONG
)lParam
);
1946 case TBM_SETPAGESIZE
:
1947 return TRACKBAR_SetPageSize (infoPtr
, (LONG
)lParam
);
1950 return TRACKBAR_SetPos (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1953 return TRACKBAR_SetRange (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1955 case TBM_SETRANGEMAX
:
1956 return TRACKBAR_SetRangeMax (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1958 case TBM_SETRANGEMIN
:
1959 return TRACKBAR_SetRangeMin (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1962 return TRACKBAR_SetSel (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1965 return TRACKBAR_SetSelEnd (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1967 case TBM_SETSELSTART
:
1968 return TRACKBAR_SetSelStart (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1970 case TBM_SETTHUMBLENGTH
:
1971 return TRACKBAR_SetThumbLength (infoPtr
, (UINT
)wParam
);
1974 return TRACKBAR_SetTic (infoPtr
, (LONG
)lParam
);
1976 case TBM_SETTICFREQ
:
1977 return TRACKBAR_SetTicFreq (infoPtr
, (WORD
)wParam
);
1979 case TBM_SETTIPSIDE
:
1980 return TRACKBAR_SetTipSide (infoPtr
, (INT
)wParam
);
1982 case TBM_SETTOOLTIPS
:
1983 return TRACKBAR_SetToolTips (infoPtr
, (HWND
)wParam
);
1985 case TBM_SETUNICODEFORMAT
:
1986 return TRACKBAR_SetUnicodeFormat (infoPtr
, (BOOL
)wParam
);
1989 case WM_CAPTURECHANGED
:
1990 if (hwnd
== (HWND
)lParam
) return 0;
1991 return TRACKBAR_CaptureChanged (infoPtr
);
1994 return TRACKBAR_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
1997 return TRACKBAR_Destroy (infoPtr
);
2000 return TRACKBAR_Enable (infoPtr
, (BOOL
)wParam
);
2006 return DLGC_WANTARROWS
;
2009 return TRACKBAR_KeyDown (infoPtr
, (INT
)wParam
);
2012 return TRACKBAR_KeyUp (infoPtr
, (INT
)wParam
);
2015 return TRACKBAR_KillFocus (infoPtr
);
2017 case WM_LBUTTONDOWN
:
2018 return TRACKBAR_LButtonDown (infoPtr
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
2021 return TRACKBAR_LButtonUp (infoPtr
);
2024 infoPtr
->flags
&= ~TB_THUMB_HOT
;
2025 InvalidateRect (infoPtr
->hwndSelf
, &infoPtr
->rcThumb
, FALSE
);
2029 return TRACKBAR_MouseMove (infoPtr
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
2031 case WM_PRINTCLIENT
:
2033 return TRACKBAR_Paint (infoPtr
, (HDC
)wParam
);
2036 return TRACKBAR_SetFocus (infoPtr
);
2039 return TRACKBAR_Size (infoPtr
);
2041 case WM_STYLECHANGED
:
2042 return TRACKBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
2044 case WM_THEMECHANGED
:
2045 return theme_changed (infoPtr
);
2048 return TRACKBAR_Timer (infoPtr
);
2050 case WM_WININICHANGE
:
2051 return TRACKBAR_InitializeThumb (infoPtr
);
2054 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
2055 ERR("unknown msg %04x wp=%08lx lp=%08lx\n", uMsg
, wParam
, lParam
);
2056 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2061 void TRACKBAR_Register (void)
2065 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
2066 wndClass
.style
= CS_GLOBALCLASS
;
2067 wndClass
.lpfnWndProc
= TRACKBAR_WindowProc
;
2068 wndClass
.cbClsExtra
= 0;
2069 wndClass
.cbWndExtra
= sizeof(TRACKBAR_INFO
*);
2070 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
2071 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
2072 wndClass
.lpszClassName
= TRACKBAR_CLASSW
;
2074 RegisterClassW (&wndClass
);
2078 void TRACKBAR_Unregister (void)
2080 UnregisterClassW (TRACKBAR_CLASSW
, NULL
);