4 * Copyright 1998, 1999 Eric Kohl <ekohl@abo.rhein-zeitung.de>
5 * Copyright 1998,1999 Alex Priem <alexp@sci.kun.nl>
10 * - more display code.
11 * - handle dragging slider better
12 * - better tic handling.
13 * - more notifications.
19 -TBM_SETRANGEMAX & TBM_SETRANGEMIN should only change the view of the
20 trackbar, not the actual amount of tics in the list.
21 -TBM_GETTIC & TBM_GETTICPOS shouldn't rely on infoPtr->tics being sorted.
22 - Make drawing code exact match of w95 drawing.
30 #include "debugtools.h"
32 DEFAULT_DEBUG_CHANNEL(trackbar)
35 #define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)GetWindowLongA (hwnd,0))
38 /* Used by TRACKBAR_Refresh to find out which parts of the control
39 need to be recalculated */
41 #define TB_THUMBPOSCHANGED 1
42 #define TB_THUMBSIZECHANGED 2
43 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBPOSCHANGED)
44 #define TB_SELECTIONCHANGED 4
45 #define TB_DRAG_MODE 16 /* we're dragging the slider */
46 #define TB_DRAGPOSVALID 32 /* current Position is in dragPos */
47 #define TB_SHOW_TOOLTIP 64 /* tooltip-style enabled and tooltip on */
49 /* helper defines for TRACKBAR_DrawTic */
50 #define TIC_LEFTEDGE 0x20
51 #define TIC_RIGHTEDGE 0x40
52 #define TIC_EDGE (TIC_LEFTEDGE | TIC_RIGHTEDGE)
53 #define TIC_SELECTIONMARKMAX 0x80
54 #define TIC_SELECTIONMARKMIN 0x100
55 #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
57 static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code);
59 static void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
63 if (infoPtr->uTicFreq && infoPtr->nRangeMax >= infoPtr->nRangeMin)
64 nrTics=(infoPtr->nRangeMax - infoPtr->nRangeMin)/infoPtr->uTicFreq;
67 COMCTL32_Free (infoPtr->tics);
73 if (nrTics!=infoPtr->uNumTics) {
74 infoPtr->tics=COMCTL32_ReAlloc (infoPtr->tics,
75 (nrTics+1)*sizeof (DWORD));
76 infoPtr->uNumTics=nrTics;
78 infoPtr->uNumTics=nrTics;
79 tic=infoPtr->nRangeMin+infoPtr->uTicFreq;
80 for (i=0; i<nrTics; i++,tic+=infoPtr->uTicFreq)
85 /* converts from physical (mouse) position to logical position
86 (in range of trackbar) */
89 TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place,
92 double range,width,pos;
94 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
96 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
97 pos=(range*(place - infoPtr->rcChannel.top)) / width;
99 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
100 pos=(range*(place - infoPtr->rcChannel.left)) / width;
103 if (pos > infoPtr->nRangeMax)
104 pos = infoPtr->nRangeMax;
105 else if (pos < infoPtr->nRangeMin)
106 pos = infoPtr->nRangeMin;
114 TRACKBAR_CalcChannel (HWND hwnd, TRACKBAR_INFO *infoPtr)
116 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
118 RECT lpRect,*channel = & infoPtr->rcChannel;
120 GetClientRect (hwnd, &lpRect);
122 if (dwStyle & TBS_ENABLESELRANGE)
123 cyChannel = MAX(infoPtr->uThumbLen - 8, 4);
127 if (dwStyle & TBS_VERT) {
128 channel->top = lpRect.top + 8;
129 channel->bottom = lpRect.bottom - 8;
131 if (dwStyle & TBS_BOTH) {
132 channel->left = (lpRect.right - cyChannel) / 2;
133 channel->right = (lpRect.right + cyChannel) / 2;
135 else if (dwStyle & TBS_LEFT) {
136 channel->left = lpRect.left + 10;
137 channel->right = channel->left + cyChannel;
139 else { /* TBS_RIGHT */
140 channel->right = lpRect.right - 10;
141 channel->left = channel->right - cyChannel;
145 channel->left = lpRect.left + 8;
146 channel->right = lpRect.right - 8;
147 if (dwStyle & TBS_BOTH) {
148 channel->top = (lpRect.bottom - cyChannel) / 2;
149 channel->bottom = (lpRect.bottom + cyChannel) / 2;
151 else if (dwStyle & TBS_TOP) {
152 channel->top = lpRect.top + 10;
153 channel->bottom = channel->top + cyChannel;
155 else { /* TBS_BOTTOM */
156 channel->bottom = lpRect.bottom - 10;
157 channel->top = channel->bottom - cyChannel;
163 TRACKBAR_CalcThumb (HWND hwnd, TRACKBAR_INFO *infoPtr)
168 thumb=&infoPtr->rcThumb;
169 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
170 if (!range) return; /* FIXME: may this happen? */
171 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
172 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
173 thumb->left = infoPtr->rcChannel.left - 1;
174 thumb->right = infoPtr->rcChannel.left + infoPtr->uThumbLen - 8;
175 thumb->top = infoPtr->rcChannel.top +
176 (width*infoPtr->nPos)/range - 5;
177 thumb->bottom = thumb->top + infoPtr->uThumbLen/3;
180 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
181 thumb->left = infoPtr->rcChannel.left +
182 (width*infoPtr->nPos)/range - 5;
183 thumb->right = thumb->left + infoPtr->uThumbLen/3;
184 thumb->top = infoPtr->rcChannel.top - 1;
185 thumb->bottom = infoPtr->rcChannel.top + infoPtr->uThumbLen - 8;
190 TRACKBAR_CalcSelection (HWND hwnd, TRACKBAR_INFO *infoPtr)
195 selection= & infoPtr->rcSelection;
196 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
197 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
200 SetRectEmpty (selection);
202 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
203 selection->left = infoPtr->rcChannel.left +
204 (width*infoPtr->nSelMin)/range;
205 selection->right = infoPtr->rcChannel.left +
206 (width*infoPtr->nSelMax)/range;
207 selection->top = infoPtr->rcChannel.top + 2;
208 selection->bottom = infoPtr->rcChannel.bottom - 2;
210 selection->top = infoPtr->rcChannel.top +
211 (width*infoPtr->nSelMin)/range;
212 selection->bottom = infoPtr->rcChannel.top +
213 (width*infoPtr->nSelMax)/range;
214 selection->left = infoPtr->rcChannel.left + 2;
215 selection->right = infoPtr->rcChannel.right - 2;
219 /* Trackbar drawing code. I like my spaghetti done milanese. */
221 /* ticPos is in tic-units, not in pixels */
224 TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
225 int flags, COLORREF clrTic)
227 RECT rcChannel=infoPtr->rcChannel;
228 int x,y,width,range,side;
230 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
231 width=rcChannel.right - rcChannel.left;
233 if (flags & TBS_TOP) {
237 y=rcChannel.bottom+2;
241 if (flags & TIC_SELECTIONMARK) {
242 if (flags & TIC_SELECTIONMARKMIN)
243 x=rcChannel.left + (width*ticPos)/range - 1;
245 x=rcChannel.left + (width*ticPos)/range + 1;
247 SetPixel (hdc, x,y+6*side, clrTic);
248 SetPixel (hdc, x,y+7*side, clrTic);
252 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
253 x=rcChannel.left + (width*ticPos)/range;
254 SetPixel (hdc, x,y+5*side, clrTic);
255 SetPixel (hdc, x,y+6*side, clrTic);
256 SetPixel (hdc, x,y+7*side, clrTic);
259 if (flags & TIC_EDGE) {
260 if (flags & TIC_LEFTEDGE)
265 SetPixel (hdc, x,y+5*side, clrTic);
266 SetPixel (hdc, x,y+6*side, clrTic);
267 SetPixel (hdc, x,y+7*side, clrTic);
268 SetPixel (hdc, x,y+8*side, clrTic);
274 TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
275 int flags, COLORREF clrTic)
277 RECT rcChannel=infoPtr->rcChannel;
278 int x,y,width,range,side;
280 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
281 width=rcChannel.bottom - rcChannel.top;
283 if (flags & TBS_TOP) {
292 if (flags & TIC_SELECTIONMARK) {
293 if (flags & TIC_SELECTIONMARKMIN)
294 y=rcChannel.top + (width*ticPos)/range - 1;
296 y=rcChannel.top + (width*ticPos)/range + 1;
298 SetPixel (hdc, x+6*side, y, clrTic);
299 SetPixel (hdc, x+7*side, y, clrTic);
303 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
304 y=rcChannel.top + (width*ticPos)/range;
305 SetPixel (hdc, x+5*side, y, clrTic);
306 SetPixel (hdc, x+6*side, y, clrTic);
307 SetPixel (hdc, x+7*side, y, clrTic);
310 if (flags & TIC_EDGE) {
311 if (flags & TIC_LEFTEDGE)
316 SetPixel (hdc, x+5*side, y, clrTic);
317 SetPixel (hdc, x+6*side, y, clrTic);
318 SetPixel (hdc, x+7*side, y, clrTic);
319 SetPixel (hdc, x+8*side, y, clrTic);
326 TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
327 int flags, COLORREF clrTic)
330 if (flags & TBS_VERT) {
331 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
332 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos,
333 flags | TBS_TOP , clrTic);
334 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
335 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos, flags, clrTic);
339 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
340 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags | TBS_TOP , clrTic);
342 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
343 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags, clrTic);
349 TRACKBAR_Refresh (HWND hwnd, HDC hdc)
351 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
352 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
353 RECT rcClient, rcChannel, rcSelection;
354 HBRUSH hBrush = CreateSolidBrush (infoPtr->clrBk);
357 GetClientRect (hwnd, &rcClient);
358 hBrush = CreateSolidBrush (infoPtr->clrBk);
359 FillRect (hdc, &rcClient, hBrush);
360 DeleteObject (hBrush);
362 if (infoPtr->flags & TB_DRAGPOSVALID) {
363 infoPtr->nPos=infoPtr->dragPos;
364 infoPtr->flags |= TB_THUMBPOSCHANGED;
367 if (infoPtr->flags & TB_THUMBCHANGED) {
368 TRACKBAR_CalcThumb (hwnd, infoPtr);
369 if (infoPtr->flags & TB_THUMBSIZECHANGED)
370 TRACKBAR_CalcChannel (hwnd, infoPtr);
372 if (infoPtr->flags & TB_SELECTIONCHANGED)
373 TRACKBAR_CalcSelection (hwnd, infoPtr);
374 infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED |
379 rcChannel = infoPtr->rcChannel;
380 rcSelection= infoPtr->rcSelection;
381 DrawEdge (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
383 if (dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
384 HBRUSH hbr = CreateSolidBrush (RGB(255,255,255));
385 FillRect (hdc, &rcChannel, hbr);
386 if (((dwStyle & TBS_VERT) &&
387 (rcSelection.left!=rcSelection.right)) ||
388 ((!(dwStyle & TBS_VERT)) &&
389 (rcSelection.left!=rcSelection.right))) {
390 hbr=CreateSolidBrush (COLOR_HIGHLIGHT);
391 FillRect (hdc, &rcSelection, hbr);
399 if (!(dwStyle & TBS_NOTICKS)) {
400 int ticFlags = dwStyle & 0x0f;
401 COLORREF clrTic=GetSysColor (COLOR_3DDKSHADOW);
403 for (i=0; i<infoPtr->uNumTics; i++)
404 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->tics[i],
407 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_LEFTEDGE, clrTic);
408 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_RIGHTEDGE, clrTic);
410 if ((dwStyle & TBS_ENABLESELRANGE) &&
411 (rcSelection.left!=rcSelection.right)) {
412 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMin,
413 ticFlags | TIC_SELECTIONMARKMIN, clrTic);
414 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMax,
415 ticFlags | TIC_SELECTIONMARKMAX, clrTic);
421 if (!(dwStyle & TBS_NOTHUMB)) {
423 HBRUSH hbr = CreateSolidBrush (COLOR_BACKGROUND);
424 RECT thumb = infoPtr->rcThumb;
426 SelectObject (hdc, hbr);
428 if (dwStyle & TBS_BOTH) {
429 FillRect (hdc, &thumb, hbr);
430 DrawEdge (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
435 /* first, fill the thumb */
436 /* FIXME: revamp. check for TBS_VERT */
438 SetPolyFillMode (hdc,WINDING);
439 points[0].x=thumb.left;
440 points[0].y=thumb.top;
441 points[1].x=thumb.right - 1;
442 points[1].y=thumb.top;
443 points[2].x=thumb.right - 1;
444 points[2].y=thumb.bottom -2;
445 points[3].x=(thumb.right + thumb.left-1)/2;
446 points[3].y=thumb.bottom+4;
447 points[4].x=thumb.left;
448 points[4].y=thumb.bottom -2;
449 points[5].x=points[0].x;
450 points[5].y=points[0].y;
451 Polygon (hdc, points, 6);
453 if (dwStyle & TBS_VERT) {
456 RECT triangle; /* for correct shadows of thumb */
457 DrawEdge (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
461 triangle.right = thumb.right+5;
462 triangle.left = points[3].x+5;
463 triangle.top = thumb.bottom +5;
464 triangle.bottom= thumb.bottom +1;
465 DrawEdge (hdc, &triangle, EDGE_SUNKEN,
466 BF_DIAGONAL | BF_TOP | BF_RIGHT);
467 triangle.left = thumb.left+6;
468 triangle.right = points[3].x+6;
469 DrawEdge (hdc, &triangle, EDGE_RAISED,
470 BF_DIAGONAL | BF_TOP | BF_LEFT);
477 DrawFocusRect (hdc, &rcClient);
482 TRACKBAR_AlignBuddies (HWND hwnd, TRACKBAR_INFO *infoPtr)
484 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
485 HWND hwndParent = GetParent (hwnd);
486 RECT rcSelf, rcBuddy;
489 GetWindowRect (hwnd, &rcSelf);
490 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcSelf, 2);
492 /* align buddy left or above */
493 if (infoPtr->hwndBuddyLA) {
494 GetWindowRect (infoPtr->hwndBuddyLA, &rcBuddy);
495 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
497 if (dwStyle & TBS_VERT) {
498 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
499 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
500 y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
503 x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
504 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
505 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
508 SetWindowPos (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
509 SWP_NOZORDER | SWP_NOSIZE);
513 /* align buddy right or below */
514 if (infoPtr->hwndBuddyRB) {
515 GetWindowRect (infoPtr->hwndBuddyRB, &rcBuddy);
516 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
518 if (dwStyle & TBS_VERT) {
519 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
520 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
525 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
526 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
528 SetWindowPos (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
529 SWP_NOZORDER | SWP_NOSIZE);
535 TRACKBAR_ClearSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
537 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
539 infoPtr->nSelMin = 0;
540 infoPtr->nSelMax = 0;
541 infoPtr->flags |= TB_SELECTIONCHANGED;
544 InvalidateRect (hwnd, NULL, FALSE);
551 TRACKBAR_ClearTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
553 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
556 COMCTL32_Free (infoPtr->tics);
557 infoPtr->tics = NULL;
558 infoPtr->uNumTics = 0;
562 InvalidateRect (hwnd, NULL, FALSE);
569 TRACKBAR_GetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
571 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
573 if (wParam) /* buddy is left or above */
574 return (LRESULT)infoPtr->hwndBuddyLA;
576 /* buddy is right or below */
577 return (LRESULT) infoPtr->hwndBuddyRB;
582 TRACKBAR_GetChannelRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
584 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
585 LPRECT lprc = (LPRECT)lParam;
590 lprc->left = infoPtr->rcChannel.left;
591 lprc->right = infoPtr->rcChannel.right;
592 lprc->bottom = infoPtr->rcChannel.bottom;
593 lprc->top = infoPtr->rcChannel.top;
600 TRACKBAR_GetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
602 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
604 return infoPtr->nLineSize;
609 TRACKBAR_GetNumTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
611 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
613 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_NOTICKS)
616 return infoPtr->uNumTics+2;
621 TRACKBAR_GetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
623 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
625 return infoPtr->nPageSize;
630 TRACKBAR_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
632 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
634 return infoPtr->nPos;
639 TRACKBAR_GetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
641 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
643 return infoPtr->nRangeMax;
648 TRACKBAR_GetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
650 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
652 return infoPtr->nRangeMin;
657 TRACKBAR_GetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
659 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
661 return infoPtr->nSelMax;
666 TRACKBAR_GetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
668 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
670 return infoPtr->nSelMin;
675 TRACKBAR_GetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
677 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
679 return infoPtr->uThumbLen;
683 TRACKBAR_GetPTics (HWND hwnd)
685 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
687 return (LRESULT) infoPtr->tics;
691 TRACKBAR_GetThumbRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
693 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
694 LPRECT lprc = (LPRECT)lParam;
699 lprc->left = infoPtr->rcThumb.left;
700 lprc->right = infoPtr->rcThumb.right;
701 lprc->bottom = infoPtr->rcThumb.bottom;
702 lprc->top = infoPtr->rcThumb.top;
709 TRACKBAR_GetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
711 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
715 if ((iTic<0) || (iTic>infoPtr->uNumTics))
718 return (LRESULT) infoPtr->tics[iTic];
724 TRACKBAR_GetTicPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
726 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
727 INT iTic, range, width, pos;
731 if ((iTic<0) || (iTic>infoPtr->uNumTics))
734 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
735 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
736 pos=infoPtr->rcChannel.left + (width * infoPtr->tics[iTic]) / range;
739 return (LRESULT) pos;
744 TRACKBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
746 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
748 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
749 return (LRESULT)infoPtr->hwndToolTip;
754 /* case TBM_GETUNICODEFORMAT: */
758 TRACKBAR_SetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
760 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
764 /* buddy is left or above */
765 hwndTemp = infoPtr->hwndBuddyLA;
766 infoPtr->hwndBuddyLA = (HWND)lParam;
768 FIXME("move buddy!\n");
771 /* buddy is right or below */
772 hwndTemp = infoPtr->hwndBuddyRB;
773 infoPtr->hwndBuddyRB = (HWND)lParam;
775 FIXME("move buddy!\n");
778 TRACKBAR_AlignBuddies (hwnd, infoPtr);
780 return (LRESULT)hwndTemp;
785 TRACKBAR_SetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
787 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
788 INT nTemp = infoPtr->nLineSize;
790 infoPtr->nLineSize = (INT)lParam;
797 TRACKBAR_SetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
799 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
800 INT nTemp = infoPtr->nPageSize;
802 infoPtr->nPageSize = (INT)lParam;
809 TRACKBAR_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
811 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
813 infoPtr->nPos = (INT)LOWORD(lParam);
815 if (infoPtr->nPos < infoPtr->nRangeMin)
816 infoPtr->nPos = infoPtr->nRangeMin;
818 if (infoPtr->nPos > infoPtr->nRangeMax)
819 infoPtr->nPos = infoPtr->nRangeMax;
820 infoPtr->flags |= TB_THUMBPOSCHANGED;
823 InvalidateRect (hwnd, NULL, FALSE);
830 TRACKBAR_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
832 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
833 infoPtr->nRangeMin = (INT)LOWORD(lParam);
834 infoPtr->nRangeMax = (INT)HIWORD(lParam);
836 if (infoPtr->nPos < infoPtr->nRangeMin) {
837 infoPtr->nPos = infoPtr->nRangeMin;
838 infoPtr->flags |=TB_THUMBPOSCHANGED;
841 if (infoPtr->nPos > infoPtr->nRangeMax) {
842 infoPtr->nPos = infoPtr->nRangeMax;
843 infoPtr->flags |=TB_THUMBPOSCHANGED;
846 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
847 if (infoPtr->nPageSize == 0)
848 infoPtr->nPageSize = 1;
849 TRACKBAR_RecalculateTics (infoPtr);
852 InvalidateRect (hwnd, NULL, FALSE);
859 TRACKBAR_SetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
861 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
863 infoPtr->nRangeMax = (INT)lParam;
864 if (infoPtr->nPos > infoPtr->nRangeMax) {
865 infoPtr->nPos = infoPtr->nRangeMax;
866 infoPtr->flags |=TB_THUMBPOSCHANGED;
869 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
870 if (infoPtr->nPageSize == 0)
871 infoPtr->nPageSize = 1;
872 TRACKBAR_RecalculateTics (infoPtr);
875 InvalidateRect (hwnd, NULL, FALSE);
882 TRACKBAR_SetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
884 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
886 infoPtr->nRangeMin = (INT)lParam;
887 if (infoPtr->nPos < infoPtr->nRangeMin) {
888 infoPtr->nPos = infoPtr->nRangeMin;
889 infoPtr->flags |=TB_THUMBPOSCHANGED;
892 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
893 if (infoPtr->nPageSize == 0)
894 infoPtr->nPageSize = 1;
895 TRACKBAR_RecalculateTics (infoPtr);
898 InvalidateRect (hwnd, NULL, FALSE);
905 TRACKBAR_SetTicFreq (HWND hwnd, WPARAM wParam)
907 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
909 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_AUTOTICKS)
910 infoPtr->uTicFreq=(UINT) wParam;
912 TRACKBAR_RecalculateTics (infoPtr);
914 InvalidateRect (hwnd, NULL, FALSE);
921 TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
923 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
925 infoPtr->nSelMin = (INT)LOWORD(lParam);
926 infoPtr->nSelMax = (INT)HIWORD(lParam);
927 infoPtr->flags |=TB_SELECTIONCHANGED;
929 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
932 if (infoPtr->nSelMin < infoPtr->nRangeMin)
933 infoPtr->nSelMin = infoPtr->nRangeMin;
934 if (infoPtr->nSelMax > infoPtr->nRangeMax)
935 infoPtr->nSelMax = infoPtr->nRangeMax;
938 InvalidateRect (hwnd, NULL, FALSE);
946 TRACKBAR_SetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
948 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
950 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
953 infoPtr->nSelMax = (INT)lParam;
954 infoPtr->flags |= TB_SELECTIONCHANGED;
956 if (infoPtr->nSelMax > infoPtr->nRangeMax)
957 infoPtr->nSelMax = infoPtr->nRangeMax;
960 InvalidateRect (hwnd, NULL, FALSE);
967 TRACKBAR_SetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
969 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
971 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
974 infoPtr->nSelMin = (INT)lParam;
975 infoPtr->flags |=TB_SELECTIONCHANGED;
977 if (infoPtr->nSelMin < infoPtr->nRangeMin)
978 infoPtr->nSelMin = infoPtr->nRangeMin;
981 InvalidateRect (hwnd, NULL, FALSE);
988 TRACKBAR_SetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
990 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
992 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_FIXEDLENGTH)
993 infoPtr->uThumbLen = (UINT)wParam;
995 infoPtr->flags |= TB_THUMBSIZECHANGED;
997 InvalidateRect (hwnd, NULL, FALSE);
1004 TRACKBAR_SetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
1006 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1007 INT nPos = (INT)lParam;
1009 if ((nPos < infoPtr->nRangeMin) || (nPos> infoPtr->nRangeMax))
1012 infoPtr->uNumTics++;
1013 infoPtr->tics=COMCTL32_ReAlloc( infoPtr->tics,
1014 (infoPtr->uNumTics)*sizeof (DWORD));
1015 infoPtr->tics[infoPtr->uNumTics-1]=nPos;
1017 InvalidateRect (hwnd, NULL, FALSE);
1024 TRACKBAR_SetTipSide (HWND hwnd, WPARAM wParam, LPARAM lParam)
1026 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1027 INT fTemp = infoPtr->fLocation;
1029 infoPtr->fLocation = (INT)wParam;
1036 TRACKBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1038 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1040 infoPtr->hwndToolTip = (HWND)wParam;
1046 /* case TBM_SETUNICODEFORMAT: */
1050 TRACKBAR_InitializeThumb (HWND hwnd)
1052 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1054 infoPtr->uThumbLen = 23; /* initial thumb length */
1056 TRACKBAR_CalcChannel (hwnd,infoPtr);
1057 TRACKBAR_CalcThumb (hwnd, infoPtr);
1058 infoPtr->flags &= ~TB_SELECTIONCHANGED;
1065 TRACKBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1067 TRACKBAR_INFO *infoPtr;
1069 infoPtr = (TRACKBAR_INFO *)COMCTL32_Alloc (sizeof(TRACKBAR_INFO));
1070 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1072 /* set default values */
1073 infoPtr->nRangeMin = 0;
1074 infoPtr->nRangeMax = 100;
1075 infoPtr->nLineSize = 1;
1076 infoPtr->nPageSize = 20;
1077 infoPtr->nSelMin = 0;
1078 infoPtr->nSelMax = 0;
1081 infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
1082 infoPtr->uTicFreq = 1;
1083 infoPtr->tics = NULL;
1084 infoPtr->clrBk = GetSysColor (COLOR_BACKGROUND);
1085 infoPtr->hwndNotify = GetParent (hwnd);
1087 TRACKBAR_InitializeThumb (hwnd);
1089 /* Create tooltip control */
1090 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) {
1093 infoPtr->hwndToolTip =
1094 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
1095 CW_USEDEFAULT, CW_USEDEFAULT,
1096 CW_USEDEFAULT, CW_USEDEFAULT,
1099 /* Send NM_TOOLTIPSCREATED notification */
1100 if (infoPtr->hwndToolTip) {
1101 NMTOOLTIPSCREATED nmttc;
1103 nmttc.hdr.hwndFrom = hwnd;
1104 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1105 nmttc.hdr.code = NM_TOOLTIPSCREATED;
1106 nmttc.hwndToolTips = infoPtr->hwndToolTip;
1108 SendMessageA (GetParent (hwnd), WM_NOTIFY,
1109 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
1112 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1113 ti.cbSize = sizeof(TTTOOLINFOA);
1114 ti.uFlags = TTF_IDISHWND | TTF_TRACK;
1117 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */
1118 SetRectEmpty (&ti.rect);
1120 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
1128 TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1130 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1132 /* delete tooltip control */
1133 if (infoPtr->hwndToolTip)
1134 DestroyWindow (infoPtr->hwndToolTip);
1136 COMCTL32_Free (infoPtr);
1142 TRACKBAR_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1144 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1148 infoPtr->bFocus = FALSE;
1149 infoPtr->flags &= ~TB_DRAG_MODE;
1151 InvalidateRect (hwnd, NULL, FALSE);
1158 TRACKBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1160 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1161 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1162 int clickPlace,prevPos,vertical;
1167 vertical = dwStyle & TBS_VERT;
1169 clickPlace=(INT)HIWORD(lParam);
1171 clickPlace=(INT)LOWORD(lParam);
1174 (clickPlace>infoPtr->rcThumb.top) &&
1175 (clickPlace<infoPtr->rcThumb.bottom)) ||
1177 (clickPlace>infoPtr->rcThumb.left) &&
1178 (clickPlace<infoPtr->rcThumb.right))) {
1179 infoPtr->flags |= TB_DRAG_MODE;
1180 if (dwStyle & TBS_TOOLTIPS) { /* enable tooltip */
1185 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,
1186 (LPARAM)MAKELPARAM(pt.x, pt.y));
1188 ti.cbSize = sizeof(TTTOOLINFOA);
1190 ti.hwnd = (UINT)hwnd;
1192 infoPtr->flags |= TB_SHOW_TOOLTIP;
1194 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1195 (WPARAM)TRUE, (LPARAM)&ti);
1200 clickPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, vertical);
1201 prevPos = infoPtr->nPos;
1203 if (clickPos > prevPos) { /* similar to VK_NEXT */
1204 infoPtr->nPos += infoPtr->nPageSize;
1205 if (infoPtr->nPos > infoPtr->nRangeMax)
1206 infoPtr->nPos = infoPtr->nRangeMax;
1207 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1209 infoPtr->nPos -= infoPtr->nPageSize; /* similar to VK_PRIOR */
1210 if (infoPtr->nPos < infoPtr->nRangeMin)
1211 infoPtr->nPos = infoPtr->nRangeMin;
1212 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1215 if (prevPos!=infoPtr->nPos) {
1216 infoPtr->flags |= TB_THUMBPOSCHANGED;
1217 InvalidateRect (hwnd, NULL, FALSE);
1225 TRACKBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
1227 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1229 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1231 if (infoPtr->flags & TB_DRAG_MODE)
1233 infoPtr->flags &= ~TB_DRAG_MODE;
1237 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) { /* disable tooltip */
1240 ti.cbSize = sizeof(TTTOOLINFOA);
1242 ti.hwnd = (UINT)hwnd;
1244 infoPtr->flags &= ~TB_SHOW_TOOLTIP;
1245 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1246 (WPARAM)FALSE, (LPARAM)&ti);
1249 InvalidateRect (hwnd, NULL, FALSE);
1256 TRACKBAR_CaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
1258 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1260 if (infoPtr->flags & TB_DRAGPOSVALID) {
1261 infoPtr->nPos=infoPtr->dragPos;
1262 InvalidateRect (hwnd, NULL, FALSE);
1265 infoPtr->flags &= ~ TB_DRAGPOSVALID;
1267 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1273 TRACKBAR_Paint (HWND hwnd, WPARAM wParam)
1278 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1279 TRACKBAR_Refresh (hwnd, hdc);
1281 EndPaint (hwnd, &ps);
1287 TRACKBAR_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1289 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1292 infoPtr->bFocus = TRUE;
1294 InvalidateRect (hwnd, NULL, FALSE);
1301 TRACKBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1303 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1305 TRACKBAR_CalcChannel (hwnd, infoPtr);
1306 TRACKBAR_AlignBuddies (hwnd, infoPtr);
1313 TRACKBAR_SendNotify (HWND hwnd, UINT code)
1317 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT)
1318 return (BOOL) SendMessageA (GetParent (hwnd),
1319 WM_VSCROLL, (WPARAM)code, (LPARAM)hwnd);
1321 return (BOOL) SendMessageA (GetParent (hwnd),
1322 WM_HSCROLL, (WPARAM)code, (LPARAM)hwnd);
1327 TRACKBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1329 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1330 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1335 TRACE("%x\n",wParam);
1337 if (dwStyle & TBS_VERT)
1338 clickPlace=(SHORT)HIWORD(lParam);
1340 clickPlace=(SHORT)LOWORD(lParam);
1342 if (!(infoPtr->flags & TB_DRAG_MODE))
1346 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace,
1347 dwStyle & TBS_VERT);
1348 if (dragPos > ((INT)dragPos) + 0.5)
1349 infoPtr->dragPos = dragPos + 1;
1351 infoPtr->dragPos = dragPos;
1353 infoPtr->flags |= TB_DRAGPOSVALID;
1354 TRACKBAR_SendNotify (hwnd, TB_THUMBTRACK | (infoPtr->nPos>>16));
1356 if (infoPtr->flags & TB_SHOW_TOOLTIP) {
1360 ti.cbSize = sizeof(TTTOOLINFOA);
1364 sprintf (buf,"%d",infoPtr->nPos);
1365 ti.lpszText = (LPSTR) buf;
1368 if (dwStyle & TBS_VERT) {
1369 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1370 0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15));
1372 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1373 0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5));
1375 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
1379 InvalidateRect (hwnd, NULL, FALSE);
1380 UpdateWindow (hwnd);
1387 TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1389 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1392 TRACE("%x\n",wParam);
1398 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1399 infoPtr->nPos -= infoPtr->nLineSize;
1400 if (infoPtr->nPos < infoPtr->nRangeMin)
1401 infoPtr->nPos = infoPtr->nRangeMin;
1402 TRACKBAR_SendNotify (hwnd, TB_LINEUP);
1406 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1407 infoPtr->nPos += infoPtr->nLineSize;
1408 if (infoPtr->nPos > infoPtr->nRangeMax)
1409 infoPtr->nPos = infoPtr->nRangeMax;
1410 TRACKBAR_SendNotify (hwnd, TB_LINEDOWN);
1413 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1414 infoPtr->nPos += infoPtr->nPageSize;
1415 if (infoPtr->nPos > infoPtr->nRangeMax)
1416 infoPtr->nPos = infoPtr->nRangeMax;
1417 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1420 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1421 infoPtr->nPos -= infoPtr->nPageSize;
1422 if (infoPtr->nPos < infoPtr->nRangeMin)
1423 infoPtr->nPos = infoPtr->nRangeMin;
1424 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1427 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1428 infoPtr->nPos = infoPtr->nRangeMin;
1429 TRACKBAR_SendNotify (hwnd, TB_TOP);
1432 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1433 infoPtr->nPos = infoPtr->nRangeMax;
1434 TRACKBAR_SendNotify (hwnd, TB_BOTTOM);
1438 if (pos!=infoPtr->nPos) {
1439 infoPtr->flags |=TB_THUMBPOSCHANGED;
1440 InvalidateRect (hwnd, NULL, FALSE);
1448 TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
1459 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1465 static LRESULT WINAPI
1466 TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1471 return TRACKBAR_ClearSel (hwnd, wParam, lParam);
1474 return TRACKBAR_ClearTics (hwnd, wParam, lParam);
1477 return TRACKBAR_GetBuddy (hwnd, wParam, lParam);
1479 case TBM_GETCHANNELRECT:
1480 return TRACKBAR_GetChannelRect (hwnd, wParam, lParam);
1482 case TBM_GETLINESIZE:
1483 return TRACKBAR_GetLineSize (hwnd, wParam, lParam);
1485 case TBM_GETNUMTICS:
1486 return TRACKBAR_GetNumTics (hwnd, wParam, lParam);
1488 case TBM_GETPAGESIZE:
1489 return TRACKBAR_GetPageSize (hwnd, wParam, lParam);
1492 return TRACKBAR_GetPos (hwnd, wParam, lParam);
1495 return TRACKBAR_GetPTics (hwnd);
1497 case TBM_GETRANGEMAX:
1498 return TRACKBAR_GetRangeMax (hwnd, wParam, lParam);
1500 case TBM_GETRANGEMIN:
1501 return TRACKBAR_GetRangeMin (hwnd, wParam, lParam);
1504 return TRACKBAR_GetSelEnd (hwnd, wParam, lParam);
1506 case TBM_GETSELSTART:
1507 return TRACKBAR_GetSelStart (hwnd, wParam, lParam);
1509 case TBM_GETTHUMBLENGTH:
1510 return TRACKBAR_GetThumbLength (hwnd, wParam, lParam);
1512 case TBM_GETTHUMBRECT:
1513 return TRACKBAR_GetThumbRect (hwnd, wParam, lParam);
1516 return TRACKBAR_GetTic (hwnd, wParam, lParam);
1519 return TRACKBAR_GetTicPos (hwnd, wParam, lParam);
1521 case TBM_GETTOOLTIPS:
1522 return TRACKBAR_GetToolTips (hwnd, wParam, lParam);
1524 /* case TBM_GETUNICODEFORMAT: */
1527 return TRACKBAR_SetBuddy (hwnd, wParam, lParam);
1529 case TBM_SETLINESIZE:
1530 return TRACKBAR_SetLineSize (hwnd, wParam, lParam);
1532 case TBM_SETPAGESIZE:
1533 return TRACKBAR_SetPageSize (hwnd, wParam, lParam);
1536 return TRACKBAR_SetPos (hwnd, wParam, lParam);
1539 return TRACKBAR_SetRange (hwnd, wParam, lParam);
1541 case TBM_SETRANGEMAX:
1542 return TRACKBAR_SetRangeMax (hwnd, wParam, lParam);
1544 case TBM_SETRANGEMIN:
1545 return TRACKBAR_SetRangeMin (hwnd, wParam, lParam);
1548 return TRACKBAR_SetSel (hwnd, wParam, lParam);
1551 return TRACKBAR_SetSelEnd (hwnd, wParam, lParam);
1553 case TBM_SETSELSTART:
1554 return TRACKBAR_SetSelStart (hwnd, wParam, lParam);
1556 case TBM_SETTHUMBLENGTH:
1557 return TRACKBAR_SetThumbLength (hwnd, wParam, lParam);
1560 return TRACKBAR_SetTic (hwnd, wParam, lParam);
1562 case TBM_SETTICFREQ:
1563 return TRACKBAR_SetTicFreq (hwnd, wParam);
1565 case TBM_SETTIPSIDE:
1566 return TRACKBAR_SetTipSide (hwnd, wParam, lParam);
1568 case TBM_SETTOOLTIPS:
1569 return TRACKBAR_SetToolTips (hwnd, wParam, lParam);
1571 /* case TBM_SETUNICODEFORMAT: */
1574 case WM_CAPTURECHANGED:
1575 return TRACKBAR_CaptureChanged (hwnd, wParam, lParam);
1578 return TRACKBAR_Create (hwnd, wParam, lParam);
1581 return TRACKBAR_Destroy (hwnd, wParam, lParam);
1583 /* case WM_ENABLE: */
1585 /* case WM_ERASEBKGND: */
1589 return DLGC_WANTARROWS;
1592 return TRACKBAR_KeyDown (hwnd, wParam, lParam);
1595 return TRACKBAR_KeyUp (hwnd, wParam);
1598 return TRACKBAR_KillFocus (hwnd, wParam, lParam);
1600 case WM_LBUTTONDOWN:
1601 return TRACKBAR_LButtonDown (hwnd, wParam, lParam);
1604 return TRACKBAR_LButtonUp (hwnd, wParam, lParam);
1607 return TRACKBAR_MouseMove (hwnd, wParam, lParam);
1610 return TRACKBAR_Paint (hwnd, wParam);
1613 return TRACKBAR_SetFocus (hwnd, wParam, lParam);
1616 return TRACKBAR_Size (hwnd, wParam, lParam);
1618 case WM_WININICHANGE:
1619 return TRACKBAR_InitializeThumb (hwnd);
1622 if (uMsg >= WM_USER)
1623 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
1624 uMsg, wParam, lParam);
1625 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1632 TRACKBAR_Register (void)
1636 if (GlobalFindAtomA (TRACKBAR_CLASSA)) return;
1638 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1639 wndClass.style = CS_GLOBALCLASS;
1640 wndClass.lpfnWndProc = (WNDPROC)TRACKBAR_WindowProc;
1641 wndClass.cbClsExtra = 0;
1642 wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
1643 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
1644 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1645 wndClass.lpszClassName = TRACKBAR_CLASSA;
1647 RegisterClassA (&wndClass);
1652 TRACKBAR_Unregister (void)
1654 if (GlobalFindAtomA (TRACKBAR_CLASSA))
1655 UnregisterClassA (TRACKBAR_CLASSA, (HINSTANCE)NULL);