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
);
71 #define TB_REFRESH_TIMER 1
72 #define TB_REFRESH_DELAY 500
74 #define TOOLTIP_OFFSET 2 /* distance from ctrl edge to tooltip */
76 #define TB_DEFAULTPAGESIZE 20
78 /* Used by TRACKBAR_Refresh to find out which parts of the control
79 need to be recalculated */
81 #define TB_THUMBPOSCHANGED 1
82 #define TB_THUMBSIZECHANGED 2
83 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBSIZECHANGED)
84 #define TB_SELECTIONCHANGED 4
85 #define TB_DRAG_MODE 8 /* we're dragging the slider */
86 #define TB_AUTO_PAGE_LEFT 16
87 #define TB_AUTO_PAGE_RIGHT 32
88 #define TB_AUTO_PAGE (TB_AUTO_PAGE_LEFT | TB_AUTO_PAGE_RIGHT)
89 #define TB_THUMB_HOT 64 /* mouse hovers above thumb */
91 /* helper defines for TRACKBAR_DrawTic */
93 #define TIC_SELECTIONMARKMAX 0x80
94 #define TIC_SELECTIONMARKMIN 0x100
95 #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
97 static const WCHAR themeClass
[] = { 'T','r','a','c','k','b','a','r',0 };
100 notify_customdraw (const TRACKBAR_INFO
*infoPtr
, NMCUSTOMDRAW
*pnmcd
, int stage
)
102 pnmcd
->dwDrawStage
= stage
;
103 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
104 pnmcd
->hdr
.idFrom
, (LPARAM
)pnmcd
);
107 static LRESULT
notify_hdr (const TRACKBAR_INFO
*infoPtr
, INT code
, LPNMHDR pnmh
)
111 TRACE("(code=%d)\n", code
);
113 pnmh
->hwndFrom
= infoPtr
->hwndSelf
;
114 pnmh
->idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
116 result
= SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, pnmh
->idFrom
, (LPARAM
)pnmh
);
118 TRACE(" <= %ld\n", result
);
123 static inline int notify (const TRACKBAR_INFO
*infoPtr
, INT code
)
126 return notify_hdr(infoPtr
, code
, &nmh
);
129 static void notify_with_scroll (const TRACKBAR_INFO
*infoPtr
, UINT code
)
131 UINT scroll
= infoPtr
->dwStyle
& TBS_VERT
? WM_VSCROLL
: WM_HSCROLL
;
135 SendMessageW (infoPtr
->hwndNotify
, scroll
, code
, (LPARAM
)infoPtr
->hwndSelf
);
138 static void TRACKBAR_RecalculateTics (TRACKBAR_INFO
*infoPtr
)
143 if (infoPtr
->uTicFreq
&& infoPtr
->lRangeMax
>= infoPtr
->lRangeMin
) {
144 nrTics
=(infoPtr
->lRangeMax
- infoPtr
->lRangeMin
)/infoPtr
->uTicFreq
;
145 /* don't add extra tic if there's no remainder */
146 if (nrTics
&& ((infoPtr
->lRangeMax
- infoPtr
->lRangeMin
) % infoPtr
->uTicFreq
== 0))
150 Free (infoPtr
->tics
);
151 infoPtr
->tics
= NULL
;
152 infoPtr
->uNumTics
= 0;
156 if (nrTics
!= infoPtr
->uNumTics
) {
157 infoPtr
->tics
=ReAlloc (infoPtr
->tics
,
158 (nrTics
+1)*sizeof (DWORD
));
159 if (!infoPtr
->tics
) {
160 infoPtr
->uNumTics
= 0;
161 notify(infoPtr
, NM_OUTOFMEMORY
);
164 infoPtr
->uNumTics
= nrTics
;
167 tic
= infoPtr
->lRangeMin
+ infoPtr
->uTicFreq
;
168 for (i
= 0; i
< nrTics
; i
++, tic
+= infoPtr
->uTicFreq
)
169 infoPtr
->tics
[i
] = tic
;
172 /* converts from physical (mouse) position to logical position
173 (in range of trackbar) */
176 TRACKBAR_ConvertPlaceToPosition (const TRACKBAR_INFO
*infoPtr
, int place
)
178 double range
, width
, pos
, offsetthumb
;
180 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
181 if (infoPtr
->dwStyle
& TBS_VERT
) {
182 offsetthumb
= (infoPtr
->rcThumb
.bottom
- infoPtr
->rcThumb
.top
)/2;
183 width
= infoPtr
->rcChannel
.bottom
- infoPtr
->rcChannel
.top
- (offsetthumb
* 2) - 1;
184 pos
= (range
*(place
- infoPtr
->rcChannel
.top
- offsetthumb
)) / width
;
186 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
187 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- (offsetthumb
* 2) - 1;
188 pos
= (range
*(place
- infoPtr
->rcChannel
.left
- offsetthumb
)) / width
;
190 pos
+= infoPtr
->lRangeMin
;
191 if (pos
> infoPtr
->lRangeMax
)
192 pos
= infoPtr
->lRangeMax
;
193 else if (pos
< infoPtr
->lRangeMin
)
194 pos
= infoPtr
->lRangeMin
;
196 TRACE("%.2f\n", pos
);
197 return (LONG
)floor(pos
+ 0.5);
201 /* return: 0> prev, 0 none, >0 next */
203 TRACKBAR_GetAutoPageDirection (const TRACKBAR_INFO
*infoPtr
, POINT clickPoint
)
207 if (infoPtr
->dwStyle
& TBS_VERT
) {
208 pageRect
.top
= infoPtr
->rcChannel
.top
;
209 pageRect
.bottom
= infoPtr
->rcChannel
.bottom
;
210 pageRect
.left
= infoPtr
->rcThumb
.left
;
211 pageRect
.right
= infoPtr
->rcThumb
.right
;
213 pageRect
.top
= infoPtr
->rcThumb
.top
;
214 pageRect
.bottom
= infoPtr
->rcThumb
.bottom
;
215 pageRect
.left
= infoPtr
->rcChannel
.left
;
216 pageRect
.right
= infoPtr
->rcChannel
.right
;
220 if (PtInRect(&pageRect
, clickPoint
))
222 int clickPlace
= (infoPtr
->dwStyle
& TBS_VERT
) ? clickPoint
.y
: clickPoint
.x
;
224 LONG clickPos
= TRACKBAR_ConvertPlaceToPosition(infoPtr
, clickPlace
);
226 return clickPos
- infoPtr
->lPos
;
233 TRACKBAR_PageDown (TRACKBAR_INFO
*infoPtr
)
235 if (infoPtr
->lPos
== infoPtr
->lRangeMax
) return;
237 infoPtr
->lPos
+= infoPtr
->lPageSize
;
238 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
239 infoPtr
->lPos
= infoPtr
->lRangeMax
;
240 notify_with_scroll (infoPtr
, TB_PAGEDOWN
);
245 TRACKBAR_PageUp (TRACKBAR_INFO
*infoPtr
)
247 if (infoPtr
->lPos
== infoPtr
->lRangeMin
) return;
249 infoPtr
->lPos
-= infoPtr
->lPageSize
;
250 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
251 infoPtr
->lPos
= infoPtr
->lRangeMin
;
252 notify_with_scroll (infoPtr
, TB_PAGEUP
);
255 static inline void TRACKBAR_LineUp(TRACKBAR_INFO
*infoPtr
)
257 if (infoPtr
->lPos
== infoPtr
->lRangeMin
) return;
258 infoPtr
->lPos
-= infoPtr
->lLineSize
;
259 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
260 infoPtr
->lPos
= infoPtr
->lRangeMin
;
261 notify_with_scroll (infoPtr
, TB_LINEUP
);
264 static inline void TRACKBAR_LineDown(TRACKBAR_INFO
*infoPtr
)
266 if (infoPtr
->lPos
== infoPtr
->lRangeMax
) return;
267 infoPtr
->lPos
+= infoPtr
->lLineSize
;
268 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
269 infoPtr
->lPos
= infoPtr
->lRangeMax
;
270 notify_with_scroll (infoPtr
, TB_LINEDOWN
);
274 TRACKBAR_CalcChannel (TRACKBAR_INFO
*infoPtr
)
276 INT cyChannel
, offsetthumb
, offsetedge
;
277 RECT lpRect
, *channel
= & infoPtr
->rcChannel
;
279 GetClientRect (infoPtr
->hwndSelf
, &lpRect
);
281 offsetthumb
= infoPtr
->uThumbLen
/ 4;
282 offsetedge
= offsetthumb
+ 3;
283 cyChannel
= (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) ? offsetthumb
*3 : 4;
284 if (infoPtr
->dwStyle
& TBS_VERT
) {
285 channel
->top
= lpRect
.top
+ offsetedge
;
286 channel
->bottom
= lpRect
.bottom
- offsetedge
;
287 if (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)
288 channel
->left
= lpRect
.left
+ ((infoPtr
->uThumbLen
- cyChannel
+ 2) / 2);
290 channel
->left
= lpRect
.left
+ (infoPtr
->uThumbLen
/ 2) - 1;
291 if (infoPtr
->dwStyle
& TBS_BOTH
) {
292 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
297 else if (infoPtr
->dwStyle
& TBS_TOP
) {
298 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
303 channel
->right
= channel
->left
+ cyChannel
;
305 channel
->left
= lpRect
.left
+ offsetedge
;
306 channel
->right
= lpRect
.right
- offsetedge
;
307 if (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)
308 channel
->top
= lpRect
.top
+ ((infoPtr
->uThumbLen
- cyChannel
+ 2) / 2);
310 channel
->top
= lpRect
.top
+ (infoPtr
->uThumbLen
/ 2) - 1;
311 if (infoPtr
->dwStyle
& TBS_BOTH
) {
312 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
317 else if (infoPtr
->dwStyle
& TBS_TOP
) {
318 if (infoPtr
->dwStyle
& TBS_NOTICKS
)
323 channel
->bottom
= channel
->top
+ cyChannel
;
328 TRACKBAR_CalcThumb (const TRACKBAR_INFO
*infoPtr
, LONG lPos
, RECT
*thumb
)
330 int range
, width
, height
, thumbwidth
;
333 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
334 thumbwidth
= (infoPtr
->uThumbLen
/ 2) | 1;
336 if (!range
) range
= 1;
338 GetClientRect(infoPtr
->hwndSelf
, &lpRect
);
339 if (infoPtr
->dwStyle
& TBS_VERT
)
341 height
= infoPtr
->rcChannel
.bottom
- infoPtr
->rcChannel
.top
- thumbwidth
;
343 if ((infoPtr
->dwStyle
& (TBS_BOTH
| TBS_LEFT
)) && !(infoPtr
->dwStyle
& TBS_NOTICKS
))
347 thumb
->right
= thumb
->left
+ infoPtr
->uThumbLen
;
348 thumb
->top
= infoPtr
->rcChannel
.top
+
349 (height
*(lPos
- infoPtr
->lRangeMin
))/range
;
350 thumb
->bottom
= thumb
->top
+ thumbwidth
;
354 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- thumbwidth
;
356 thumb
->left
= infoPtr
->rcChannel
.left
+
357 (width
*(lPos
- infoPtr
->lRangeMin
))/range
;
358 thumb
->right
= thumb
->left
+ thumbwidth
;
359 if ((infoPtr
->dwStyle
& (TBS_BOTH
| TBS_TOP
)) && !(infoPtr
->dwStyle
& TBS_NOTICKS
))
363 thumb
->bottom
= thumb
->top
+ infoPtr
->uThumbLen
;
368 TRACKBAR_UpdateThumb (TRACKBAR_INFO
*infoPtr
)
370 TRACKBAR_CalcThumb(infoPtr
, infoPtr
->lPos
, &infoPtr
->rcThumb
);
374 TRACKBAR_InvalidateAll (const TRACKBAR_INFO
*infoPtr
)
376 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
380 TRACKBAR_InvalidateThumb (const TRACKBAR_INFO
*infoPtr
, LONG thumbPos
)
384 TRACKBAR_CalcThumb(infoPtr
, thumbPos
, &rcThumb
);
385 InflateRect(&rcThumb
, 1, 1);
386 InvalidateRect(infoPtr
->hwndSelf
, &rcThumb
, FALSE
);
390 TRACKBAR_InvalidateThumbMove (const TRACKBAR_INFO
*infoPtr
, LONG oldPos
, LONG newPos
)
392 TRACKBAR_InvalidateThumb (infoPtr
, oldPos
);
393 if (newPos
!= oldPos
)
394 TRACKBAR_InvalidateThumb (infoPtr
, newPos
);
398 TRACKBAR_HasSelection (const TRACKBAR_INFO
*infoPtr
)
400 return infoPtr
->lSelMin
!= infoPtr
->lSelMax
;
404 TRACKBAR_CalcSelection (TRACKBAR_INFO
*infoPtr
)
406 RECT
*selection
= &infoPtr
->rcSelection
;
407 int range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
408 int offsetthumb
, height
, width
;
411 SetRectEmpty (selection
);
413 if (infoPtr
->dwStyle
& TBS_VERT
) {
414 offsetthumb
= (infoPtr
->rcThumb
.bottom
- infoPtr
->rcThumb
.top
)/2;
415 height
= infoPtr
->rcChannel
.bottom
- infoPtr
->rcChannel
.top
- offsetthumb
*2;
416 selection
->top
= infoPtr
->rcChannel
.top
+ offsetthumb
+
417 (height
*infoPtr
->lSelMin
)/range
;
418 selection
->bottom
= infoPtr
->rcChannel
.top
+ offsetthumb
+
419 (height
*infoPtr
->lSelMax
)/range
;
420 selection
->left
= infoPtr
->rcChannel
.left
+ 3;
421 selection
->right
= infoPtr
->rcChannel
.right
- 3;
423 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
424 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- offsetthumb
*2;
425 selection
->left
= infoPtr
->rcChannel
.left
+ offsetthumb
+
426 (width
*infoPtr
->lSelMin
)/range
;
427 selection
->right
= infoPtr
->rcChannel
.left
+ offsetthumb
+
428 (width
*infoPtr
->lSelMax
)/range
;
429 selection
->top
= infoPtr
->rcChannel
.top
+ 3;
430 selection
->bottom
= infoPtr
->rcChannel
.bottom
- 3;
434 TRACE("selection[%s]\n", wine_dbgstr_rect(selection
));
438 TRACKBAR_AutoPage (TRACKBAR_INFO
*infoPtr
, POINT clickPoint
)
440 LONG dir
= TRACKBAR_GetAutoPageDirection(infoPtr
, clickPoint
);
441 LONG prevPos
= infoPtr
->lPos
;
443 TRACE("clickPoint=%s, dir=%d\n", wine_dbgstr_point(&clickPoint
), dir
);
445 if (dir
> 0 && (infoPtr
->flags
& TB_AUTO_PAGE_RIGHT
))
446 TRACKBAR_PageDown(infoPtr
);
447 else if (dir
< 0 && (infoPtr
->flags
& TB_AUTO_PAGE_LEFT
))
448 TRACKBAR_PageUp(infoPtr
);
451 TRACKBAR_UpdateThumb (infoPtr
);
452 TRACKBAR_InvalidateThumbMove (infoPtr
, prevPos
, infoPtr
->lPos
);
457 /* Trackbar drawing code. I like my spaghetti done milanese. */
460 TRACKBAR_DrawChannel (const TRACKBAR_INFO
*infoPtr
, HDC hdc
)
462 RECT rcChannel
= infoPtr
->rcChannel
;
463 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
467 DrawThemeBackground (theme
, hdc
,
468 (infoPtr
->dwStyle
& TBS_VERT
) ?
469 TKP_TRACKVERT
: TKP_TRACK
, TKS_NORMAL
, &rcChannel
, 0);
473 DrawEdge (hdc
, &rcChannel
, EDGE_SUNKEN
, BF_RECT
| BF_ADJUST
);
474 if (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) { /* fill the channel */
475 FillRect (hdc
, &rcChannel
, GetStockObject(WHITE_BRUSH
));
476 if (TRACKBAR_HasSelection(infoPtr
))
477 FillRect (hdc
, &infoPtr
->rcSelection
, GetSysColorBrush(COLOR_HIGHLIGHT
));
483 TRACKBAR_DrawOneTic (const TRACKBAR_INFO
*infoPtr
, HDC hdc
, LONG ticPos
, int flags
)
485 int x
, y
, ox
, oy
, range
, side
, indent
= 0, len
= 3;
489 if (flags
& TBS_VERT
) {
490 offsetthumb
= (infoPtr
->rcThumb
.bottom
- infoPtr
->rcThumb
.top
)/2;
491 SetRect(&rcTics
, infoPtr
->rcThumb
.left
- 2, infoPtr
->rcChannel
.top
+ offsetthumb
,
492 infoPtr
->rcThumb
.right
+ 2, infoPtr
->rcChannel
.bottom
- offsetthumb
- 1);
494 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
495 SetRect(&rcTics
, infoPtr
->rcChannel
.left
+ offsetthumb
, infoPtr
->rcThumb
.top
- 2,
496 infoPtr
->rcChannel
.right
- offsetthumb
- 1, infoPtr
->rcThumb
.bottom
+ 2);
499 if (flags
& (TBS_TOP
| TBS_LEFT
)) {
509 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
511 range
= 1; /* to avoid division by zero */
513 if (flags
& TIC_SELECTIONMARK
) {
514 indent
= (flags
& TIC_SELECTIONMARKMIN
) ? -1 : 1;
515 } else if (flags
& TIC_EDGE
) {
519 if (flags
& TBS_VERT
) {
520 int height
= rcTics
.bottom
- rcTics
.top
;
521 y
= rcTics
.top
+ (height
*(ticPos
- infoPtr
->lRangeMin
))/range
;
523 int width
= rcTics
.right
- rcTics
.left
;
524 x
= rcTics
.left
+ (width
*(ticPos
- infoPtr
->lRangeMin
))/range
;
529 MoveToEx(hdc
, x
, y
, 0);
530 if (flags
& TBS_VERT
) x
+= len
* side
;
531 else y
+= len
* side
;
534 if (flags
& TIC_SELECTIONMARK
) {
535 if (flags
& TBS_VERT
) {
540 MoveToEx(hdc
, x
, y
, 0);
541 if (flags
& TBS_VERT
) {
554 TRACKBAR_DrawTic (const TRACKBAR_INFO
*infoPtr
, HDC hdc
, LONG ticPos
, int flags
)
556 if ((flags
& (TBS_LEFT
| TBS_TOP
)) || (flags
& TBS_BOTH
))
557 TRACKBAR_DrawOneTic (infoPtr
, hdc
, ticPos
, flags
| TBS_LEFT
);
559 if (!(flags
& (TBS_LEFT
| TBS_TOP
)) || (flags
& TBS_BOTH
))
560 TRACKBAR_DrawOneTic (infoPtr
, hdc
, ticPos
, flags
& ~TBS_LEFT
);
564 TRACKBAR_DrawTics (const TRACKBAR_INFO
*infoPtr
, HDC hdc
)
567 int ticFlags
= infoPtr
->dwStyle
& 0x0f;
568 LOGPEN ticPen
= { PS_SOLID
, {1, 0}, GetSysColor (COLOR_3DDKSHADOW
) };
569 HPEN hOldPen
, hTicPen
;
570 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
574 int part
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_TICSVERT
: TKP_TICS
;
575 GetThemeColor (theme
, part
, TSS_NORMAL
, TMT_COLOR
, &ticPen
.lopnColor
);
577 /* create the pen to draw the tics with */
578 hTicPen
= CreatePenIndirect(&ticPen
);
579 hOldPen
= hTicPen
? SelectObject(hdc
, hTicPen
) : 0;
581 /* actually draw the tics */
582 for (i
=0; i
<infoPtr
->uNumTics
; i
++)
583 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->tics
[i
], ticFlags
);
585 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lRangeMin
, ticFlags
| TIC_EDGE
);
586 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lRangeMax
, ticFlags
| TIC_EDGE
);
588 if ((infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) && TRACKBAR_HasSelection(infoPtr
)) {
589 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lSelMin
,
590 ticFlags
| TIC_SELECTIONMARKMIN
);
591 TRACKBAR_DrawTic (infoPtr
, hdc
, infoPtr
->lSelMax
,
592 ticFlags
| TIC_SELECTIONMARKMAX
);
595 /* clean up the pen, if we created one */
597 SelectObject(hdc
, hOldPen
);
598 DeleteObject(hTicPen
);
603 TRACKBAR_FillThumb (const TRACKBAR_INFO
*infoPtr
, HDC hdc
, HBRUSH hbrush
)
605 const RECT
*thumb
= &infoPtr
->rcThumb
;
610 if (infoPtr
->dwStyle
& TBS_BOTH
)
612 FillRect(hdc
, thumb
, hbrush
);
616 if (infoPtr
->dwStyle
& TBS_VERT
)
618 PointDepth
= (thumb
->bottom
- thumb
->top
) / 2;
619 if (infoPtr
->dwStyle
& TBS_LEFT
)
621 points
[0].x
= thumb
->right
-1;
622 points
[0].y
= thumb
->top
;
623 points
[1].x
= thumb
->right
-1;
624 points
[1].y
= thumb
->bottom
-1;
625 points
[2].x
= thumb
->left
+ PointDepth
;
626 points
[2].y
= thumb
->bottom
-1;
627 points
[3].x
= thumb
->left
;
628 points
[3].y
= thumb
->top
+ PointDepth
;
629 points
[4].x
= thumb
->left
+ PointDepth
;
630 points
[4].y
= thumb
->top
;
631 points
[5].x
= points
[0].x
;
632 points
[5].y
= points
[0].y
;
636 points
[0].x
= thumb
->right
;
637 points
[0].y
= thumb
->top
+ PointDepth
;
638 points
[1].x
= thumb
->right
- PointDepth
;
639 points
[1].y
= thumb
->bottom
-1;
640 points
[2].x
= thumb
->left
;
641 points
[2].y
= thumb
->bottom
-1;
642 points
[3].x
= thumb
->left
;
643 points
[3].y
= thumb
->top
;
644 points
[4].x
= thumb
->right
- PointDepth
;
645 points
[4].y
= thumb
->top
;
646 points
[5].x
= points
[0].x
;
647 points
[5].y
= points
[0].y
;
652 PointDepth
= (thumb
->right
- thumb
->left
) / 2;
653 if (infoPtr
->dwStyle
& TBS_TOP
)
655 points
[0].x
= thumb
->left
+ PointDepth
;
656 points
[0].y
= thumb
->top
+1;
657 points
[1].x
= thumb
->right
-1;
658 points
[1].y
= thumb
->top
+ PointDepth
+ 1;
659 points
[2].x
= thumb
->right
-1;
660 points
[2].y
= thumb
->bottom
-1;
661 points
[3].x
= thumb
->left
;
662 points
[3].y
= thumb
->bottom
-1;
663 points
[4].x
= thumb
->left
;
664 points
[4].y
= thumb
->top
+ PointDepth
+ 1;
665 points
[5].x
= points
[0].x
;
666 points
[5].y
= points
[0].y
;
670 points
[0].x
= thumb
->right
-1;
671 points
[0].y
= thumb
->top
;
672 points
[1].x
= thumb
->right
-1;
673 points
[1].y
= thumb
->bottom
- PointDepth
- 1;
674 points
[2].x
= thumb
->left
+ PointDepth
;
675 points
[2].y
= thumb
->bottom
-1;
676 points
[3].x
= thumb
->left
;
677 points
[3].y
= thumb
->bottom
- PointDepth
- 1;
678 points
[4].x
= thumb
->left
;
679 points
[4].y
= thumb
->top
;
680 points
[5].x
= points
[0].x
;
681 points
[5].y
= points
[0].y
;
685 oldbr
= SelectObject(hdc
, hbrush
);
686 SetPolyFillMode(hdc
, WINDING
);
687 Polygon(hdc
, points
, sizeof(points
) / sizeof(points
[0]));
688 SelectObject(hdc
, oldbr
);
694 TRACKBAR_DrawThumb (TRACKBAR_INFO
*infoPtr
, HDC hdc
)
696 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
704 if (infoPtr
->dwStyle
& TBS_BOTH
)
705 partId
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_THUMBVERT
: TKP_THUMB
;
706 else if (infoPtr
->dwStyle
& TBS_LEFT
)
707 partId
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_THUMBLEFT
: TKP_THUMBTOP
;
709 partId
= (infoPtr
->dwStyle
& TBS_VERT
) ? TKP_THUMBRIGHT
: TKP_THUMBBOTTOM
;
711 if (infoPtr
->dwStyle
& WS_DISABLED
)
712 stateId
= TUS_DISABLED
;
713 else if (infoPtr
->flags
& TB_DRAG_MODE
)
714 stateId
= TUS_PRESSED
;
715 else if (infoPtr
->flags
& TB_THUMB_HOT
)
718 stateId
= TUS_NORMAL
;
720 DrawThemeBackground (theme
, hdc
, partId
, stateId
, &infoPtr
->rcThumb
, NULL
);
725 if (infoPtr
->dwStyle
& WS_DISABLED
|| infoPtr
->flags
& TB_DRAG_MODE
)
727 if (comctl32_color
.clr3dHilight
== comctl32_color
.clrWindow
)
728 brush
= COMCTL32_hPattern55AABrush
;
730 brush
= GetSysColorBrush(COLOR_SCROLLBAR
);
732 SetTextColor(hdc
, comctl32_color
.clr3dFace
);
733 SetBkColor(hdc
, comctl32_color
.clr3dHilight
);
736 brush
= GetSysColorBrush(COLOR_BTNFACE
);
738 PointDepth
= TRACKBAR_FillThumb(infoPtr
, hdc
, brush
);
740 if (infoPtr
->dwStyle
& TBS_BOTH
)
742 DrawEdge(hdc
, &infoPtr
->rcThumb
, EDGE_RAISED
, BF_RECT
| BF_SOFT
);
747 RECT thumb
= infoPtr
->rcThumb
;
749 if (infoPtr
->dwStyle
& TBS_VERT
)
751 if (infoPtr
->dwStyle
& TBS_LEFT
)
753 /* rectangular part */
754 thumb
.left
+= PointDepth
;
755 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_TOP
| BF_RIGHT
| BF_BOTTOM
| BF_SOFT
);
758 thumb
.left
-= PointDepth
;
759 thumb
.right
= thumb
.left
+ PointDepth
;
760 thumb
.bottom
= infoPtr
->rcThumb
.top
+ PointDepth
+ 1;
761 thumb
.top
= infoPtr
->rcThumb
.top
;
762 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPRIGHT
| BF_SOFT
);
765 thumb
.top
+= PointDepth
;
766 thumb
.bottom
+= PointDepth
;
767 DrawEdge(hdc
, &thumb
, EDGE_SUNKEN
, BF_DIAGONAL_ENDTOPLEFT
| BF_SOFT
);
772 /* rectangular part */
773 thumb
.right
-= PointDepth
;
774 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_TOP
| BF_LEFT
| BF_BOTTOM
| BF_SOFT
);
777 thumb
.left
= thumb
.right
;
778 thumb
.right
+= PointDepth
+ 1;
779 thumb
.bottom
= infoPtr
->rcThumb
.top
+ PointDepth
+ 1;
780 thumb
.top
= infoPtr
->rcThumb
.top
;
781 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPLEFT
| BF_SOFT
);
784 thumb
.top
+= PointDepth
;
785 thumb
.bottom
+= PointDepth
;
786 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDBOTTOMLEFT
| BF_SOFT
);
791 if (infoPtr
->dwStyle
& TBS_TOP
)
793 /* rectangular part */
794 thumb
.top
+= PointDepth
;
795 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_LEFT
| BF_BOTTOM
| BF_RIGHT
| BF_SOFT
);
798 thumb
.left
= infoPtr
->rcThumb
.left
;
799 thumb
.right
= thumb
.left
+ PointDepth
;
800 thumb
.bottom
= infoPtr
->rcThumb
.top
+ PointDepth
+ 1;
801 thumb
.top
-= PointDepth
;
802 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPRIGHT
| BF_SOFT
);
805 thumb
.left
+= PointDepth
;
806 thumb
.right
+= PointDepth
;
807 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDBOTTOMRIGHT
| BF_SOFT
);
811 /* rectangular part */
812 thumb
.bottom
-= PointDepth
;
813 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_LEFT
| BF_TOP
| BF_RIGHT
| BF_SOFT
);
816 thumb
.left
= infoPtr
->rcThumb
.left
;
817 thumb
.right
= thumb
.left
+ PointDepth
;
818 thumb
.top
= infoPtr
->rcThumb
.bottom
- PointDepth
- 1;
819 thumb
.bottom
+= PointDepth
;
820 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDTOPLEFT
| BF_SOFT
);
823 thumb
.left
+= PointDepth
;
824 thumb
.right
+= PointDepth
;
825 DrawEdge(hdc
, &thumb
, EDGE_RAISED
, BF_DIAGONAL_ENDBOTTOMLEFT
| BF_SOFT
);
833 TRACKBAR_ActivateToolTip (const TRACKBAR_INFO
*infoPtr
, BOOL fShow
)
837 if (!infoPtr
->hwndToolTip
) return;
839 ZeroMemory(&ti
, sizeof(ti
));
840 ti
.cbSize
= sizeof(ti
);
841 ti
.hwnd
= infoPtr
->hwndSelf
;
843 SendMessageW (infoPtr
->hwndToolTip
, TTM_TRACKACTIVATE
, fShow
, (LPARAM
)&ti
);
848 TRACKBAR_UpdateToolTip (const TRACKBAR_INFO
*infoPtr
)
851 static const WCHAR fmt
[] = { '%', 'l', 'd', 0 };
857 if (!infoPtr
->hwndToolTip
) return;
859 ZeroMemory(&ti
, sizeof(ti
));
860 ti
.cbSize
= sizeof(ti
);
861 ti
.hwnd
= infoPtr
->hwndSelf
;
862 ti
.uFlags
= TTF_IDISHWND
| TTF_TRACK
| TTF_ABSOLUTE
;
864 wsprintfW (buf
, fmt
, infoPtr
->lPos
);
866 SendMessageW (infoPtr
->hwndToolTip
, TTM_UPDATETIPTEXTW
, 0, (LPARAM
)&ti
);
868 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
869 size
= SendMessageW (infoPtr
->hwndToolTip
, TTM_GETBUBBLESIZE
, 0, (LPARAM
)&ti
);
870 if (infoPtr
->dwStyle
& TBS_VERT
) {
871 if (infoPtr
->fLocation
== TBTS_LEFT
)
872 pt
.x
= 0 - LOWORD(size
) - TOOLTIP_OFFSET
;
874 pt
.x
= rcClient
.right
+ TOOLTIP_OFFSET
;
875 pt
.y
= (infoPtr
->rcThumb
.top
+ infoPtr
->rcThumb
.bottom
- HIWORD(size
))/2;
877 if (infoPtr
->fLocation
== TBTS_TOP
)
878 pt
.y
= 0 - HIWORD(size
) - TOOLTIP_OFFSET
;
880 pt
.y
= rcClient
.bottom
+ TOOLTIP_OFFSET
;
881 pt
.x
= (infoPtr
->rcThumb
.left
+ infoPtr
->rcThumb
.right
- LOWORD(size
))/2;
883 ClientToScreen(infoPtr
->hwndSelf
, &pt
);
885 SendMessageW (infoPtr
->hwndToolTip
, TTM_TRACKPOSITION
,
886 0, MAKELPARAM(pt
.x
, pt
.y
));
891 TRACKBAR_Refresh (TRACKBAR_INFO
*infoPtr
, HDC hdcDst
)
895 HBITMAP hOldBmp
= 0, hOffScreenBmp
= 0;
899 if (infoPtr
->flags
& TB_THUMBCHANGED
) {
900 TRACKBAR_UpdateThumb (infoPtr
);
901 if (infoPtr
->flags
& TB_THUMBSIZECHANGED
)
902 TRACKBAR_CalcChannel (infoPtr
);
904 if (infoPtr
->flags
& TB_SELECTIONCHANGED
)
905 TRACKBAR_CalcSelection (infoPtr
);
907 if (infoPtr
->flags
& TB_DRAG_MODE
)
908 TRACKBAR_UpdateToolTip (infoPtr
);
910 infoPtr
->flags
&= ~ (TB_THUMBCHANGED
| TB_SELECTIONCHANGED
);
912 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
914 /* try to render offscreen, if we fail, carrry onscreen */
915 hdc
= CreateCompatibleDC(hdcDst
);
917 hOffScreenBmp
= CreateCompatibleBitmap(hdcDst
, rcClient
.right
, rcClient
.bottom
);
919 hOldBmp
= SelectObject(hdc
, hOffScreenBmp
);
928 ZeroMemory(&nmcd
, sizeof(nmcd
));
929 nmcd
.hdr
.hwndFrom
= infoPtr
->hwndSelf
;
930 nmcd
.hdr
.idFrom
= GetWindowLongPtrW (infoPtr
->hwndSelf
, GWLP_ID
);
931 nmcd
.hdr
.code
= NM_CUSTOMDRAW
;
934 /* start the paint cycle */
936 gcdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_PREPAINT
);
937 if (gcdrf
& CDRF_SKIPDEFAULT
) goto cleanup
;
939 /* Erase background */
940 if (gcdrf
== CDRF_DODEFAULT
||
941 notify_customdraw(infoPtr
, &nmcd
, CDDS_PREERASE
) != CDRF_SKIPDEFAULT
) {
942 if (GetWindowTheme (infoPtr
->hwndSelf
)) {
943 DrawThemeParentBackground (infoPtr
->hwndSelf
, hdc
, 0);
946 HBRUSH brush
= (HBRUSH
)SendMessageW(infoPtr
->hwndNotify
, WM_CTLCOLORSTATIC
,
947 (WPARAM
)hdc
, (LPARAM
)infoPtr
->hwndSelf
);
948 FillRect (hdc
, &rcClient
, brush
? brush
: GetSysColorBrush(COLOR_BTNFACE
));
950 if (gcdrf
!= CDRF_DODEFAULT
)
951 notify_customdraw(infoPtr
, &nmcd
, CDDS_POSTERASE
);
955 if (gcdrf
& CDRF_NOTIFYITEMDRAW
) {
956 nmcd
.dwItemSpec
= TBCD_CHANNEL
;
957 nmcd
.uItemState
= CDIS_DEFAULT
;
958 nmcd
.rc
= infoPtr
->rcChannel
;
959 icdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPREPAINT
);
960 } else icdrf
= CDRF_DODEFAULT
;
961 if ( !(icdrf
& CDRF_SKIPDEFAULT
) ) {
962 TRACKBAR_DrawChannel (infoPtr
, hdc
);
963 if (icdrf
& CDRF_NOTIFYPOSTPAINT
)
964 notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPOSTPAINT
);
969 if (!(infoPtr
->dwStyle
& TBS_NOTICKS
)) {
970 if (gcdrf
& CDRF_NOTIFYITEMDRAW
) {
971 nmcd
.dwItemSpec
= TBCD_TICS
;
972 nmcd
.uItemState
= CDIS_DEFAULT
;
974 icdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPREPAINT
);
975 } else icdrf
= CDRF_DODEFAULT
;
976 if ( !(icdrf
& CDRF_SKIPDEFAULT
) ) {
977 TRACKBAR_DrawTics (infoPtr
, hdc
);
978 if (icdrf
& CDRF_NOTIFYPOSTPAINT
)
979 notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPOSTPAINT
);
984 if (!(infoPtr
->dwStyle
& TBS_NOTHUMB
)) {
985 if (gcdrf
& CDRF_NOTIFYITEMDRAW
) {
986 nmcd
.dwItemSpec
= TBCD_THUMB
;
987 nmcd
.uItemState
= infoPtr
->flags
& TB_DRAG_MODE
? CDIS_HOT
: CDIS_DEFAULT
;
988 nmcd
.rc
= infoPtr
->rcThumb
;
989 icdrf
= notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPREPAINT
);
990 } else icdrf
= CDRF_DODEFAULT
;
991 if ( !(icdrf
& CDRF_SKIPDEFAULT
) ) {
992 TRACKBAR_DrawThumb(infoPtr
, hdc
);
993 if (icdrf
& CDRF_NOTIFYPOSTPAINT
)
994 notify_customdraw(infoPtr
, &nmcd
, CDDS_ITEMPOSTPAINT
);
998 /* draw focus rectangle */
999 if (infoPtr
->bFocussed
) {
1000 DrawFocusRect(hdc
, &rcClient
);
1003 /* finish up the painting */
1004 if (gcdrf
& CDRF_NOTIFYPOSTPAINT
)
1005 notify_customdraw(infoPtr
, &nmcd
, CDDS_POSTPAINT
);
1008 /* cleanup, if we rendered offscreen */
1009 if (hdc
!= hdcDst
) {
1010 BitBlt(hdcDst
, 0, 0, rcClient
.right
, rcClient
.bottom
, hdc
, 0, 0, SRCCOPY
);
1011 SelectObject(hdc
, hOldBmp
);
1012 DeleteObject(hOffScreenBmp
);
1019 TRACKBAR_AlignBuddies (const TRACKBAR_INFO
*infoPtr
)
1021 HWND hwndParent
= GetParent (infoPtr
->hwndSelf
);
1022 RECT rcSelf
, rcBuddy
;
1025 GetWindowRect (infoPtr
->hwndSelf
, &rcSelf
);
1026 MapWindowPoints (HWND_DESKTOP
, hwndParent
, (LPPOINT
)&rcSelf
, 2);
1028 /* align buddy left or above */
1029 if (infoPtr
->hwndBuddyLA
) {
1030 GetWindowRect (infoPtr
->hwndBuddyLA
, &rcBuddy
);
1031 MapWindowPoints (HWND_DESKTOP
, hwndParent
, (LPPOINT
)&rcBuddy
, 2);
1033 if (infoPtr
->dwStyle
& TBS_VERT
) {
1034 x
= (infoPtr
->rcChannel
.right
+ infoPtr
->rcChannel
.left
) / 2 -
1035 (rcBuddy
.right
- rcBuddy
.left
) / 2 + rcSelf
.left
;
1036 y
= rcSelf
.top
- (rcBuddy
.bottom
- rcBuddy
.top
);
1039 x
= rcSelf
.left
- (rcBuddy
.right
- rcBuddy
.left
);
1040 y
= (infoPtr
->rcChannel
.bottom
+ infoPtr
->rcChannel
.top
) / 2 -
1041 (rcBuddy
.bottom
- rcBuddy
.top
) / 2 + rcSelf
.top
;
1044 SetWindowPos (infoPtr
->hwndBuddyLA
, 0, x
, y
, 0, 0,
1045 SWP_NOZORDER
| SWP_NOSIZE
);
1049 /* align buddy right or below */
1050 if (infoPtr
->hwndBuddyRB
) {
1051 GetWindowRect (infoPtr
->hwndBuddyRB
, &rcBuddy
);
1052 MapWindowPoints (HWND_DESKTOP
, hwndParent
, (LPPOINT
)&rcBuddy
, 2);
1054 if (infoPtr
->dwStyle
& TBS_VERT
) {
1055 x
= (infoPtr
->rcChannel
.right
+ infoPtr
->rcChannel
.left
) / 2 -
1056 (rcBuddy
.right
- rcBuddy
.left
) / 2 + rcSelf
.left
;
1061 y
= (infoPtr
->rcChannel
.bottom
+ infoPtr
->rcChannel
.top
) / 2 -
1062 (rcBuddy
.bottom
- rcBuddy
.top
) / 2 + rcSelf
.top
;
1064 SetWindowPos (infoPtr
->hwndBuddyRB
, 0, x
, y
, 0, 0,
1065 SWP_NOZORDER
| SWP_NOSIZE
);
1071 TRACKBAR_ClearSel (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
)
1073 infoPtr
->lSelMin
= 0;
1074 infoPtr
->lSelMax
= 0;
1075 infoPtr
->flags
|= TB_SELECTIONCHANGED
;
1077 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1084 TRACKBAR_ClearTics (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
)
1086 if (infoPtr
->tics
) {
1087 Free (infoPtr
->tics
);
1088 infoPtr
->tics
= NULL
;
1089 infoPtr
->uNumTics
= 0;
1092 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1098 static inline LRESULT
1099 TRACKBAR_GetChannelRect (const TRACKBAR_INFO
*infoPtr
, LPRECT lprc
)
1101 if (lprc
== NULL
) return 0;
1103 lprc
->left
= infoPtr
->rcChannel
.left
;
1104 lprc
->right
= infoPtr
->rcChannel
.right
;
1105 lprc
->bottom
= infoPtr
->rcChannel
.bottom
;
1106 lprc
->top
= infoPtr
->rcChannel
.top
;
1113 TRACKBAR_GetNumTics (const TRACKBAR_INFO
*infoPtr
)
1115 if (infoPtr
->dwStyle
& TBS_NOTICKS
) return 0;
1117 return infoPtr
->uNumTics
+ 2;
1121 static int comp_tics (const void *ap
, const void *bp
)
1123 const DWORD a
= *(const DWORD
*)ap
;
1124 const DWORD b
= *(const DWORD
*)bp
;
1126 TRACE("(a=%d, b=%d)\n", a
, b
);
1127 if (a
< b
) return -1;
1128 if (a
> b
) return 1;
1134 TRACKBAR_GetTic (const TRACKBAR_INFO
*infoPtr
, INT iTic
)
1136 if ((iTic
< 0) || (iTic
>= infoPtr
->uNumTics
) || !infoPtr
->tics
)
1139 qsort(infoPtr
->tics
, infoPtr
->uNumTics
, sizeof(DWORD
), comp_tics
);
1140 return infoPtr
->tics
[iTic
];
1145 TRACKBAR_GetTicPos (const TRACKBAR_INFO
*infoPtr
, INT iTic
)
1147 LONG range
, width
, pos
, tic
;
1150 if ((iTic
< 0) || (iTic
>= infoPtr
->uNumTics
) || !infoPtr
->tics
)
1153 tic
= TRACKBAR_GetTic (infoPtr
, iTic
);
1154 range
= infoPtr
->lRangeMax
- infoPtr
->lRangeMin
;
1155 if (range
<= 0) range
= 1;
1156 offsetthumb
= (infoPtr
->rcThumb
.right
- infoPtr
->rcThumb
.left
)/2;
1157 width
= infoPtr
->rcChannel
.right
- infoPtr
->rcChannel
.left
- offsetthumb
*2;
1158 pos
= infoPtr
->rcChannel
.left
+ offsetthumb
+ (width
* tic
) / range
;
1165 TRACKBAR_SetBuddy (TRACKBAR_INFO
*infoPtr
, BOOL fLocation
, HWND hwndBuddy
)
1170 /* buddy is left or above */
1171 hwndTemp
= infoPtr
->hwndBuddyLA
;
1172 infoPtr
->hwndBuddyLA
= hwndBuddy
;
1175 /* buddy is right or below */
1176 hwndTemp
= infoPtr
->hwndBuddyRB
;
1177 infoPtr
->hwndBuddyRB
= hwndBuddy
;
1180 TRACKBAR_AlignBuddies (infoPtr
);
1187 TRACKBAR_SetLineSize (TRACKBAR_INFO
*infoPtr
, LONG lLineSize
)
1189 LONG lTemp
= infoPtr
->lLineSize
;
1191 infoPtr
->lLineSize
= lLineSize
;
1198 TRACKBAR_SetPageSize (TRACKBAR_INFO
*infoPtr
, LONG lPageSize
)
1200 LONG lTemp
= infoPtr
->lPageSize
;
1202 if (lPageSize
!= -1)
1203 infoPtr
->lPageSize
= lPageSize
;
1205 infoPtr
->lPageSize
= TB_DEFAULTPAGESIZE
;
1211 static inline LRESULT
1212 TRACKBAR_SetPos (TRACKBAR_INFO
*infoPtr
, BOOL fPosition
, LONG lPosition
)
1214 LONG oldPos
= infoPtr
->lPos
;
1215 infoPtr
->lPos
= lPosition
;
1217 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
1218 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1220 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
1221 infoPtr
->lPos
= infoPtr
->lRangeMax
;
1223 if (fPosition
&& oldPos
!= lPosition
)
1225 TRACKBAR_UpdateThumb(infoPtr
);
1226 TRACKBAR_InvalidateThumbMove(infoPtr
, oldPos
, lPosition
);
1233 static inline LRESULT
1234 TRACKBAR_SetRange (TRACKBAR_INFO
*infoPtr
, BOOL redraw
, LONG range
)
1236 BOOL changed
= infoPtr
->lRangeMin
!= (SHORT
)LOWORD(range
) ||
1237 infoPtr
->lRangeMax
!= (SHORT
)HIWORD(range
);
1239 infoPtr
->lRangeMin
= (SHORT
)LOWORD(range
);
1240 infoPtr
->lRangeMax
= (SHORT
)HIWORD(range
);
1242 /* clip position to new min/max limit */
1243 if (infoPtr
->lPos
< infoPtr
->lRangeMin
)
1244 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1246 if (infoPtr
->lPos
> infoPtr
->lRangeMax
)
1247 infoPtr
->lPos
= infoPtr
->lRangeMax
;
1249 infoPtr
->lPageSize
= (infoPtr
->lRangeMax
- infoPtr
->lRangeMin
) / 5;
1250 if (infoPtr
->lPageSize
== 0) infoPtr
->lPageSize
= 1;
1253 if (infoPtr
->dwStyle
& TBS_AUTOTICKS
)
1254 TRACKBAR_RecalculateTics (infoPtr
);
1255 infoPtr
->flags
|= TB_THUMBPOSCHANGED
;
1258 if (redraw
) TRACKBAR_InvalidateAll(infoPtr
);
1264 static inline LRESULT
1265 TRACKBAR_SetRangeMax (TRACKBAR_INFO
*infoPtr
, BOOL redraw
, LONG lMax
)
1267 BOOL changed
= infoPtr
->lRangeMax
!= lMax
;
1268 LONG rightmost
= max(lMax
, infoPtr
->lRangeMin
);
1270 infoPtr
->lRangeMax
= lMax
;
1271 if (infoPtr
->lPos
> rightmost
) {
1272 infoPtr
->lPos
= rightmost
;
1273 infoPtr
->flags
|= TB_THUMBPOSCHANGED
;
1276 infoPtr
->lPageSize
= (infoPtr
->lRangeMax
- infoPtr
->lRangeMin
) / 5;
1277 if (infoPtr
->lPageSize
== 0) infoPtr
->lPageSize
= 1;
1279 if (changed
&& (infoPtr
->dwStyle
& TBS_AUTOTICKS
))
1280 TRACKBAR_RecalculateTics (infoPtr
);
1282 if (redraw
) TRACKBAR_InvalidateAll(infoPtr
);
1288 static inline LRESULT
1289 TRACKBAR_SetRangeMin (TRACKBAR_INFO
*infoPtr
, BOOL redraw
, LONG lMin
)
1291 BOOL changed
= infoPtr
->lRangeMin
!= lMin
;
1293 infoPtr
->lRangeMin
= lMin
;
1294 if (infoPtr
->lPos
< infoPtr
->lRangeMin
) {
1295 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1296 infoPtr
->flags
|= TB_THUMBPOSCHANGED
;
1299 infoPtr
->lPageSize
= (infoPtr
->lRangeMax
- infoPtr
->lRangeMin
) / 5;
1300 if (infoPtr
->lPageSize
== 0) infoPtr
->lPageSize
= 1;
1302 if (changed
&& (infoPtr
->dwStyle
& TBS_AUTOTICKS
))
1303 TRACKBAR_RecalculateTics (infoPtr
);
1305 if (redraw
) TRACKBAR_InvalidateAll(infoPtr
);
1311 static inline LRESULT
1312 TRACKBAR_SetSel (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
, LONG lSel
)
1314 if (!(infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)){
1315 infoPtr
->lSelMin
= 0;
1316 infoPtr
->lSelMax
= 0;
1320 infoPtr
->lSelMin
= (SHORT
)LOWORD(lSel
);
1321 infoPtr
->lSelMax
= (SHORT
)HIWORD(lSel
);
1322 infoPtr
->flags
|= TB_SELECTIONCHANGED
;
1324 if (infoPtr
->lSelMin
< infoPtr
->lRangeMin
)
1325 infoPtr
->lSelMin
= infoPtr
->lRangeMin
;
1326 if (infoPtr
->lSelMax
> infoPtr
->lRangeMax
)
1327 infoPtr
->lSelMax
= infoPtr
->lRangeMax
;
1329 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1335 static inline LRESULT
1336 TRACKBAR_SetSelEnd (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
, LONG lEnd
)
1338 if (!(infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)){
1339 infoPtr
->lSelMax
= 0;
1343 infoPtr
->lSelMax
= lEnd
;
1344 infoPtr
->flags
|= TB_SELECTIONCHANGED
;
1346 if (infoPtr
->lSelMax
> infoPtr
->lRangeMax
)
1347 infoPtr
->lSelMax
= infoPtr
->lRangeMax
;
1349 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1355 static inline LRESULT
1356 TRACKBAR_SetSelStart (TRACKBAR_INFO
*infoPtr
, BOOL fRedraw
, LONG lStart
)
1358 if (!(infoPtr
->dwStyle
& TBS_ENABLESELRANGE
)){
1359 infoPtr
->lSelMin
= 0;
1363 infoPtr
->lSelMin
= lStart
;
1364 infoPtr
->flags
|=TB_SELECTIONCHANGED
;
1366 if (infoPtr
->lSelMin
< infoPtr
->lRangeMin
)
1367 infoPtr
->lSelMin
= infoPtr
->lRangeMin
;
1369 if (fRedraw
) TRACKBAR_InvalidateAll(infoPtr
);
1375 static inline LRESULT
1376 TRACKBAR_SetThumbLength (TRACKBAR_INFO
*infoPtr
, UINT iLength
)
1378 if (infoPtr
->dwStyle
& TBS_FIXEDLENGTH
) {
1379 /* We're not supposed to check if it's really changed or not,
1380 just repaint in any case. */
1381 infoPtr
->uThumbLen
= iLength
;
1382 infoPtr
->flags
|= TB_THUMBSIZECHANGED
;
1383 TRACKBAR_InvalidateAll(infoPtr
);
1390 static inline LRESULT
1391 TRACKBAR_SetTic (TRACKBAR_INFO
*infoPtr
, LONG lPos
)
1393 if ((lPos
< infoPtr
->lRangeMin
) || (lPos
> infoPtr
->lRangeMax
))
1396 TRACE("lPos=%d\n", lPos
);
1398 infoPtr
->uNumTics
++;
1399 infoPtr
->tics
=ReAlloc( infoPtr
->tics
,
1400 (infoPtr
->uNumTics
)*sizeof (DWORD
));
1401 if (!infoPtr
->tics
) {
1402 infoPtr
->uNumTics
= 0;
1403 notify(infoPtr
, NM_OUTOFMEMORY
);
1406 infoPtr
->tics
[infoPtr
->uNumTics
-1] = lPos
;
1408 TRACKBAR_InvalidateAll(infoPtr
);
1414 static inline LRESULT
1415 TRACKBAR_SetTicFreq (TRACKBAR_INFO
*infoPtr
, WORD wFreq
)
1417 if (infoPtr
->dwStyle
& TBS_AUTOTICKS
) {
1418 infoPtr
->uTicFreq
= wFreq
;
1419 TRACKBAR_RecalculateTics (infoPtr
);
1420 TRACKBAR_InvalidateAll(infoPtr
);
1423 TRACKBAR_UpdateThumb (infoPtr
);
1429 TRACKBAR_SetTipSide (TRACKBAR_INFO
*infoPtr
, INT fLocation
)
1431 INT fTemp
= infoPtr
->fLocation
;
1433 infoPtr
->fLocation
= fLocation
;
1439 static inline LRESULT
1440 TRACKBAR_SetToolTips (TRACKBAR_INFO
*infoPtr
, HWND hwndTT
)
1442 infoPtr
->hwndToolTip
= hwndTT
;
1449 TRACKBAR_SetUnicodeFormat (TRACKBAR_INFO
*infoPtr
, BOOL fUnicode
)
1451 BOOL bTemp
= infoPtr
->bUnicode
;
1453 infoPtr
->bUnicode
= fUnicode
;
1460 TRACKBAR_InitializeThumb (TRACKBAR_INFO
*infoPtr
)
1463 int clientWidth
, clientMetric
;
1465 /* initial thumb length */
1466 clientMetric
= (infoPtr
->dwStyle
& TBS_ENABLESELRANGE
) ? 23 : 21;
1467 GetClientRect(infoPtr
->hwndSelf
,&rect
);
1468 if (infoPtr
->dwStyle
& TBS_VERT
) {
1469 clientWidth
= rect
.right
- rect
.left
;
1471 clientWidth
= rect
.bottom
- rect
.top
;
1473 if (clientWidth
>= clientMetric
)
1474 infoPtr
->uThumbLen
= clientMetric
;
1476 infoPtr
->uThumbLen
= clientWidth
> 9 ? clientWidth
- 6 : 4;
1478 TRACKBAR_CalcChannel (infoPtr
);
1479 TRACKBAR_UpdateThumb (infoPtr
);
1480 infoPtr
->flags
&= ~TB_SELECTIONCHANGED
;
1487 TRACKBAR_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
1489 TRACKBAR_INFO
*infoPtr
;
1491 infoPtr
= Alloc (sizeof(TRACKBAR_INFO
));
1492 if (!infoPtr
) return -1;
1493 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
1495 /* set default values */
1496 infoPtr
->hwndSelf
= hwnd
;
1497 infoPtr
->dwStyle
= lpcs
->style
;
1498 infoPtr
->lRangeMin
= 0;
1499 infoPtr
->lRangeMax
= 100;
1500 infoPtr
->lLineSize
= 1;
1501 infoPtr
->lPageSize
= TB_DEFAULTPAGESIZE
;
1502 infoPtr
->lSelMin
= 0;
1503 infoPtr
->lSelMax
= 0;
1505 infoPtr
->fLocation
= TBTS_TOP
;
1506 infoPtr
->uNumTics
= 0; /* start and end tic are not included in count*/
1507 infoPtr
->uTicFreq
= 1;
1508 infoPtr
->tics
= NULL
;
1509 infoPtr
->hwndNotify
= lpcs
->hwndParent
;
1511 TRACKBAR_InitializeThumb (infoPtr
);
1513 /* Create tooltip control */
1514 if (infoPtr
->dwStyle
& TBS_TOOLTIPS
) {
1516 infoPtr
->hwndToolTip
=
1517 CreateWindowExW (0, TOOLTIPS_CLASSW
, NULL
, WS_POPUP
,
1518 CW_USEDEFAULT
, CW_USEDEFAULT
,
1519 CW_USEDEFAULT
, CW_USEDEFAULT
,
1522 if (infoPtr
->hwndToolTip
) {
1525 ZeroMemory (&ti
, sizeof(ti
));
1526 ti
.cbSize
= sizeof(ti
);
1527 ti
.uFlags
= TTF_IDISHWND
| TTF_TRACK
| TTF_ABSOLUTE
;
1529 ti
.lpszText
= &wEmpty
;
1531 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
, 0, (LPARAM
)&ti
);
1535 OpenThemeData (hwnd
, themeClass
);
1542 TRACKBAR_Destroy (TRACKBAR_INFO
*infoPtr
)
1544 /* delete tooltip control */
1545 if (infoPtr
->hwndToolTip
)
1546 DestroyWindow (infoPtr
->hwndToolTip
);
1548 Free (infoPtr
->tics
);
1549 infoPtr
->tics
= NULL
;
1551 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
1552 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
1560 TRACKBAR_KillFocus (TRACKBAR_INFO
*infoPtr
)
1563 infoPtr
->bFocussed
= FALSE
;
1564 TRACKBAR_InvalidateAll(infoPtr
);
1570 TRACKBAR_LButtonDown (TRACKBAR_INFO
*infoPtr
, INT x
, INT y
)
1577 SetFocus(infoPtr
->hwndSelf
);
1579 if (PtInRect(&infoPtr
->rcThumb
, clickPoint
)) {
1580 infoPtr
->flags
|= TB_DRAG_MODE
;
1581 SetCapture (infoPtr
->hwndSelf
);
1582 TRACKBAR_UpdateToolTip (infoPtr
);
1583 TRACKBAR_ActivateToolTip (infoPtr
, TRUE
);
1584 TRACKBAR_InvalidateThumb(infoPtr
, infoPtr
->lPos
);
1586 LONG dir
= TRACKBAR_GetAutoPageDirection(infoPtr
, clickPoint
);
1587 if (dir
== 0) return 0;
1588 infoPtr
->flags
|= (dir
< 0) ? TB_AUTO_PAGE_LEFT
: TB_AUTO_PAGE_RIGHT
;
1589 TRACKBAR_AutoPage (infoPtr
, clickPoint
);
1590 SetCapture (infoPtr
->hwndSelf
);
1591 SetTimer(infoPtr
->hwndSelf
, TB_REFRESH_TIMER
, TB_REFRESH_DELAY
, 0);
1599 TRACKBAR_LButtonUp (TRACKBAR_INFO
*infoPtr
)
1601 if (infoPtr
->flags
& TB_DRAG_MODE
) {
1602 notify_with_scroll (infoPtr
, TB_THUMBPOSITION
| (infoPtr
->lPos
<<16));
1603 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1604 infoPtr
->flags
&= ~TB_DRAG_MODE
;
1606 notify(infoPtr
, NM_RELEASEDCAPTURE
);
1607 TRACKBAR_ActivateToolTip(infoPtr
, FALSE
);
1608 TRACKBAR_InvalidateThumb(infoPtr
, infoPtr
->lPos
);
1610 if (infoPtr
->flags
& TB_AUTO_PAGE
) {
1611 KillTimer (infoPtr
->hwndSelf
, TB_REFRESH_TIMER
);
1612 infoPtr
->flags
&= ~TB_AUTO_PAGE
;
1613 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1615 notify(infoPtr
, NM_RELEASEDCAPTURE
);
1623 TRACKBAR_CaptureChanged (const TRACKBAR_INFO
*infoPtr
)
1625 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1631 TRACKBAR_Paint (TRACKBAR_INFO
*infoPtr
, HDC hdc
)
1634 TRACKBAR_Refresh(infoPtr
, hdc
);
1637 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
1638 TRACKBAR_Refresh (infoPtr
, hdc
);
1639 EndPaint (infoPtr
->hwndSelf
, &ps
);
1647 TRACKBAR_SetFocus (TRACKBAR_INFO
*infoPtr
)
1650 infoPtr
->bFocussed
= TRUE
;
1651 TRACKBAR_InvalidateAll(infoPtr
);
1658 TRACKBAR_Size (TRACKBAR_INFO
*infoPtr
)
1660 if (infoPtr
->dwStyle
& TBS_FIXEDLENGTH
)
1662 TRACKBAR_CalcChannel(infoPtr
);
1663 TRACKBAR_UpdateThumb(infoPtr
);
1666 TRACKBAR_InitializeThumb(infoPtr
);
1667 TRACKBAR_AlignBuddies (infoPtr
);
1668 TRACKBAR_InvalidateAll(infoPtr
);
1674 TRACKBAR_StyleChanged (TRACKBAR_INFO
*infoPtr
, WPARAM wStyleType
,
1675 const STYLESTRUCT
*lpss
)
1677 if (wStyleType
!= GWL_STYLE
) return 0;
1679 infoPtr
->dwStyle
= lpss
->styleNew
;
1685 TRACKBAR_Timer (TRACKBAR_INFO
*infoPtr
)
1687 if (infoPtr
->flags
& TB_AUTO_PAGE
) {
1689 if (GetCursorPos(&pt
))
1690 if (ScreenToClient(infoPtr
->hwndSelf
, &pt
))
1691 TRACKBAR_AutoPage(infoPtr
, pt
);
1697 /* update theme after a WM_THEMECHANGED message */
1698 static LRESULT
theme_changed (const TRACKBAR_INFO
* infoPtr
)
1700 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1701 CloseThemeData (theme
);
1702 OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
1708 TRACKBAR_MouseMove (TRACKBAR_INFO
*infoPtr
, INT x
, INT y
)
1710 INT clickPlace
= (infoPtr
->dwStyle
& TBS_VERT
) ? y
: x
;
1711 LONG dragPos
, oldPos
= infoPtr
->lPos
;
1713 TRACE("(x=%d. y=%d)\n", x
, y
);
1715 if (infoPtr
->flags
& TB_AUTO_PAGE
) {
1719 TRACKBAR_AutoPage (infoPtr
, pt
);
1723 if (!(infoPtr
->flags
& TB_DRAG_MODE
))
1725 if (GetWindowTheme (infoPtr
->hwndSelf
))
1727 DWORD oldFlags
= infoPtr
->flags
;
1731 if (PtInRect (&infoPtr
->rcThumb
, pt
))
1733 TRACKMOUSEEVENT tme
;
1734 tme
.cbSize
= sizeof( tme
);
1735 tme
.dwFlags
= TME_LEAVE
;
1736 tme
.hwndTrack
= infoPtr
->hwndSelf
;
1737 TrackMouseEvent( &tme
);
1738 infoPtr
->flags
|= TB_THUMB_HOT
;
1742 TRACKMOUSEEVENT tme
;
1743 tme
.cbSize
= sizeof( tme
);
1744 tme
.dwFlags
= TME_CANCEL
;
1745 tme
.hwndTrack
= infoPtr
->hwndSelf
;
1746 TrackMouseEvent( &tme
);
1747 infoPtr
->flags
&= ~TB_THUMB_HOT
;
1749 if (oldFlags
!= infoPtr
->flags
) InvalidateRect (infoPtr
->hwndSelf
, &infoPtr
->rcThumb
, FALSE
);
1754 dragPos
= TRACKBAR_ConvertPlaceToPosition (infoPtr
, clickPlace
);
1756 if (dragPos
== oldPos
) return TRUE
;
1758 infoPtr
->lPos
= dragPos
;
1759 TRACKBAR_UpdateThumb (infoPtr
);
1761 notify_with_scroll (infoPtr
, TB_THUMBTRACK
| (infoPtr
->lPos
<<16));
1763 TRACKBAR_InvalidateThumbMove(infoPtr
, oldPos
, dragPos
);
1764 UpdateWindow (infoPtr
->hwndSelf
);
1770 TRACKBAR_KeyDown (TRACKBAR_INFO
*infoPtr
, INT nVirtKey
)
1772 BOOL downIsLeft
= infoPtr
->dwStyle
& TBS_DOWNISLEFT
;
1773 BOOL vert
= infoPtr
->dwStyle
& TBS_VERT
;
1774 LONG pos
= infoPtr
->lPos
;
1776 TRACE("%x\n", nVirtKey
);
1780 if (!vert
&& downIsLeft
) TRACKBAR_LineDown(infoPtr
);
1781 else TRACKBAR_LineUp(infoPtr
);
1784 if (vert
&& downIsLeft
) TRACKBAR_LineDown(infoPtr
);
1785 else TRACKBAR_LineUp(infoPtr
);
1788 if (!vert
&& downIsLeft
) TRACKBAR_LineUp(infoPtr
);
1789 else TRACKBAR_LineDown(infoPtr
);
1792 if (vert
&& downIsLeft
) TRACKBAR_LineUp(infoPtr
);
1793 else TRACKBAR_LineDown(infoPtr
);
1796 if (!vert
&& downIsLeft
) TRACKBAR_PageUp(infoPtr
);
1797 else TRACKBAR_PageDown(infoPtr
);
1800 if (!vert
&& downIsLeft
) TRACKBAR_PageDown(infoPtr
);
1801 else TRACKBAR_PageUp(infoPtr
);
1804 if (infoPtr
->lPos
== infoPtr
->lRangeMin
) return FALSE
;
1805 infoPtr
->lPos
= infoPtr
->lRangeMin
;
1806 notify_with_scroll (infoPtr
, TB_TOP
);
1809 if (infoPtr
->lPos
== infoPtr
->lRangeMax
) return FALSE
;
1810 infoPtr
->lPos
= infoPtr
->lRangeMax
;
1811 notify_with_scroll (infoPtr
, TB_BOTTOM
);
1815 if (pos
!= infoPtr
->lPos
) {
1816 TRACKBAR_UpdateThumb (infoPtr
);
1817 TRACKBAR_InvalidateThumbMove (infoPtr
, pos
, infoPtr
->lPos
);
1825 TRACKBAR_KeyUp (const TRACKBAR_INFO
*infoPtr
, INT nVirtKey
)
1836 notify_with_scroll (infoPtr
, TB_ENDTRACK
);
1843 TRACKBAR_Enable (TRACKBAR_INFO
*infoPtr
, BOOL enable
)
1846 infoPtr
->dwStyle
&= ~WS_DISABLED
;
1848 infoPtr
->dwStyle
|= WS_DISABLED
;
1850 InvalidateRect(infoPtr
->hwndSelf
, &infoPtr
->rcThumb
, TRUE
);
1855 static LRESULT WINAPI
1856 TRACKBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1858 TRACKBAR_INFO
*infoPtr
= (TRACKBAR_INFO
*)GetWindowLongPtrW (hwnd
, 0);
1860 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
1862 if (!infoPtr
&& (uMsg
!= WM_CREATE
))
1863 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
1868 return TRACKBAR_ClearSel (infoPtr
, (BOOL
)wParam
);
1871 return TRACKBAR_ClearTics (infoPtr
, (BOOL
)wParam
);
1874 return (LRESULT
)(wParam
? infoPtr
->hwndBuddyLA
: infoPtr
->hwndBuddyRB
);
1876 case TBM_GETCHANNELRECT
:
1877 return TRACKBAR_GetChannelRect (infoPtr
, (LPRECT
)lParam
);
1879 case TBM_GETLINESIZE
:
1880 return infoPtr
->lLineSize
;
1882 case TBM_GETNUMTICS
:
1883 return TRACKBAR_GetNumTics (infoPtr
);
1885 case TBM_GETPAGESIZE
:
1886 return infoPtr
->lPageSize
;
1889 return infoPtr
->lPos
;
1892 return (LRESULT
)infoPtr
->tics
;
1894 case TBM_GETRANGEMAX
:
1895 return infoPtr
->lRangeMax
;
1897 case TBM_GETRANGEMIN
:
1898 return infoPtr
->lRangeMin
;
1901 return infoPtr
->lSelMax
;
1903 case TBM_GETSELSTART
:
1904 return infoPtr
->lSelMin
;
1906 case TBM_GETTHUMBLENGTH
:
1907 return infoPtr
->uThumbLen
;
1909 case TBM_GETTHUMBRECT
:
1910 return CopyRect((LPRECT
)lParam
, &infoPtr
->rcThumb
);
1913 return TRACKBAR_GetTic (infoPtr
, (INT
)wParam
);
1916 return TRACKBAR_GetTicPos (infoPtr
, (INT
)wParam
);
1918 case TBM_GETTOOLTIPS
:
1919 return (LRESULT
)infoPtr
->hwndToolTip
;
1921 case TBM_GETUNICODEFORMAT
:
1922 return infoPtr
->bUnicode
;
1925 return (LRESULT
) TRACKBAR_SetBuddy(infoPtr
, (BOOL
)wParam
, (HWND
)lParam
);
1927 case TBM_SETLINESIZE
:
1928 return TRACKBAR_SetLineSize (infoPtr
, (LONG
)lParam
);
1930 case TBM_SETPAGESIZE
:
1931 return TRACKBAR_SetPageSize (infoPtr
, (LONG
)lParam
);
1934 return TRACKBAR_SetPos (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1937 return TRACKBAR_SetRange (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1939 case TBM_SETRANGEMAX
:
1940 return TRACKBAR_SetRangeMax (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1942 case TBM_SETRANGEMIN
:
1943 return TRACKBAR_SetRangeMin (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1946 return TRACKBAR_SetSel (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1949 return TRACKBAR_SetSelEnd (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1951 case TBM_SETSELSTART
:
1952 return TRACKBAR_SetSelStart (infoPtr
, (BOOL
)wParam
, (LONG
)lParam
);
1954 case TBM_SETTHUMBLENGTH
:
1955 return TRACKBAR_SetThumbLength (infoPtr
, (UINT
)wParam
);
1958 return TRACKBAR_SetTic (infoPtr
, (LONG
)lParam
);
1960 case TBM_SETTICFREQ
:
1961 return TRACKBAR_SetTicFreq (infoPtr
, (WORD
)wParam
);
1963 case TBM_SETTIPSIDE
:
1964 return TRACKBAR_SetTipSide (infoPtr
, (INT
)wParam
);
1966 case TBM_SETTOOLTIPS
:
1967 return TRACKBAR_SetToolTips (infoPtr
, (HWND
)wParam
);
1969 case TBM_SETUNICODEFORMAT
:
1970 return TRACKBAR_SetUnicodeFormat (infoPtr
, (BOOL
)wParam
);
1973 case WM_CAPTURECHANGED
:
1974 if (hwnd
== (HWND
)lParam
) return 0;
1975 return TRACKBAR_CaptureChanged (infoPtr
);
1978 return TRACKBAR_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
1981 return TRACKBAR_Destroy (infoPtr
);
1984 return TRACKBAR_Enable (infoPtr
, (BOOL
)wParam
);
1990 return DLGC_WANTARROWS
;
1993 return TRACKBAR_KeyDown (infoPtr
, (INT
)wParam
);
1996 return TRACKBAR_KeyUp (infoPtr
, (INT
)wParam
);
1999 return TRACKBAR_KillFocus (infoPtr
);
2001 case WM_LBUTTONDOWN
:
2002 return TRACKBAR_LButtonDown (infoPtr
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
2005 return TRACKBAR_LButtonUp (infoPtr
);
2008 infoPtr
->flags
&= ~TB_THUMB_HOT
;
2009 InvalidateRect (infoPtr
->hwndSelf
, &infoPtr
->rcThumb
, FALSE
);
2013 return TRACKBAR_MouseMove (infoPtr
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
2015 case WM_PRINTCLIENT
:
2017 return TRACKBAR_Paint (infoPtr
, (HDC
)wParam
);
2020 return TRACKBAR_SetFocus (infoPtr
);
2023 return TRACKBAR_Size (infoPtr
);
2025 case WM_STYLECHANGED
:
2026 return TRACKBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
2028 case WM_THEMECHANGED
:
2029 return theme_changed (infoPtr
);
2032 return TRACKBAR_Timer (infoPtr
);
2034 case WM_WININICHANGE
:
2035 return TRACKBAR_InitializeThumb (infoPtr
);
2038 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
2039 ERR("unknown msg %04x wp=%08lx lp=%08lx\n", uMsg
, wParam
, lParam
);
2040 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2045 void TRACKBAR_Register (void)
2049 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
2050 wndClass
.style
= CS_GLOBALCLASS
;
2051 wndClass
.lpfnWndProc
= TRACKBAR_WindowProc
;
2052 wndClass
.cbClsExtra
= 0;
2053 wndClass
.cbWndExtra
= sizeof(TRACKBAR_INFO
*);
2054 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
2055 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
2056 wndClass
.lpszClassName
= TRACKBAR_CLASSW
;
2058 RegisterClassW (&wndClass
);
2062 void TRACKBAR_Unregister (void)
2064 UnregisterClassW (TRACKBAR_CLASSW
, NULL
);