configure: Changes from running autconf after previous patch.
[wine/hacks.git] / dlls / comctl32 / trackbar.c
blobc924b5304e1142b38fb75ae382a1cf16e9b11692
1 /*
2 * Trackbar control
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
22 * NOTE
24 * This code was audited for completeness against the documented features
25 * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun.
27 * Unless otherwise noted, we believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features, or bugs, please note them below.
33 #include <stdarg.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
38 #include "windef.h"
39 #include "winbase.h"
40 #include "wingdi.h"
41 #include "winuser.h"
42 #include "winnls.h"
43 #include "commctrl.h"
44 #include "uxtheme.h"
45 #include "tmschema.h"
46 #include "wine/debug.h"
48 #include "comctl32.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(trackbar);
52 typedef struct
54 HWND hwndSelf;
55 DWORD dwStyle;
56 LONG lRangeMin;
57 LONG lRangeMax;
58 LONG lLineSize;
59 LONG lPageSize;
60 LONG lSelMin;
61 LONG lSelMax;
62 LONG lPos;
63 UINT uThumbLen;
64 UINT uNumTics;
65 UINT uTicFreq;
66 HWND hwndNotify;
67 HWND hwndToolTip;
68 HWND hwndBuddyLA;
69 HWND hwndBuddyRB;
70 INT fLocation;
71 INT flags;
72 BOOL bUnicode;
73 BOOL bFocussed;
74 RECT rcChannel;
75 RECT rcSelection;
76 RECT rcThumb;
77 LPLONG tics;
78 } TRACKBAR_INFO;
80 #define TB_REFRESH_TIMER 1
81 #define TB_REFRESH_DELAY 500
83 #define TOOLTIP_OFFSET 2 /* distance from ctrl edge to tooltip */
85 #define TB_DEFAULTPAGESIZE 20
87 /* Used by TRACKBAR_Refresh to find out which parts of the control
88 need to be recalculated */
90 #define TB_THUMBPOSCHANGED 1
91 #define TB_THUMBSIZECHANGED 2
92 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBSIZECHANGED)
93 #define TB_SELECTIONCHANGED 4
94 #define TB_DRAG_MODE 8 /* we're dragging the slider */
95 #define TB_AUTO_PAGE_LEFT 16
96 #define TB_AUTO_PAGE_RIGHT 32
97 #define TB_AUTO_PAGE (TB_AUTO_PAGE_LEFT | TB_AUTO_PAGE_RIGHT)
98 #define TB_THUMB_HOT 64 /* mouse hovers above thumb */
100 /* helper defines for TRACKBAR_DrawTic */
101 #define TIC_EDGE 0x20
102 #define TIC_SELECTIONMARKMAX 0x80
103 #define TIC_SELECTIONMARKMIN 0x100
104 #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
106 static const WCHAR themeClass[] = { 'T','r','a','c','k','b','a','r',0 };
108 static inline int
109 notify_customdraw (const TRACKBAR_INFO *infoPtr, NMCUSTOMDRAW *pnmcd, int stage)
111 pnmcd->dwDrawStage = stage;
112 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
113 pnmcd->hdr.idFrom, (LPARAM)pnmcd);
116 static LRESULT notify_hdr (const TRACKBAR_INFO *infoPtr, INT code, LPNMHDR pnmh)
118 LRESULT result;
120 TRACE("(code=%d)\n", code);
122 pnmh->hwndFrom = infoPtr->hwndSelf;
123 pnmh->idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
124 pnmh->code = code;
125 result = SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, pnmh->idFrom, (LPARAM)pnmh);
127 TRACE(" <= %ld\n", result);
129 return result;
132 static inline int notify (const TRACKBAR_INFO *infoPtr, INT code)
134 NMHDR nmh;
135 return notify_hdr(infoPtr, code, &nmh);
138 static void notify_with_scroll (const TRACKBAR_INFO *infoPtr, UINT code)
140 UINT scroll = infoPtr->dwStyle & TBS_VERT ? WM_VSCROLL : WM_HSCROLL;
142 TRACE("%x\n", code);
144 SendMessageW (infoPtr->hwndNotify, scroll, code, (LPARAM)infoPtr->hwndSelf);
147 static void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
149 int tic;
150 unsigned nrTics, i;
152 if (infoPtr->uTicFreq && infoPtr->lRangeMax >= infoPtr->lRangeMin) {
153 nrTics=(infoPtr->lRangeMax - infoPtr->lRangeMin)/infoPtr->uTicFreq;
154 /* don't add extra tic if there's no remainder */
155 if (nrTics && ((infoPtr->lRangeMax - infoPtr->lRangeMin) % infoPtr->uTicFreq == 0))
156 nrTics--;
158 else {
159 Free (infoPtr->tics);
160 infoPtr->tics = NULL;
161 infoPtr->uNumTics = 0;
162 return;
165 if (nrTics != infoPtr->uNumTics) {
166 infoPtr->tics=ReAlloc (infoPtr->tics,
167 (nrTics+1)*sizeof (DWORD));
168 if (!infoPtr->tics) {
169 infoPtr->uNumTics = 0;
170 notify(infoPtr, NM_OUTOFMEMORY);
171 return;
173 infoPtr->uNumTics = nrTics;
176 tic = infoPtr->lRangeMin + infoPtr->uTicFreq;
177 for (i = 0; i < nrTics; i++, tic += infoPtr->uTicFreq)
178 infoPtr->tics[i] = tic;
181 /* converts from physical (mouse) position to logical position
182 (in range of trackbar) */
184 static inline LONG
185 TRACKBAR_ConvertPlaceToPosition (const TRACKBAR_INFO *infoPtr, int place)
187 double range, width, pos, offsetthumb;
189 range = infoPtr->lRangeMax - infoPtr->lRangeMin;
190 if (infoPtr->dwStyle & TBS_VERT) {
191 offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2;
192 width = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - (offsetthumb * 2) - 1;
193 pos = (range*(place - infoPtr->rcChannel.top - offsetthumb)) / width;
194 } else {
195 offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
196 width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - (offsetthumb * 2) - 1;
197 pos = (range*(place - infoPtr->rcChannel.left - offsetthumb)) / width;
199 pos += infoPtr->lRangeMin;
200 if (pos > infoPtr->lRangeMax)
201 pos = infoPtr->lRangeMax;
202 else if (pos < infoPtr->lRangeMin)
203 pos = infoPtr->lRangeMin;
205 TRACE("%.2f\n", pos);
206 return (LONG)(pos + 0.5);
210 /* return: 0> prev, 0 none, >0 next */
211 static LONG
212 TRACKBAR_GetAutoPageDirection (const TRACKBAR_INFO *infoPtr, POINT clickPoint)
214 RECT pageRect;
216 if (infoPtr->dwStyle & TBS_VERT) {
217 pageRect.top = infoPtr->rcChannel.top;
218 pageRect.bottom = infoPtr->rcChannel.bottom;
219 pageRect.left = infoPtr->rcThumb.left;
220 pageRect.right = infoPtr->rcThumb.right;
221 } else {
222 pageRect.top = infoPtr->rcThumb.top;
223 pageRect.bottom = infoPtr->rcThumb.bottom;
224 pageRect.left = infoPtr->rcChannel.left;
225 pageRect.right = infoPtr->rcChannel.right;
229 if (PtInRect(&pageRect, clickPoint))
231 int clickPlace = (infoPtr->dwStyle & TBS_VERT) ? clickPoint.y : clickPoint.x;
233 LONG clickPos = TRACKBAR_ConvertPlaceToPosition(infoPtr, clickPlace);
235 return clickPos - infoPtr->lPos;
238 return 0;
241 static inline void
242 TRACKBAR_PageDown (TRACKBAR_INFO *infoPtr)
244 if (infoPtr->lPos == infoPtr->lRangeMax) return;
246 infoPtr->lPos += infoPtr->lPageSize;
247 if (infoPtr->lPos > infoPtr->lRangeMax)
248 infoPtr->lPos = infoPtr->lRangeMax;
249 notify_with_scroll (infoPtr, TB_PAGEDOWN);
253 static inline void
254 TRACKBAR_PageUp (TRACKBAR_INFO *infoPtr)
256 if (infoPtr->lPos == infoPtr->lRangeMin) return;
258 infoPtr->lPos -= infoPtr->lPageSize;
259 if (infoPtr->lPos < infoPtr->lRangeMin)
260 infoPtr->lPos = infoPtr->lRangeMin;
261 notify_with_scroll (infoPtr, TB_PAGEUP);
264 static inline void TRACKBAR_LineUp(TRACKBAR_INFO *infoPtr)
266 if (infoPtr->lPos == infoPtr->lRangeMin) return;
267 infoPtr->lPos -= infoPtr->lLineSize;
268 if (infoPtr->lPos < infoPtr->lRangeMin)
269 infoPtr->lPos = infoPtr->lRangeMin;
270 notify_with_scroll (infoPtr, TB_LINEUP);
273 static inline void TRACKBAR_LineDown(TRACKBAR_INFO *infoPtr)
275 if (infoPtr->lPos == infoPtr->lRangeMax) return;
276 infoPtr->lPos += infoPtr->lLineSize;
277 if (infoPtr->lPos > infoPtr->lRangeMax)
278 infoPtr->lPos = infoPtr->lRangeMax;
279 notify_with_scroll (infoPtr, TB_LINEDOWN);
282 static void
283 TRACKBAR_CalcChannel (TRACKBAR_INFO *infoPtr)
285 INT cyChannel, offsetthumb, offsetedge;
286 RECT lpRect, *channel = & infoPtr->rcChannel;
288 GetClientRect (infoPtr->hwndSelf, &lpRect);
290 offsetthumb = infoPtr->uThumbLen / 4;
291 offsetedge = offsetthumb + 3;
292 cyChannel = (infoPtr->dwStyle & TBS_ENABLESELRANGE) ? offsetthumb*3 : 4;
293 if (infoPtr->dwStyle & TBS_VERT) {
294 channel->top = lpRect.top + offsetedge;
295 channel->bottom = lpRect.bottom - offsetedge;
296 if (infoPtr->dwStyle & TBS_ENABLESELRANGE)
297 channel->left = lpRect.left + ((infoPtr->uThumbLen - cyChannel + 2) / 2);
298 else
299 channel->left = lpRect.left + (infoPtr->uThumbLen / 2) - 1;
300 if (infoPtr->dwStyle & TBS_BOTH) {
301 if (infoPtr->dwStyle & TBS_NOTICKS)
302 channel->left += 1;
303 else
304 channel->left += 9;
306 else if (infoPtr->dwStyle & TBS_TOP) {
307 if (infoPtr->dwStyle & TBS_NOTICKS)
308 channel->left += 2;
309 else
310 channel->left += 10;
312 channel->right = channel->left + cyChannel;
313 } else {
314 channel->left = lpRect.left + offsetedge;
315 channel->right = lpRect.right - offsetedge;
316 if (infoPtr->dwStyle & TBS_ENABLESELRANGE)
317 channel->top = lpRect.top + ((infoPtr->uThumbLen - cyChannel + 2) / 2);
318 else
319 channel->top = lpRect.top + (infoPtr->uThumbLen / 2) - 1;
320 if (infoPtr->dwStyle & TBS_BOTH) {
321 if (infoPtr->dwStyle & TBS_NOTICKS)
322 channel->top += 1;
323 else
324 channel->top += 9;
326 else if (infoPtr->dwStyle & TBS_TOP) {
327 if (infoPtr->dwStyle & TBS_NOTICKS)
328 channel->top += 2;
329 else
330 channel->top += 10;
332 channel->bottom = channel->top + cyChannel;
336 static void
337 TRACKBAR_CalcThumb (const TRACKBAR_INFO *infoPtr, LONG lPos, RECT *thumb)
339 int range, width, height, thumbwidth;
340 RECT lpRect;
342 range = infoPtr->lRangeMax - infoPtr->lRangeMin;
343 thumbwidth = (infoPtr->uThumbLen / 2) | 1;
345 if (!range) range = 1;
347 GetClientRect(infoPtr->hwndSelf, &lpRect);
348 if (infoPtr->dwStyle & TBS_VERT)
350 height = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - thumbwidth;
352 if ((infoPtr->dwStyle & (TBS_BOTH | TBS_LEFT)) && !(infoPtr->dwStyle & TBS_NOTICKS))
353 thumb->left = 10;
354 else
355 thumb->left = 2;
356 thumb->right = thumb->left + infoPtr->uThumbLen;
357 thumb->top = infoPtr->rcChannel.top +
358 (height*(lPos - infoPtr->lRangeMin))/range;
359 thumb->bottom = thumb->top + thumbwidth;
361 else
363 width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - thumbwidth;
365 thumb->left = infoPtr->rcChannel.left +
366 (width*(lPos - infoPtr->lRangeMin))/range;
367 thumb->right = thumb->left + thumbwidth;
368 if ((infoPtr->dwStyle & (TBS_BOTH | TBS_TOP)) && !(infoPtr->dwStyle & TBS_NOTICKS))
369 thumb->top = 10;
370 else
371 thumb->top = 2;
372 thumb->bottom = thumb->top + infoPtr->uThumbLen;
376 static inline void
377 TRACKBAR_UpdateThumb (TRACKBAR_INFO *infoPtr)
379 TRACKBAR_CalcThumb(infoPtr, infoPtr->lPos, &infoPtr->rcThumb);
382 static inline void
383 TRACKBAR_InvalidateAll (const TRACKBAR_INFO *infoPtr)
385 InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
388 static void
389 TRACKBAR_InvalidateThumb (const TRACKBAR_INFO *infoPtr, LONG thumbPos)
391 RECT rcThumb;
393 TRACKBAR_CalcThumb(infoPtr, thumbPos, &rcThumb);
394 InflateRect(&rcThumb, 1, 1);
395 InvalidateRect(infoPtr->hwndSelf, &rcThumb, FALSE);
398 static inline void
399 TRACKBAR_InvalidateThumbMove (const TRACKBAR_INFO *infoPtr, LONG oldPos, LONG newPos)
401 TRACKBAR_InvalidateThumb (infoPtr, oldPos);
402 if (newPos != oldPos)
403 TRACKBAR_InvalidateThumb (infoPtr, newPos);
406 static inline BOOL
407 TRACKBAR_HasSelection (const TRACKBAR_INFO *infoPtr)
409 return infoPtr->lSelMin != infoPtr->lSelMax;
412 static void
413 TRACKBAR_CalcSelection (TRACKBAR_INFO *infoPtr)
415 RECT *selection = &infoPtr->rcSelection;
416 int range = infoPtr->lRangeMax - infoPtr->lRangeMin;
417 int offsetthumb, height, width;
419 if (range <= 0) {
420 SetRectEmpty (selection);
421 } else {
422 if (infoPtr->dwStyle & TBS_VERT) {
423 offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2;
424 height = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - offsetthumb*2;
425 selection->top = infoPtr->rcChannel.top + offsetthumb +
426 (height*infoPtr->lSelMin)/range;
427 selection->bottom = infoPtr->rcChannel.top + offsetthumb +
428 (height*infoPtr->lSelMax)/range;
429 selection->left = infoPtr->rcChannel.left + 3;
430 selection->right = infoPtr->rcChannel.right - 3;
431 } else {
432 offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
433 width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - offsetthumb*2;
434 selection->left = infoPtr->rcChannel.left + offsetthumb +
435 (width*infoPtr->lSelMin)/range;
436 selection->right = infoPtr->rcChannel.left + offsetthumb +
437 (width*infoPtr->lSelMax)/range;
438 selection->top = infoPtr->rcChannel.top + 3;
439 selection->bottom = infoPtr->rcChannel.bottom - 3;
443 TRACE("selection[%s]\n", wine_dbgstr_rect(selection));
446 static BOOL
447 TRACKBAR_AutoPage (TRACKBAR_INFO *infoPtr, POINT clickPoint)
449 LONG dir = TRACKBAR_GetAutoPageDirection(infoPtr, clickPoint);
450 LONG prevPos = infoPtr->lPos;
452 TRACE("x=%d, y=%d, dir=%d\n", clickPoint.x, clickPoint.y, dir);
454 if (dir > 0 && (infoPtr->flags & TB_AUTO_PAGE_RIGHT))
455 TRACKBAR_PageDown(infoPtr);
456 else if (dir < 0 && (infoPtr->flags & TB_AUTO_PAGE_LEFT))
457 TRACKBAR_PageUp(infoPtr);
458 else return FALSE;
460 infoPtr->flags |= TB_THUMBPOSCHANGED;
461 TRACKBAR_InvalidateThumbMove (infoPtr, prevPos, infoPtr->lPos);
463 return TRUE;
466 /* Trackbar drawing code. I like my spaghetti done milanese. */
468 static void
469 TRACKBAR_DrawChannel (const TRACKBAR_INFO *infoPtr, HDC hdc)
471 RECT rcChannel = infoPtr->rcChannel;
472 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
474 if (theme)
476 DrawThemeBackground (theme, hdc,
477 (infoPtr->dwStyle & TBS_VERT) ?
478 TKP_TRACKVERT : TKP_TRACK, TKS_NORMAL, &rcChannel, 0);
480 else
482 DrawEdge (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
483 if (infoPtr->dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
484 FillRect (hdc, &rcChannel, GetStockObject(WHITE_BRUSH));
485 if (TRACKBAR_HasSelection(infoPtr))
486 FillRect (hdc, &infoPtr->rcSelection, GetSysColorBrush(COLOR_HIGHLIGHT));
491 static void
492 TRACKBAR_DrawOneTic (const TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags)
494 int x, y, ox, oy, range, side, indent = 0, len = 3;
495 int offsetthumb;
496 RECT rcTics;
498 if (flags & TBS_VERT) {
499 offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2;
500 rcTics.left = infoPtr->rcThumb.left - 2;
501 rcTics.right = infoPtr->rcThumb.right + 2;
502 rcTics.top = infoPtr->rcChannel.top + offsetthumb + 1;
503 rcTics.bottom = infoPtr->rcChannel.bottom - offsetthumb;
504 } else {
505 offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
506 rcTics.left = infoPtr->rcChannel.left + offsetthumb + 1;
507 rcTics.right = infoPtr->rcChannel.right - offsetthumb;
508 rcTics.top = infoPtr->rcThumb.top - 2;
509 rcTics.bottom = infoPtr->rcThumb.bottom + 2;
512 if (flags & (TBS_TOP | TBS_LEFT)) {
513 x = rcTics.left;
514 y = rcTics.top;
515 side = -1;
516 } else {
517 x = rcTics.right;
518 y = rcTics.bottom;
519 side = 1;
522 range = infoPtr->lRangeMax - infoPtr->lRangeMin;
523 if (range <= 0)
524 range = 1; /* to avoid division by zero */
526 if (flags & TIC_SELECTIONMARK) {
527 indent = (flags & TIC_SELECTIONMARKMIN) ? -1 : 1;
528 } else if (flags & TIC_EDGE) {
529 len++;
532 if (flags & TBS_VERT) {
533 int height = rcTics.bottom - rcTics.top;
534 y = rcTics.top + (height*(ticPos - infoPtr->lRangeMin))/range;
535 } else {
536 int width = rcTics.right - rcTics.left;
537 x = rcTics.left + (width*(ticPos - infoPtr->lRangeMin))/range;
540 ox = x;
541 oy = y;
542 MoveToEx(hdc, x, y, 0);
543 if (flags & TBS_VERT) x += len * side;
544 else y += len * side;
545 LineTo(hdc, x, y);
547 if (flags & TIC_SELECTIONMARK) {
548 if (flags & TBS_VERT) {
549 x -= side;
550 } else {
551 y -= side;
553 MoveToEx(hdc, x, y, 0);
554 if (flags & TBS_VERT) {
555 y += 2 * indent;
556 } else {
557 x += 2 * indent;
560 LineTo(hdc, x, y);
561 LineTo(hdc, ox, oy);
566 static inline void
567 TRACKBAR_DrawTic (const TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags)
569 if ((flags & (TBS_LEFT | TBS_TOP)) || (flags & TBS_BOTH))
570 TRACKBAR_DrawOneTic (infoPtr, hdc, ticPos, flags | TBS_LEFT);
572 if (!(flags & (TBS_LEFT | TBS_TOP)) || (flags & TBS_BOTH))
573 TRACKBAR_DrawOneTic (infoPtr, hdc, ticPos, flags & ~TBS_LEFT);
576 static void
577 TRACKBAR_DrawTics (const TRACKBAR_INFO *infoPtr, HDC hdc)
579 unsigned int i;
580 int ticFlags = infoPtr->dwStyle & 0x0f;
581 LOGPEN ticPen = { PS_SOLID, {1, 0}, GetSysColor (COLOR_3DDKSHADOW) };
582 HPEN hOldPen, hTicPen;
583 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
585 if (theme)
587 int part = (infoPtr->dwStyle & TBS_VERT) ? TKP_TICSVERT : TKP_TICS;
588 GetThemeColor (theme, part, TSS_NORMAL, TMT_COLOR, &ticPen.lopnColor);
590 /* create the pen to draw the tics with */
591 hTicPen = CreatePenIndirect(&ticPen);
592 hOldPen = hTicPen ? SelectObject(hdc, hTicPen) : 0;
594 /* actually draw the tics */
595 for (i=0; i<infoPtr->uNumTics; i++)
596 TRACKBAR_DrawTic (infoPtr, hdc, infoPtr->tics[i], ticFlags);
598 TRACKBAR_DrawTic (infoPtr, hdc, infoPtr->lRangeMin, ticFlags | TIC_EDGE);
599 TRACKBAR_DrawTic (infoPtr, hdc, infoPtr->lRangeMax, ticFlags | TIC_EDGE);
601 if ((infoPtr->dwStyle & TBS_ENABLESELRANGE) && TRACKBAR_HasSelection(infoPtr)) {
602 TRACKBAR_DrawTic (infoPtr, hdc, infoPtr->lSelMin,
603 ticFlags | TIC_SELECTIONMARKMIN);
604 TRACKBAR_DrawTic (infoPtr, hdc, infoPtr->lSelMax,
605 ticFlags | TIC_SELECTIONMARKMAX);
608 /* clean up the pen, if we created one */
609 if (hTicPen) {
610 SelectObject(hdc, hOldPen);
611 DeleteObject(hTicPen);
615 static void
616 TRACKBAR_DrawThumb (const TRACKBAR_INFO *infoPtr, HDC hdc)
618 HBRUSH oldbr;
619 HPEN oldpen;
620 RECT thumb = infoPtr->rcThumb;
621 int BlackUntil = 3;
622 int PointCount = 6;
623 POINT points[6];
624 int fillClr;
625 int PointDepth;
626 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
628 if (theme)
630 int partId;
631 int stateId;
632 if (infoPtr->dwStyle & TBS_BOTH)
633 partId = (infoPtr->dwStyle & TBS_VERT) ? TKP_THUMBVERT : TKP_THUMB;
634 else if (infoPtr->dwStyle & TBS_LEFT)
635 partId = (infoPtr->dwStyle & TBS_VERT) ? TKP_THUMBLEFT : TKP_THUMBTOP;
636 else
637 partId = (infoPtr->dwStyle & TBS_VERT) ? TKP_THUMBRIGHT : TKP_THUMBBOTTOM;
639 if (infoPtr->dwStyle & WS_DISABLED)
640 stateId = TUS_DISABLED;
641 else if (infoPtr->flags & TB_DRAG_MODE)
642 stateId = TUS_PRESSED;
643 else if (infoPtr->flags & TB_THUMB_HOT)
644 stateId = TUS_HOT;
645 else
646 stateId = TUS_NORMAL;
648 DrawThemeBackground (theme, hdc, partId, stateId, &thumb, 0);
650 return;
653 fillClr = infoPtr->flags & TB_DRAG_MODE ? COLOR_BTNHILIGHT : COLOR_BTNFACE;
654 oldbr = SelectObject (hdc, GetSysColorBrush(fillClr));
655 SetPolyFillMode (hdc, WINDING);
657 if (infoPtr->dwStyle & TBS_BOTH)
659 points[0].x=thumb.right;
660 points[0].y=thumb.top;
661 points[1].x=thumb.right;
662 points[1].y=thumb.bottom;
663 points[2].x=thumb.left;
664 points[2].y=thumb.bottom;
665 points[3].x=thumb.left;
666 points[3].y=thumb.top;
667 points[4].x=points[0].x;
668 points[4].y=points[0].y;
669 PointCount = 5;
670 BlackUntil = 3;
672 else
674 if (infoPtr->dwStyle & TBS_VERT)
676 PointDepth = (thumb.bottom - thumb.top) / 2;
677 if (infoPtr->dwStyle & TBS_LEFT)
679 points[0].x=thumb.right;
680 points[0].y=thumb.top;
681 points[1].x=thumb.right;
682 points[1].y=thumb.bottom;
683 points[2].x=thumb.left + PointDepth;
684 points[2].y=thumb.bottom;
685 points[3].x=thumb.left;
686 points[3].y=(thumb.bottom - thumb.top) / 2 + thumb.top + 1;
687 points[4].x=thumb.left + PointDepth;
688 points[4].y=thumb.top;
689 points[5].x=points[0].x;
690 points[5].y=points[0].y;
691 BlackUntil = 4;
693 else
695 points[0].x=thumb.right;
696 points[0].y=(thumb.bottom - thumb.top) / 2 + thumb.top + 1;
697 points[1].x=thumb.right - PointDepth;
698 points[1].y=thumb.bottom;
699 points[2].x=thumb.left;
700 points[2].y=thumb.bottom;
701 points[3].x=thumb.left;
702 points[3].y=thumb.top;
703 points[4].x=thumb.right - PointDepth;
704 points[4].y=thumb.top;
705 points[5].x=points[0].x;
706 points[5].y=points[0].y;
709 else
711 PointDepth = (thumb.right - thumb.left) / 2;
712 if (infoPtr->dwStyle & TBS_TOP)
714 points[0].x=(thumb.right - thumb.left) / 2 + thumb.left + 1;
715 points[0].y=thumb.top;
716 points[1].x=thumb.right;
717 points[1].y=thumb.top + PointDepth;
718 points[2].x=thumb.right;
719 points[2].y=thumb.bottom;
720 points[3].x=thumb.left;
721 points[3].y=thumb.bottom;
722 points[4].x=thumb.left;
723 points[4].y=thumb.top + PointDepth;
724 points[5].x=points[0].x;
725 points[5].y=points[0].y;
726 BlackUntil = 4;
728 else
730 points[0].x=thumb.right;
731 points[0].y=thumb.top;
732 points[1].x=thumb.right;
733 points[1].y=thumb.bottom - PointDepth;
734 points[2].x=(thumb.right - thumb.left) / 2 + thumb.left + 1;
735 points[2].y=thumb.bottom;
736 points[3].x=thumb.left;
737 points[3].y=thumb.bottom - PointDepth;
738 points[4].x=thumb.left;
739 points[4].y=thumb.top;
740 points[5].x=points[0].x;
741 points[5].y=points[0].y;
747 /* Draw the thumb now */
748 Polygon (hdc, points, PointCount);
749 oldpen = SelectObject(hdc, GetStockObject(BLACK_PEN));
750 Polyline(hdc,points, BlackUntil);
751 SelectObject(hdc, GetStockObject(WHITE_PEN));
752 Polyline(hdc, &points[BlackUntil-1], PointCount+1-BlackUntil);
753 SelectObject(hdc, oldpen);
754 SelectObject(hdc, oldbr);
758 static inline void
759 TRACKBAR_ActivateToolTip (const TRACKBAR_INFO *infoPtr, BOOL fShow)
761 TTTOOLINFOW ti;
763 if (!infoPtr->hwndToolTip) return;
765 ZeroMemory(&ti, sizeof(ti));
766 ti.cbSize = sizeof(ti);
767 ti.hwnd = infoPtr->hwndSelf;
769 SendMessageW (infoPtr->hwndToolTip, TTM_TRACKACTIVATE, fShow, (LPARAM)&ti);
773 static void
774 TRACKBAR_UpdateToolTip (const TRACKBAR_INFO *infoPtr)
776 WCHAR buf[80];
777 static const WCHAR fmt[] = { '%', 'l', 'd', 0 };
778 TTTOOLINFOW ti;
779 POINT pt;
780 RECT rcClient;
781 LRESULT size;
783 if (!infoPtr->hwndToolTip) return;
785 ZeroMemory(&ti, sizeof(ti));
786 ti.cbSize = sizeof(ti);
787 ti.hwnd = infoPtr->hwndSelf;
788 ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
790 wsprintfW (buf, fmt, infoPtr->lPos);
791 ti.lpszText = buf;
792 SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW, 0, (LPARAM)&ti);
794 GetClientRect (infoPtr->hwndSelf, &rcClient);
795 size = SendMessageW (infoPtr->hwndToolTip, TTM_GETBUBBLESIZE, 0, (LPARAM)&ti);
796 if (infoPtr->dwStyle & TBS_VERT) {
797 if (infoPtr->fLocation == TBTS_LEFT)
798 pt.x = 0 - LOWORD(size) - TOOLTIP_OFFSET;
799 else
800 pt.x = rcClient.right + TOOLTIP_OFFSET;
801 pt.y = (infoPtr->rcThumb.top + infoPtr->rcThumb.bottom - HIWORD(size))/2;
802 } else {
803 if (infoPtr->fLocation == TBTS_TOP)
804 pt.y = 0 - HIWORD(size) - TOOLTIP_OFFSET;
805 else
806 pt.y = rcClient.bottom + TOOLTIP_OFFSET;
807 pt.x = (infoPtr->rcThumb.left + infoPtr->rcThumb.right - LOWORD(size))/2;
809 ClientToScreen(infoPtr->hwndSelf, &pt);
811 SendMessageW (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
812 0, MAKELPARAM(pt.x, pt.y));
816 static void
817 TRACKBAR_Refresh (TRACKBAR_INFO *infoPtr, HDC hdcDst)
819 RECT rcClient;
820 HDC hdc;
821 HBITMAP hOldBmp = 0, hOffScreenBmp = 0;
822 NMCUSTOMDRAW nmcd;
823 int gcdrf, icdrf;
825 if (infoPtr->flags & TB_THUMBCHANGED) {
826 TRACKBAR_UpdateThumb (infoPtr);
827 if (infoPtr->flags & TB_THUMBSIZECHANGED)
828 TRACKBAR_CalcChannel (infoPtr);
830 if (infoPtr->flags & TB_SELECTIONCHANGED)
831 TRACKBAR_CalcSelection (infoPtr);
833 if (infoPtr->flags & TB_DRAG_MODE)
834 TRACKBAR_UpdateToolTip (infoPtr);
836 infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED);
838 GetClientRect (infoPtr->hwndSelf, &rcClient);
840 /* try to render offscreen, if we fail, carrry onscreen */
841 hdc = CreateCompatibleDC(hdcDst);
842 if (hdc) {
843 hOffScreenBmp = CreateCompatibleBitmap(hdcDst, rcClient.right, rcClient.bottom);
844 if (hOffScreenBmp) {
845 hOldBmp = SelectObject(hdc, hOffScreenBmp);
846 } else {
847 DeleteObject(hdc);
848 hdc = hdcDst;
850 } else {
851 hdc = hdcDst;
854 ZeroMemory(&nmcd, sizeof(nmcd));
855 nmcd.hdr.hwndFrom = infoPtr->hwndSelf;
856 nmcd.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID);
857 nmcd.hdr.code = NM_CUSTOMDRAW;
858 nmcd.hdc = hdc;
860 /* start the paint cycle */
861 nmcd.rc = rcClient;
862 gcdrf = notify_customdraw(infoPtr, &nmcd, CDDS_PREPAINT);
863 if (gcdrf & CDRF_SKIPDEFAULT) goto cleanup;
865 /* Erase background */
866 if (gcdrf == CDRF_DODEFAULT ||
867 notify_customdraw(infoPtr, &nmcd, CDDS_PREERASE) != CDRF_SKIPDEFAULT) {
868 if (GetWindowTheme (infoPtr->hwndSelf)) {
869 DrawThemeParentBackground (infoPtr->hwndSelf, hdc, 0);
871 else
872 FillRect (hdc, &rcClient, GetSysColorBrush(COLOR_BTNFACE));
873 if (gcdrf != CDRF_DODEFAULT)
874 notify_customdraw(infoPtr, &nmcd, CDDS_POSTERASE);
877 /* draw channel */
878 if (gcdrf & CDRF_NOTIFYITEMDRAW) {
879 nmcd.dwItemSpec = TBCD_CHANNEL;
880 nmcd.uItemState = CDIS_DEFAULT;
881 nmcd.rc = infoPtr->rcChannel;
882 icdrf = notify_customdraw(infoPtr, &nmcd, CDDS_ITEMPREPAINT);
883 } else icdrf = CDRF_DODEFAULT;
884 if ( !(icdrf & CDRF_SKIPDEFAULT) ) {
885 TRACKBAR_DrawChannel (infoPtr, hdc);
886 if (icdrf & CDRF_NOTIFYPOSTPAINT)
887 notify_customdraw(infoPtr, &nmcd, CDDS_ITEMPOSTPAINT);
891 /* draw tics */
892 if (!(infoPtr->dwStyle & TBS_NOTICKS)) {
893 if (gcdrf & CDRF_NOTIFYITEMDRAW) {
894 nmcd.dwItemSpec = TBCD_TICS;
895 nmcd.uItemState = CDIS_DEFAULT;
896 nmcd.rc = rcClient;
897 icdrf = notify_customdraw(infoPtr, &nmcd, CDDS_ITEMPREPAINT);
898 } else icdrf = CDRF_DODEFAULT;
899 if ( !(icdrf & CDRF_SKIPDEFAULT) ) {
900 TRACKBAR_DrawTics (infoPtr, hdc);
901 if (icdrf & CDRF_NOTIFYPOSTPAINT)
902 notify_customdraw(infoPtr, &nmcd, CDDS_ITEMPOSTPAINT);
906 /* draw thumb */
907 if (!(infoPtr->dwStyle & TBS_NOTHUMB)) {
908 if (gcdrf & CDRF_NOTIFYITEMDRAW) {
909 nmcd.dwItemSpec = TBCD_THUMB;
910 nmcd.uItemState = infoPtr->flags & TB_DRAG_MODE ? CDIS_HOT : CDIS_DEFAULT;
911 nmcd.rc = infoPtr->rcThumb;
912 icdrf = notify_customdraw(infoPtr, &nmcd, CDDS_ITEMPREPAINT);
913 } else icdrf = CDRF_DODEFAULT;
914 if ( !(icdrf & CDRF_SKIPDEFAULT) ) {
915 TRACKBAR_DrawThumb(infoPtr, hdc);
916 if (icdrf & CDRF_NOTIFYPOSTPAINT)
917 notify_customdraw(infoPtr, &nmcd, CDDS_ITEMPOSTPAINT);
921 /* draw focus rectangle */
922 if (infoPtr->bFocussed) {
923 DrawFocusRect(hdc, &rcClient);
926 /* finish up the painting */
927 if (gcdrf & CDRF_NOTIFYPOSTPAINT)
928 notify_customdraw(infoPtr, &nmcd, CDDS_POSTPAINT);
930 cleanup:
931 /* cleanup, if we rendered offscreen */
932 if (hdc != hdcDst) {
933 BitBlt(hdcDst, 0, 0, rcClient.right, rcClient.bottom, hdc, 0, 0, SRCCOPY);
934 SelectObject(hdc, hOldBmp);
935 DeleteObject(hOffScreenBmp);
936 DeleteObject(hdc);
941 static void
942 TRACKBAR_AlignBuddies (const TRACKBAR_INFO *infoPtr)
944 HWND hwndParent = GetParent (infoPtr->hwndSelf);
945 RECT rcSelf, rcBuddy;
946 INT x, y;
948 GetWindowRect (infoPtr->hwndSelf, &rcSelf);
949 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcSelf, 2);
951 /* align buddy left or above */
952 if (infoPtr->hwndBuddyLA) {
953 GetWindowRect (infoPtr->hwndBuddyLA, &rcBuddy);
954 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
956 if (infoPtr->dwStyle & TBS_VERT) {
957 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
958 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
959 y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
961 else {
962 x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
963 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
964 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
967 SetWindowPos (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
968 SWP_NOZORDER | SWP_NOSIZE);
972 /* align buddy right or below */
973 if (infoPtr->hwndBuddyRB) {
974 GetWindowRect (infoPtr->hwndBuddyRB, &rcBuddy);
975 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
977 if (infoPtr->dwStyle & TBS_VERT) {
978 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
979 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
980 y = rcSelf.bottom;
982 else {
983 x = rcSelf.right;
984 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
985 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
987 SetWindowPos (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
988 SWP_NOZORDER | SWP_NOSIZE);
993 static LRESULT
994 TRACKBAR_ClearSel (TRACKBAR_INFO *infoPtr, BOOL fRedraw)
996 infoPtr->lSelMin = 0;
997 infoPtr->lSelMax = 0;
998 infoPtr->flags |= TB_SELECTIONCHANGED;
1000 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1002 return 0;
1006 static LRESULT
1007 TRACKBAR_ClearTics (TRACKBAR_INFO *infoPtr, BOOL fRedraw)
1009 if (infoPtr->tics) {
1010 Free (infoPtr->tics);
1011 infoPtr->tics = NULL;
1012 infoPtr->uNumTics = 0;
1015 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1017 return 0;
1021 static inline LRESULT
1022 TRACKBAR_GetChannelRect (const TRACKBAR_INFO *infoPtr, LPRECT lprc)
1024 if (lprc == NULL) return 0;
1026 lprc->left = infoPtr->rcChannel.left;
1027 lprc->right = infoPtr->rcChannel.right;
1028 lprc->bottom = infoPtr->rcChannel.bottom;
1029 lprc->top = infoPtr->rcChannel.top;
1031 return 0;
1035 static inline LONG
1036 TRACKBAR_GetNumTics (const TRACKBAR_INFO *infoPtr)
1038 if (infoPtr->dwStyle & TBS_NOTICKS) return 0;
1040 return infoPtr->uNumTics + 2;
1044 static int comp_tics (const void *ap, const void *bp)
1046 const DWORD a = *(const DWORD *)ap;
1047 const DWORD b = *(const DWORD *)bp;
1049 TRACE("(a=%d, b=%d)\n", a, b);
1050 if (a < b) return -1;
1051 if (a > b) return 1;
1052 return 0;
1056 static inline LONG
1057 TRACKBAR_GetTic (const TRACKBAR_INFO *infoPtr, INT iTic)
1059 if ((iTic < 0) || (iTic >= infoPtr->uNumTics) || !infoPtr->tics)
1060 return -1;
1062 qsort(infoPtr->tics, infoPtr->uNumTics, sizeof(DWORD), comp_tics);
1063 return infoPtr->tics[iTic];
1067 static inline LONG
1068 TRACKBAR_GetTicPos (const TRACKBAR_INFO *infoPtr, INT iTic)
1070 LONG range, width, pos, tic;
1071 int offsetthumb;
1073 if ((iTic < 0) || (iTic >= infoPtr->uNumTics) || !infoPtr->tics)
1074 return -1;
1076 tic = TRACKBAR_GetTic (infoPtr, iTic);
1077 range = infoPtr->lRangeMax - infoPtr->lRangeMin;
1078 if (range <= 0) range = 1;
1079 offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
1080 width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - offsetthumb*2;
1081 pos = infoPtr->rcChannel.left + offsetthumb + (width * tic) / range;
1083 return pos;
1087 static HWND
1088 TRACKBAR_SetBuddy (TRACKBAR_INFO *infoPtr, BOOL fLocation, HWND hwndBuddy)
1090 HWND hwndTemp;
1092 if (fLocation) {
1093 /* buddy is left or above */
1094 hwndTemp = infoPtr->hwndBuddyLA;
1095 infoPtr->hwndBuddyLA = hwndBuddy;
1097 else {
1098 /* buddy is right or below */
1099 hwndTemp = infoPtr->hwndBuddyRB;
1100 infoPtr->hwndBuddyRB = hwndBuddy;
1103 TRACKBAR_AlignBuddies (infoPtr);
1105 return hwndTemp;
1109 static inline LONG
1110 TRACKBAR_SetLineSize (TRACKBAR_INFO *infoPtr, LONG lLineSize)
1112 LONG lTemp = infoPtr->lLineSize;
1114 infoPtr->lLineSize = lLineSize;
1116 return lTemp;
1120 static inline LONG
1121 TRACKBAR_SetPageSize (TRACKBAR_INFO *infoPtr, LONG lPageSize)
1123 LONG lTemp = infoPtr->lPageSize;
1125 if (lPageSize != -1)
1126 infoPtr->lPageSize = lPageSize;
1127 else
1128 infoPtr->lPageSize = TB_DEFAULTPAGESIZE;
1130 return lTemp;
1134 static inline LRESULT
1135 TRACKBAR_SetPos (TRACKBAR_INFO *infoPtr, BOOL fPosition, LONG lPosition)
1137 LONG oldPos = infoPtr->lPos;
1138 infoPtr->lPos = lPosition;
1140 if (infoPtr->lPos < infoPtr->lRangeMin)
1141 infoPtr->lPos = infoPtr->lRangeMin;
1143 if (infoPtr->lPos > infoPtr->lRangeMax)
1144 infoPtr->lPos = infoPtr->lRangeMax;
1145 infoPtr->flags |= TB_THUMBPOSCHANGED;
1147 if (fPosition && oldPos != lPosition) TRACKBAR_InvalidateThumbMove(infoPtr, oldPos, lPosition);
1149 return 0;
1153 static inline LRESULT
1154 TRACKBAR_SetRange (TRACKBAR_INFO *infoPtr, BOOL fRedraw, LONG lRange)
1156 infoPtr->lRangeMin = (SHORT)LOWORD(lRange);
1157 infoPtr->lRangeMax = (SHORT)HIWORD(lRange);
1159 if (infoPtr->lPos < infoPtr->lRangeMin) {
1160 infoPtr->lPos = infoPtr->lRangeMin;
1161 infoPtr->flags |= TB_THUMBPOSCHANGED;
1164 if (infoPtr->lPos > infoPtr->lRangeMax) {
1165 infoPtr->lPos = infoPtr->lRangeMax;
1166 infoPtr->flags |= TB_THUMBPOSCHANGED;
1169 infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
1170 if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
1172 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1174 return 0;
1178 static inline LRESULT
1179 TRACKBAR_SetRangeMax (TRACKBAR_INFO *infoPtr, BOOL fRedraw, LONG lMax)
1181 infoPtr->lRangeMax = lMax;
1182 if (infoPtr->lPos > infoPtr->lRangeMax) {
1183 infoPtr->lPos = infoPtr->lRangeMax;
1184 infoPtr->flags |= TB_THUMBPOSCHANGED;
1187 infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
1188 if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
1190 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1192 return 0;
1196 static inline LRESULT
1197 TRACKBAR_SetRangeMin (TRACKBAR_INFO *infoPtr, BOOL fRedraw, LONG lMin)
1199 infoPtr->lRangeMin = lMin;
1200 if (infoPtr->lPos < infoPtr->lRangeMin) {
1201 infoPtr->lPos = infoPtr->lRangeMin;
1202 infoPtr->flags |= TB_THUMBPOSCHANGED;
1205 infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
1206 if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
1208 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1210 return 0;
1214 static inline LRESULT
1215 TRACKBAR_SetSel (TRACKBAR_INFO *infoPtr, BOOL fRedraw, LONG lSel)
1217 if (!(infoPtr->dwStyle & TBS_ENABLESELRANGE)){
1218 infoPtr->lSelMin = 0;
1219 infoPtr->lSelMax = 0;
1220 return 0;
1223 infoPtr->lSelMin = (SHORT)LOWORD(lSel);
1224 infoPtr->lSelMax = (SHORT)HIWORD(lSel);
1225 infoPtr->flags |= TB_SELECTIONCHANGED;
1227 if (infoPtr->lSelMin < infoPtr->lRangeMin)
1228 infoPtr->lSelMin = infoPtr->lRangeMin;
1229 if (infoPtr->lSelMax > infoPtr->lRangeMax)
1230 infoPtr->lSelMax = infoPtr->lRangeMax;
1232 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1234 return 0;
1238 static inline LRESULT
1239 TRACKBAR_SetSelEnd (TRACKBAR_INFO *infoPtr, BOOL fRedraw, LONG lEnd)
1241 if (!(infoPtr->dwStyle & TBS_ENABLESELRANGE)){
1242 infoPtr->lSelMax = 0;
1243 return 0;
1246 infoPtr->lSelMax = lEnd;
1247 infoPtr->flags |= TB_SELECTIONCHANGED;
1249 if (infoPtr->lSelMax > infoPtr->lRangeMax)
1250 infoPtr->lSelMax = infoPtr->lRangeMax;
1252 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1254 return 0;
1258 static inline LRESULT
1259 TRACKBAR_SetSelStart (TRACKBAR_INFO *infoPtr, BOOL fRedraw, LONG lStart)
1261 if (!(infoPtr->dwStyle & TBS_ENABLESELRANGE)){
1262 infoPtr->lSelMin = 0;
1263 return 0;
1266 infoPtr->lSelMin = lStart;
1267 infoPtr->flags |=TB_SELECTIONCHANGED;
1269 if (infoPtr->lSelMin < infoPtr->lRangeMin)
1270 infoPtr->lSelMin = infoPtr->lRangeMin;
1272 if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
1274 return 0;
1278 static inline LRESULT
1279 TRACKBAR_SetThumbLength (TRACKBAR_INFO *infoPtr, UINT iLength)
1281 if (infoPtr->dwStyle & TBS_FIXEDLENGTH) {
1282 infoPtr->uThumbLen = iLength;
1283 infoPtr->flags |= TB_THUMBSIZECHANGED;
1284 InvalidateRect (infoPtr->hwndSelf, &infoPtr->rcThumb, FALSE);
1287 return 0;
1291 static inline LRESULT
1292 TRACKBAR_SetTic (TRACKBAR_INFO *infoPtr, LONG lPos)
1294 if ((lPos < infoPtr->lRangeMin) || (lPos> infoPtr->lRangeMax))
1295 return FALSE;
1297 TRACE("lPos=%d\n", lPos);
1299 infoPtr->uNumTics++;
1300 infoPtr->tics=ReAlloc( infoPtr->tics,
1301 (infoPtr->uNumTics)*sizeof (DWORD));
1302 if (!infoPtr->tics) {
1303 infoPtr->uNumTics = 0;
1304 notify(infoPtr, NM_OUTOFMEMORY);
1305 return FALSE;
1307 infoPtr->tics[infoPtr->uNumTics-1] = lPos;
1309 TRACKBAR_InvalidateAll(infoPtr);
1311 return TRUE;
1315 static inline LRESULT
1316 TRACKBAR_SetTicFreq (TRACKBAR_INFO *infoPtr, WORD wFreq)
1318 if (infoPtr->dwStyle & TBS_AUTOTICKS) {
1319 infoPtr->uTicFreq = wFreq;
1320 TRACKBAR_RecalculateTics (infoPtr);
1321 TRACKBAR_InvalidateAll(infoPtr);
1324 return 0;
1328 static inline INT
1329 TRACKBAR_SetTipSide (TRACKBAR_INFO *infoPtr, INT fLocation)
1331 INT fTemp = infoPtr->fLocation;
1333 infoPtr->fLocation = fLocation;
1335 return fTemp;
1339 static inline LRESULT
1340 TRACKBAR_SetToolTips (TRACKBAR_INFO *infoPtr, HWND hwndTT)
1342 infoPtr->hwndToolTip = hwndTT;
1344 return 0;
1348 static inline BOOL
1349 TRACKBAR_SetUnicodeFormat (TRACKBAR_INFO *infoPtr, BOOL fUnicode)
1351 BOOL bTemp = infoPtr->bUnicode;
1353 infoPtr->bUnicode = fUnicode;
1355 return bTemp;
1359 static LRESULT
1360 TRACKBAR_InitializeThumb (TRACKBAR_INFO *infoPtr)
1362 RECT rect;
1363 int clientWidth, clientMetric;
1365 /* initial thumb length */
1366 clientMetric = (infoPtr->dwStyle & TBS_ENABLESELRANGE) ? 23 : 21;
1367 GetClientRect(infoPtr->hwndSelf,&rect);
1368 if (infoPtr->dwStyle & TBS_VERT) {
1369 clientWidth = rect.right - rect.left;
1370 } else {
1371 clientWidth = rect.bottom - rect.top;
1373 if (clientWidth >= clientMetric)
1374 infoPtr->uThumbLen = clientMetric;
1375 else
1376 infoPtr->uThumbLen = clientWidth > 9 ? clientWidth - 6 : 4;
1378 TRACKBAR_CalcChannel (infoPtr);
1379 TRACKBAR_UpdateThumb (infoPtr);
1380 infoPtr->flags &= ~TB_SELECTIONCHANGED;
1382 return 0;
1386 static LRESULT
1387 TRACKBAR_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
1389 TRACKBAR_INFO *infoPtr;
1391 infoPtr = Alloc (sizeof(TRACKBAR_INFO));
1392 if (!infoPtr) return -1;
1393 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
1395 /* set default values */
1396 infoPtr->hwndSelf = hwnd;
1397 infoPtr->dwStyle = lpcs->style;
1398 infoPtr->lRangeMin = 0;
1399 infoPtr->lRangeMax = 100;
1400 infoPtr->lLineSize = 1;
1401 infoPtr->lPageSize = TB_DEFAULTPAGESIZE;
1402 infoPtr->lSelMin = 0;
1403 infoPtr->lSelMax = 0;
1404 infoPtr->lPos = 0;
1405 infoPtr->fLocation = TBTS_TOP;
1406 infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
1407 infoPtr->uTicFreq = 1;
1408 infoPtr->tics = NULL;
1409 infoPtr->hwndNotify= lpcs->hwndParent;
1411 TRACKBAR_InitializeThumb (infoPtr);
1413 /* Create tooltip control */
1414 if (infoPtr->dwStyle & TBS_TOOLTIPS) {
1416 infoPtr->hwndToolTip =
1417 CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, WS_POPUP,
1418 CW_USEDEFAULT, CW_USEDEFAULT,
1419 CW_USEDEFAULT, CW_USEDEFAULT,
1420 hwnd, 0, 0, 0);
1422 if (infoPtr->hwndToolTip) {
1423 TTTOOLINFOW ti;
1424 ZeroMemory (&ti, sizeof(ti));
1425 ti.cbSize = sizeof(ti);
1426 ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
1427 ti.hwnd = hwnd;
1429 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 0, (LPARAM)&ti);
1433 OpenThemeData (hwnd, themeClass);
1435 return 0;
1439 static LRESULT
1440 TRACKBAR_Destroy (TRACKBAR_INFO *infoPtr)
1442 /* delete tooltip control */
1443 if (infoPtr->hwndToolTip)
1444 DestroyWindow (infoPtr->hwndToolTip);
1446 Free (infoPtr->tics);
1447 infoPtr->tics = NULL;
1449 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
1450 CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
1451 Free (infoPtr);
1453 return 0;
1457 static LRESULT
1458 TRACKBAR_KillFocus (TRACKBAR_INFO *infoPtr)
1460 TRACE("\n");
1461 infoPtr->bFocussed = FALSE;
1462 TRACKBAR_InvalidateAll(infoPtr);
1464 return 0;
1467 static LRESULT
1468 TRACKBAR_LButtonDown (TRACKBAR_INFO *infoPtr, INT x, INT y)
1470 POINT clickPoint;
1472 clickPoint.x = x;
1473 clickPoint.y = y;
1475 SetFocus(infoPtr->hwndSelf);
1477 if (PtInRect(&infoPtr->rcThumb, clickPoint)) {
1478 infoPtr->flags |= TB_DRAG_MODE;
1479 SetCapture (infoPtr->hwndSelf);
1480 TRACKBAR_UpdateToolTip (infoPtr);
1481 TRACKBAR_ActivateToolTip (infoPtr, TRUE);
1482 TRACKBAR_InvalidateThumb(infoPtr, infoPtr->lPos);
1483 } else {
1484 LONG dir = TRACKBAR_GetAutoPageDirection(infoPtr, clickPoint);
1485 if (dir == 0) return 0;
1486 infoPtr->flags |= (dir < 0) ? TB_AUTO_PAGE_LEFT : TB_AUTO_PAGE_RIGHT;
1487 TRACKBAR_AutoPage (infoPtr, clickPoint);
1488 SetCapture (infoPtr->hwndSelf);
1489 SetTimer(infoPtr->hwndSelf, TB_REFRESH_TIMER, TB_REFRESH_DELAY, 0);
1492 return 0;
1496 static LRESULT
1497 TRACKBAR_LButtonUp (TRACKBAR_INFO *infoPtr)
1499 if (infoPtr->flags & TB_DRAG_MODE) {
1500 notify_with_scroll (infoPtr, TB_THUMBPOSITION | (infoPtr->lPos<<16));
1501 notify_with_scroll (infoPtr, TB_ENDTRACK);
1502 infoPtr->flags &= ~TB_DRAG_MODE;
1503 ReleaseCapture ();
1504 notify(infoPtr, NM_RELEASEDCAPTURE);
1505 TRACKBAR_ActivateToolTip(infoPtr, FALSE);
1506 TRACKBAR_InvalidateThumb(infoPtr, infoPtr->lPos);
1508 if (infoPtr->flags & TB_AUTO_PAGE) {
1509 KillTimer (infoPtr->hwndSelf, TB_REFRESH_TIMER);
1510 infoPtr->flags &= ~TB_AUTO_PAGE;
1511 notify_with_scroll (infoPtr, TB_ENDTRACK);
1512 ReleaseCapture ();
1513 notify(infoPtr, NM_RELEASEDCAPTURE);
1516 return 0;
1520 static LRESULT
1521 TRACKBAR_CaptureChanged (const TRACKBAR_INFO *infoPtr)
1523 notify_with_scroll (infoPtr, TB_ENDTRACK);
1524 return 0;
1528 static LRESULT
1529 TRACKBAR_Paint (TRACKBAR_INFO *infoPtr, HDC hdc)
1531 if (hdc) {
1532 TRACKBAR_Refresh(infoPtr, hdc);
1533 } else {
1534 PAINTSTRUCT ps;
1535 hdc = BeginPaint (infoPtr->hwndSelf, &ps);
1536 TRACKBAR_Refresh (infoPtr, hdc);
1537 EndPaint (infoPtr->hwndSelf, &ps);
1540 return 0;
1544 static LRESULT
1545 TRACKBAR_SetFocus (TRACKBAR_INFO *infoPtr)
1547 TRACE("\n");
1548 infoPtr->bFocussed = TRUE;
1549 TRACKBAR_InvalidateAll(infoPtr);
1551 return 0;
1555 static LRESULT
1556 TRACKBAR_Size (TRACKBAR_INFO *infoPtr)
1558 TRACKBAR_InitializeThumb (infoPtr);
1559 TRACKBAR_AlignBuddies (infoPtr);
1561 return 0;
1564 static LRESULT
1565 TRACKBAR_StyleChanged (TRACKBAR_INFO *infoPtr, WPARAM wStyleType,
1566 const STYLESTRUCT *lpss)
1568 if (wStyleType != GWL_STYLE) return 0;
1570 infoPtr->dwStyle = lpss->styleNew;
1572 return 0;
1575 static LRESULT
1576 TRACKBAR_Timer (TRACKBAR_INFO *infoPtr)
1578 if (infoPtr->flags & TB_AUTO_PAGE) {
1579 POINT pt;
1580 if (GetCursorPos(&pt))
1581 if (ScreenToClient(infoPtr->hwndSelf, &pt))
1582 TRACKBAR_AutoPage(infoPtr, pt);
1584 return 0;
1588 /* update theme after a WM_THEMECHANGED message */
1589 static LRESULT theme_changed (const TRACKBAR_INFO* infoPtr)
1591 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
1592 CloseThemeData (theme);
1593 OpenThemeData (infoPtr->hwndSelf, themeClass);
1594 return 0;
1598 static LRESULT
1599 TRACKBAR_MouseMove (TRACKBAR_INFO *infoPtr, INT x, INT y)
1601 INT clickPlace = (infoPtr->dwStyle & TBS_VERT) ? y : x;
1602 LONG dragPos, oldPos = infoPtr->lPos;
1604 TRACE("(x=%d. y=%d)\n", x, y);
1606 if (infoPtr->flags & TB_AUTO_PAGE) {
1607 POINT pt;
1608 pt.x = x;
1609 pt.y = y;
1610 TRACKBAR_AutoPage (infoPtr, pt);
1611 return TRUE;
1614 if (!(infoPtr->flags & TB_DRAG_MODE))
1616 if (GetWindowTheme (infoPtr->hwndSelf))
1618 DWORD oldFlags = infoPtr->flags;
1619 POINT pt;
1620 pt.x = x;
1621 pt.y = y;
1622 if (PtInRect (&infoPtr->rcThumb, pt))
1624 TRACKMOUSEEVENT tme;
1625 tme.cbSize = sizeof( tme );
1626 tme.dwFlags = TME_LEAVE;
1627 tme.hwndTrack = infoPtr->hwndSelf;
1628 TrackMouseEvent( &tme );
1629 infoPtr->flags |= TB_THUMB_HOT;
1631 else
1633 TRACKMOUSEEVENT tme;
1634 tme.cbSize = sizeof( tme );
1635 tme.dwFlags = TME_CANCEL;
1636 tme.hwndTrack = infoPtr->hwndSelf;
1637 TrackMouseEvent( &tme );
1638 infoPtr->flags &= ~TB_THUMB_HOT;
1640 if (oldFlags != infoPtr->flags) InvalidateRect (infoPtr->hwndSelf, &infoPtr->rcThumb, FALSE);
1642 return TRUE;
1645 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace);
1647 if (dragPos == oldPos) return TRUE;
1649 infoPtr->lPos = dragPos;
1651 infoPtr->flags |= TB_THUMBPOSCHANGED;
1652 notify_with_scroll (infoPtr, TB_THUMBTRACK | (infoPtr->lPos<<16));
1655 TRACKBAR_InvalidateThumbMove(infoPtr, oldPos, dragPos);
1656 UpdateWindow (infoPtr->hwndSelf);
1658 return TRUE;
1661 static BOOL
1662 TRACKBAR_KeyDown (TRACKBAR_INFO *infoPtr, INT nVirtKey)
1664 BOOL downIsLeft = infoPtr->dwStyle & TBS_DOWNISLEFT;
1665 BOOL vert = infoPtr->dwStyle & TBS_VERT;
1666 LONG pos = infoPtr->lPos;
1668 TRACE("%x\n", nVirtKey);
1670 switch (nVirtKey) {
1671 case VK_UP:
1672 if (!vert && downIsLeft) TRACKBAR_LineDown(infoPtr);
1673 else TRACKBAR_LineUp(infoPtr);
1674 break;
1675 case VK_LEFT:
1676 if (vert && downIsLeft) TRACKBAR_LineDown(infoPtr);
1677 else TRACKBAR_LineUp(infoPtr);
1678 break;
1679 case VK_DOWN:
1680 if (!vert && downIsLeft) TRACKBAR_LineUp(infoPtr);
1681 else TRACKBAR_LineDown(infoPtr);
1682 break;
1683 case VK_RIGHT:
1684 if (vert && downIsLeft) TRACKBAR_LineUp(infoPtr);
1685 else TRACKBAR_LineDown(infoPtr);
1686 break;
1687 case VK_NEXT:
1688 if (!vert && downIsLeft) TRACKBAR_PageUp(infoPtr);
1689 else TRACKBAR_PageDown(infoPtr);
1690 break;
1691 case VK_PRIOR:
1692 if (!vert && downIsLeft) TRACKBAR_PageDown(infoPtr);
1693 else TRACKBAR_PageUp(infoPtr);
1694 break;
1695 case VK_HOME:
1696 if (infoPtr->lPos == infoPtr->lRangeMin) return FALSE;
1697 infoPtr->lPos = infoPtr->lRangeMin;
1698 notify_with_scroll (infoPtr, TB_TOP);
1699 break;
1700 case VK_END:
1701 if (infoPtr->lPos == infoPtr->lRangeMax) return FALSE;
1702 infoPtr->lPos = infoPtr->lRangeMax;
1703 notify_with_scroll (infoPtr, TB_BOTTOM);
1704 break;
1707 if (pos != infoPtr->lPos) {
1708 infoPtr->flags |=TB_THUMBPOSCHANGED;
1709 TRACKBAR_InvalidateThumbMove (infoPtr, pos, infoPtr->lPos);
1712 return TRUE;
1716 static inline BOOL
1717 TRACKBAR_KeyUp (const TRACKBAR_INFO *infoPtr, INT nVirtKey)
1719 switch (nVirtKey) {
1720 case VK_LEFT:
1721 case VK_UP:
1722 case VK_RIGHT:
1723 case VK_DOWN:
1724 case VK_NEXT:
1725 case VK_PRIOR:
1726 case VK_HOME:
1727 case VK_END:
1728 notify_with_scroll (infoPtr, TB_ENDTRACK);
1730 return TRUE;
1734 static LRESULT WINAPI
1735 TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1737 TRACKBAR_INFO *infoPtr = (TRACKBAR_INFO *)GetWindowLongPtrW (hwnd, 0);
1739 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd, uMsg, wParam, lParam);
1741 if (!infoPtr && (uMsg != WM_CREATE))
1742 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
1744 switch (uMsg)
1746 case TBM_CLEARSEL:
1747 return TRACKBAR_ClearSel (infoPtr, (BOOL)wParam);
1749 case TBM_CLEARTICS:
1750 return TRACKBAR_ClearTics (infoPtr, (BOOL)wParam);
1752 case TBM_GETBUDDY:
1753 return (LRESULT)(wParam ? infoPtr->hwndBuddyLA : infoPtr->hwndBuddyRB);
1755 case TBM_GETCHANNELRECT:
1756 return TRACKBAR_GetChannelRect (infoPtr, (LPRECT)lParam);
1758 case TBM_GETLINESIZE:
1759 return infoPtr->lLineSize;
1761 case TBM_GETNUMTICS:
1762 return TRACKBAR_GetNumTics (infoPtr);
1764 case TBM_GETPAGESIZE:
1765 return infoPtr->lPageSize;
1767 case TBM_GETPOS:
1768 return infoPtr->lPos;
1770 case TBM_GETPTICS:
1771 return (LRESULT)infoPtr->tics;
1773 case TBM_GETRANGEMAX:
1774 return infoPtr->lRangeMax;
1776 case TBM_GETRANGEMIN:
1777 return infoPtr->lRangeMin;
1779 case TBM_GETSELEND:
1780 return infoPtr->lSelMax;
1782 case TBM_GETSELSTART:
1783 return infoPtr->lSelMin;
1785 case TBM_GETTHUMBLENGTH:
1786 return infoPtr->uThumbLen;
1788 case TBM_GETTHUMBRECT:
1789 return CopyRect((LPRECT)lParam, &infoPtr->rcThumb);
1791 case TBM_GETTIC:
1792 return TRACKBAR_GetTic (infoPtr, (INT)wParam);
1794 case TBM_GETTICPOS:
1795 return TRACKBAR_GetTicPos (infoPtr, (INT)wParam);
1797 case TBM_GETTOOLTIPS:
1798 return (LRESULT)infoPtr->hwndToolTip;
1800 case TBM_GETUNICODEFORMAT:
1801 return infoPtr->bUnicode;
1803 case TBM_SETBUDDY:
1804 return (LRESULT) TRACKBAR_SetBuddy(infoPtr, (BOOL)wParam, (HWND)lParam);
1806 case TBM_SETLINESIZE:
1807 return TRACKBAR_SetLineSize (infoPtr, (LONG)lParam);
1809 case TBM_SETPAGESIZE:
1810 return TRACKBAR_SetPageSize (infoPtr, (LONG)lParam);
1812 case TBM_SETPOS:
1813 return TRACKBAR_SetPos (infoPtr, (BOOL)wParam, (LONG)lParam);
1815 case TBM_SETRANGE:
1816 return TRACKBAR_SetRange (infoPtr, (BOOL)wParam, (LONG)lParam);
1818 case TBM_SETRANGEMAX:
1819 return TRACKBAR_SetRangeMax (infoPtr, (BOOL)wParam, (LONG)lParam);
1821 case TBM_SETRANGEMIN:
1822 return TRACKBAR_SetRangeMin (infoPtr, (BOOL)wParam, (LONG)lParam);
1824 case TBM_SETSEL:
1825 return TRACKBAR_SetSel (infoPtr, (BOOL)wParam, (LONG)lParam);
1827 case TBM_SETSELEND:
1828 return TRACKBAR_SetSelEnd (infoPtr, (BOOL)wParam, (LONG)lParam);
1830 case TBM_SETSELSTART:
1831 return TRACKBAR_SetSelStart (infoPtr, (BOOL)wParam, (LONG)lParam);
1833 case TBM_SETTHUMBLENGTH:
1834 return TRACKBAR_SetThumbLength (infoPtr, (UINT)wParam);
1836 case TBM_SETTIC:
1837 return TRACKBAR_SetTic (infoPtr, (LONG)lParam);
1839 case TBM_SETTICFREQ:
1840 return TRACKBAR_SetTicFreq (infoPtr, (WORD)wParam);
1842 case TBM_SETTIPSIDE:
1843 return TRACKBAR_SetTipSide (infoPtr, (INT)wParam);
1845 case TBM_SETTOOLTIPS:
1846 return TRACKBAR_SetToolTips (infoPtr, (HWND)wParam);
1848 case TBM_SETUNICODEFORMAT:
1849 return TRACKBAR_SetUnicodeFormat (infoPtr, (BOOL)wParam);
1852 case WM_CAPTURECHANGED:
1853 return TRACKBAR_CaptureChanged (infoPtr);
1855 case WM_CREATE:
1856 return TRACKBAR_Create (hwnd, (LPCREATESTRUCTW)lParam);
1858 case WM_DESTROY:
1859 return TRACKBAR_Destroy (infoPtr);
1861 /* case WM_ENABLE: */
1863 case WM_ERASEBKGND:
1864 return 0;
1866 case WM_GETDLGCODE:
1867 return DLGC_WANTARROWS;
1869 case WM_KEYDOWN:
1870 return TRACKBAR_KeyDown (infoPtr, (INT)wParam);
1872 case WM_KEYUP:
1873 return TRACKBAR_KeyUp (infoPtr, (INT)wParam);
1875 case WM_KILLFOCUS:
1876 return TRACKBAR_KillFocus (infoPtr);
1878 case WM_LBUTTONDOWN:
1879 return TRACKBAR_LButtonDown (infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1881 case WM_LBUTTONUP:
1882 return TRACKBAR_LButtonUp (infoPtr);
1884 case WM_MOUSELEAVE:
1885 infoPtr->flags &= ~TB_THUMB_HOT;
1886 InvalidateRect (infoPtr->hwndSelf, &infoPtr->rcThumb, FALSE);
1887 return 0;
1889 case WM_MOUSEMOVE:
1890 return TRACKBAR_MouseMove (infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1892 case WM_PRINTCLIENT:
1893 case WM_PAINT:
1894 return TRACKBAR_Paint (infoPtr, (HDC)wParam);
1896 case WM_SETFOCUS:
1897 return TRACKBAR_SetFocus (infoPtr);
1899 case WM_SIZE:
1900 return TRACKBAR_Size (infoPtr);
1902 case WM_STYLECHANGED:
1903 return TRACKBAR_StyleChanged (infoPtr, wParam, (LPSTYLESTRUCT)lParam);
1905 case WM_THEMECHANGED:
1906 return theme_changed (infoPtr);
1908 case WM_TIMER:
1909 return TRACKBAR_Timer (infoPtr);
1911 case WM_WININICHANGE:
1912 return TRACKBAR_InitializeThumb (infoPtr);
1914 default:
1915 if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
1916 ERR("unknown msg %04x wp=%08lx lp=%08lx\n", uMsg, wParam, lParam);
1917 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
1922 void TRACKBAR_Register (void)
1924 WNDCLASSW wndClass;
1926 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
1927 wndClass.style = CS_GLOBALCLASS;
1928 wndClass.lpfnWndProc = TRACKBAR_WindowProc;
1929 wndClass.cbClsExtra = 0;
1930 wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
1931 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
1932 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1933 wndClass.lpszClassName = TRACKBAR_CLASSW;
1935 RegisterClassW (&wndClass);
1939 void TRACKBAR_Unregister (void)
1941 UnregisterClassW (TRACKBAR_CLASSW, NULL);