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 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 (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
171 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
172 thumb->left = infoPtr->rcChannel.left - 1;
173 thumb->right = infoPtr->rcChannel.left + infoPtr->uThumbLen - 8;
174 thumb->top = infoPtr->rcChannel.top +
175 (width*infoPtr->nPos)/range - 5;
176 thumb->bottom = thumb->top + infoPtr->uThumbLen/3;
179 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
180 thumb->left = infoPtr->rcChannel.left +
181 (width*infoPtr->nPos)/range - 5;
182 thumb->right = thumb->left + infoPtr->uThumbLen/3;
183 thumb->top = infoPtr->rcChannel.top - 1;
184 thumb->bottom = infoPtr->rcChannel.top + infoPtr->uThumbLen - 8;
189 TRACKBAR_CalcSelection (HWND hwnd, TRACKBAR_INFO *infoPtr)
194 selection= & infoPtr->rcSelection;
195 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
196 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
199 SetRectEmpty (selection);
201 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
202 selection->left = infoPtr->rcChannel.left +
203 (width*infoPtr->nSelMin)/range;
204 selection->right = infoPtr->rcChannel.left +
205 (width*infoPtr->nSelMax)/range;
206 selection->top = infoPtr->rcChannel.top + 2;
207 selection->bottom = infoPtr->rcChannel.bottom - 2;
209 selection->top = infoPtr->rcChannel.top +
210 (width*infoPtr->nSelMin)/range;
211 selection->bottom = infoPtr->rcChannel.top +
212 (width*infoPtr->nSelMax)/range;
213 selection->left = infoPtr->rcChannel.left + 2;
214 selection->right = infoPtr->rcChannel.right - 2;
218 /* Trackbar drawing code. I like my spaghetti done milanese. */
220 /* ticPos is in tic-units, not in pixels */
223 TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
224 int flags, COLORREF clrTic)
226 RECT rcChannel=infoPtr->rcChannel;
227 int x,y,width,range,side;
229 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
230 width=rcChannel.right - rcChannel.left;
232 if (flags & TBS_TOP) {
236 y=rcChannel.bottom+2;
240 if (flags & TIC_SELECTIONMARK) {
241 if (flags & TIC_SELECTIONMARKMIN)
242 x=rcChannel.left + (width*ticPos)/range - 1;
244 x=rcChannel.left + (width*ticPos)/range + 1;
246 SetPixel (hdc, x,y+6*side, clrTic);
247 SetPixel (hdc, x,y+7*side, clrTic);
251 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
252 x=rcChannel.left + (width*ticPos)/range;
253 SetPixel (hdc, x,y+5*side, clrTic);
254 SetPixel (hdc, x,y+6*side, clrTic);
255 SetPixel (hdc, x,y+7*side, clrTic);
258 if (flags & TIC_EDGE) {
259 if (flags & TIC_LEFTEDGE)
264 SetPixel (hdc, x,y+5*side, clrTic);
265 SetPixel (hdc, x,y+6*side, clrTic);
266 SetPixel (hdc, x,y+7*side, clrTic);
267 SetPixel (hdc, x,y+8*side, clrTic);
273 TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
274 int flags, COLORREF clrTic)
276 RECT rcChannel=infoPtr->rcChannel;
277 int x,y,width,range,side;
279 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
280 width=rcChannel.bottom - rcChannel.top;
282 if (flags & TBS_TOP) {
291 if (flags & TIC_SELECTIONMARK) {
292 if (flags & TIC_SELECTIONMARKMIN)
293 y=rcChannel.top + (width*ticPos)/range - 1;
295 y=rcChannel.top + (width*ticPos)/range + 1;
297 SetPixel (hdc, x+6*side, y, clrTic);
298 SetPixel (hdc, x+7*side, y, clrTic);
302 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
303 y=rcChannel.top + (width*ticPos)/range;
304 SetPixel (hdc, x+5*side, y, clrTic);
305 SetPixel (hdc, x+6*side, y, clrTic);
306 SetPixel (hdc, x+7*side, y, clrTic);
309 if (flags & TIC_EDGE) {
310 if (flags & TIC_LEFTEDGE)
315 SetPixel (hdc, x+5*side, y, clrTic);
316 SetPixel (hdc, x+6*side, y, clrTic);
317 SetPixel (hdc, x+7*side, y, clrTic);
318 SetPixel (hdc, x+8*side, y, clrTic);
325 TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
326 int flags, COLORREF clrTic)
329 if (flags & TBS_VERT) {
330 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
331 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos,
332 flags | TBS_TOP , clrTic);
333 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
334 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos, flags, clrTic);
338 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
339 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags | TBS_TOP , clrTic);
341 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
342 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags, clrTic);
348 TRACKBAR_Refresh (HWND hwnd, HDC hdc)
350 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
351 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
352 RECT rcClient, rcChannel, rcSelection;
353 HBRUSH hBrush = CreateSolidBrush (infoPtr->clrBk);
356 GetClientRect (hwnd, &rcClient);
357 hBrush = CreateSolidBrush (infoPtr->clrBk);
358 FillRect (hdc, &rcClient, hBrush);
359 DeleteObject (hBrush);
361 if (infoPtr->flags & TB_DRAGPOSVALID) {
362 infoPtr->nPos=infoPtr->dragPos;
363 infoPtr->flags |= TB_THUMBPOSCHANGED;
366 if (infoPtr->flags & TB_THUMBCHANGED) {
367 TRACKBAR_CalcThumb (hwnd, infoPtr);
368 if (infoPtr->flags & TB_THUMBSIZECHANGED)
369 TRACKBAR_CalcChannel (hwnd, infoPtr);
371 if (infoPtr->flags & TB_SELECTIONCHANGED)
372 TRACKBAR_CalcSelection (hwnd, infoPtr);
373 infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED |
378 rcChannel = infoPtr->rcChannel;
379 rcSelection= infoPtr->rcSelection;
380 DrawEdge (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
382 if (dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
383 HBRUSH hbr = CreateSolidBrush (RGB(255,255,255));
384 FillRect (hdc, &rcChannel, hbr);
385 if (((dwStyle & TBS_VERT) &&
386 (rcSelection.left!=rcSelection.right)) ||
387 ((!(dwStyle & TBS_VERT)) &&
388 (rcSelection.left!=rcSelection.right))) {
389 hbr=CreateSolidBrush (COLOR_HIGHLIGHT);
390 FillRect (hdc, &rcSelection, hbr);
398 if (!(dwStyle & TBS_NOTICKS)) {
399 int ticFlags = dwStyle & 0x0f;
400 COLORREF clrTic=GetSysColor (COLOR_3DDKSHADOW);
402 for (i=0; i<infoPtr->uNumTics; i++)
403 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->tics[i],
406 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_LEFTEDGE, clrTic);
407 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_RIGHTEDGE, clrTic);
409 if ((dwStyle & TBS_ENABLESELRANGE) &&
410 (rcSelection.left!=rcSelection.right)) {
411 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMin,
412 ticFlags | TIC_SELECTIONMARKMIN, clrTic);
413 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMax,
414 ticFlags | TIC_SELECTIONMARKMAX, clrTic);
420 if (!(dwStyle & TBS_NOTHUMB)) {
422 HBRUSH hbr = CreateSolidBrush (COLOR_BACKGROUND);
423 RECT thumb = infoPtr->rcThumb;
425 SelectObject (hdc, hbr);
427 if (dwStyle & TBS_BOTH) {
428 FillRect (hdc, &thumb, hbr);
429 DrawEdge (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
434 /* first, fill the thumb */
435 /* FIXME: revamp. check for TBS_VERT */
437 SetPolyFillMode (hdc,WINDING);
438 points[0].x=thumb.left;
439 points[0].y=thumb.top;
440 points[1].x=thumb.right - 1;
441 points[1].y=thumb.top;
442 points[2].x=thumb.right - 1;
443 points[2].y=thumb.bottom -2;
444 points[3].x=(thumb.right + thumb.left-1)/2;
445 points[3].y=thumb.bottom+4;
446 points[4].x=thumb.left;
447 points[4].y=thumb.bottom -2;
448 points[5].x=points[0].x;
449 points[5].y=points[0].y;
450 Polygon (hdc, points, 6);
452 if (dwStyle & TBS_VERT) {
455 RECT triangle; /* for correct shadows of thumb */
456 DrawEdge (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
460 triangle.right = thumb.right+5;
461 triangle.left = points[3].x+5;
462 triangle.top = thumb.bottom +5;
463 triangle.bottom= thumb.bottom +1;
464 DrawEdge (hdc, &triangle, EDGE_SUNKEN,
465 BF_DIAGONAL | BF_TOP | BF_RIGHT);
466 triangle.left = thumb.left+6;
467 triangle.right = points[3].x+6;
468 DrawEdge (hdc, &triangle, EDGE_RAISED,
469 BF_DIAGONAL | BF_TOP | BF_LEFT);
476 DrawFocusRect (hdc, &rcClient);
481 TRACKBAR_AlignBuddies (HWND hwnd, TRACKBAR_INFO *infoPtr)
483 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
484 HWND hwndParent = GetParent (hwnd);
485 RECT rcSelf, rcBuddy;
488 GetWindowRect (hwnd, &rcSelf);
489 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcSelf, 2);
491 /* align buddy left or above */
492 if (infoPtr->hwndBuddyLA) {
493 GetWindowRect (infoPtr->hwndBuddyLA, &rcBuddy);
494 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
496 if (dwStyle & TBS_VERT) {
497 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
498 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
499 y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
502 x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
503 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
504 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
507 SetWindowPos (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
508 SWP_NOZORDER | SWP_NOSIZE);
512 /* align buddy right or below */
513 if (infoPtr->hwndBuddyRB) {
514 GetWindowRect (infoPtr->hwndBuddyRB, &rcBuddy);
515 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
517 if (dwStyle & TBS_VERT) {
518 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
519 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
524 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
525 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
527 SetWindowPos (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
528 SWP_NOZORDER | SWP_NOSIZE);
534 TRACKBAR_ClearSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
536 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
538 infoPtr->nSelMin = 0;
539 infoPtr->nSelMax = 0;
540 infoPtr->flags |= TB_SELECTIONCHANGED;
543 InvalidateRect (hwnd, NULL, FALSE);
550 TRACKBAR_ClearTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
552 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
555 COMCTL32_Free (infoPtr->tics);
556 infoPtr->tics = NULL;
557 infoPtr->uNumTics = 0;
561 InvalidateRect (hwnd, NULL, FALSE);
568 TRACKBAR_GetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
570 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
572 if (wParam) /* buddy is left or above */
573 return (LRESULT)infoPtr->hwndBuddyLA;
575 /* buddy is right or below */
576 return (LRESULT) infoPtr->hwndBuddyRB;
581 TRACKBAR_GetChannelRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
583 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
584 LPRECT lprc = (LPRECT)lParam;
589 lprc->left = infoPtr->rcChannel.left;
590 lprc->right = infoPtr->rcChannel.right;
591 lprc->bottom = infoPtr->rcChannel.bottom;
592 lprc->top = infoPtr->rcChannel.top;
599 TRACKBAR_GetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
601 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
603 return infoPtr->nLineSize;
608 TRACKBAR_GetNumTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
610 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
612 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_NOTICKS)
615 return infoPtr->uNumTics+2;
620 TRACKBAR_GetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
622 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
624 return infoPtr->nPageSize;
629 TRACKBAR_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
631 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
633 return infoPtr->nPos;
638 TRACKBAR_GetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
640 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
642 return infoPtr->nRangeMax;
647 TRACKBAR_GetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
649 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
651 return infoPtr->nRangeMin;
656 TRACKBAR_GetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
658 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
660 return infoPtr->nSelMax;
665 TRACKBAR_GetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
667 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
669 return infoPtr->nSelMin;
674 TRACKBAR_GetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
676 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
678 return infoPtr->uThumbLen;
682 TRACKBAR_GetPTics (HWND hwnd)
684 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
686 return (LRESULT) infoPtr->tics;
690 TRACKBAR_GetThumbRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
692 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
693 LPRECT lprc = (LPRECT)lParam;
698 lprc->left = infoPtr->rcThumb.left;
699 lprc->right = infoPtr->rcThumb.right;
700 lprc->bottom = infoPtr->rcThumb.bottom;
701 lprc->top = infoPtr->rcThumb.top;
708 TRACKBAR_GetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
710 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
714 if ((iTic<0) || (iTic>infoPtr->uNumTics))
717 return (LRESULT) infoPtr->tics[iTic];
723 TRACKBAR_GetTicPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
725 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
726 INT iTic, range, width, pos;
730 if ((iTic<0) || (iTic>infoPtr->uNumTics))
733 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
734 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
735 pos=infoPtr->rcChannel.left + (width * infoPtr->tics[iTic]) / range;
738 return (LRESULT) pos;
743 TRACKBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
745 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
747 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
748 return (LRESULT)infoPtr->hwndToolTip;
753 /* case TBM_GETUNICODEFORMAT: */
757 TRACKBAR_SetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
759 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
763 /* buddy is left or above */
764 hwndTemp = infoPtr->hwndBuddyLA;
765 infoPtr->hwndBuddyLA = (HWND)lParam;
767 FIXME("move buddy!\n");
770 /* buddy is right or below */
771 hwndTemp = infoPtr->hwndBuddyRB;
772 infoPtr->hwndBuddyRB = (HWND)lParam;
774 FIXME("move buddy!\n");
777 TRACKBAR_AlignBuddies (hwnd, infoPtr);
779 return (LRESULT)hwndTemp;
784 TRACKBAR_SetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
786 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
787 INT nTemp = infoPtr->nLineSize;
789 infoPtr->nLineSize = (INT)lParam;
796 TRACKBAR_SetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
798 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
799 INT nTemp = infoPtr->nPageSize;
801 infoPtr->nPageSize = (INT)lParam;
808 TRACKBAR_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
810 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
812 infoPtr->nPos = (INT)LOWORD(lParam);
814 if (infoPtr->nPos < infoPtr->nRangeMin)
815 infoPtr->nPos = infoPtr->nRangeMin;
817 if (infoPtr->nPos > infoPtr->nRangeMax)
818 infoPtr->nPos = infoPtr->nRangeMax;
819 infoPtr->flags |= TB_THUMBPOSCHANGED;
822 InvalidateRect (hwnd, NULL, FALSE);
829 TRACKBAR_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
831 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
832 infoPtr->nRangeMin = (INT)LOWORD(lParam);
833 infoPtr->nRangeMax = (INT)HIWORD(lParam);
835 if (infoPtr->nPos < infoPtr->nRangeMin) {
836 infoPtr->nPos = infoPtr->nRangeMin;
837 infoPtr->flags |=TB_THUMBPOSCHANGED;
840 if (infoPtr->nPos > infoPtr->nRangeMax) {
841 infoPtr->nPos = infoPtr->nRangeMax;
842 infoPtr->flags |=TB_THUMBPOSCHANGED;
845 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
846 if (infoPtr->nPageSize == 0)
847 infoPtr->nPageSize = 1;
848 TRACKBAR_RecalculateTics (infoPtr);
851 InvalidateRect (hwnd, NULL, FALSE);
858 TRACKBAR_SetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
860 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
862 infoPtr->nRangeMax = (INT)lParam;
863 if (infoPtr->nPos > infoPtr->nRangeMax) {
864 infoPtr->nPos = infoPtr->nRangeMax;
865 infoPtr->flags |=TB_THUMBPOSCHANGED;
868 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
869 if (infoPtr->nPageSize == 0)
870 infoPtr->nPageSize = 1;
871 TRACKBAR_RecalculateTics (infoPtr);
874 InvalidateRect (hwnd, NULL, FALSE);
881 TRACKBAR_SetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
883 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
885 infoPtr->nRangeMin = (INT)lParam;
886 if (infoPtr->nPos < infoPtr->nRangeMin) {
887 infoPtr->nPos = infoPtr->nRangeMin;
888 infoPtr->flags |=TB_THUMBPOSCHANGED;
891 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
892 if (infoPtr->nPageSize == 0)
893 infoPtr->nPageSize = 1;
894 TRACKBAR_RecalculateTics (infoPtr);
897 InvalidateRect (hwnd, NULL, FALSE);
904 TRACKBAR_SetTicFreq (HWND hwnd, WPARAM wParam)
906 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
908 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_AUTOTICKS)
909 infoPtr->uTicFreq=(UINT) wParam;
911 TRACKBAR_RecalculateTics (infoPtr);
913 InvalidateRect (hwnd, NULL, FALSE);
920 TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
922 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
924 infoPtr->nSelMin = (INT)LOWORD(lParam);
925 infoPtr->nSelMax = (INT)HIWORD(lParam);
926 infoPtr->flags |=TB_SELECTIONCHANGED;
928 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
931 if (infoPtr->nSelMin < infoPtr->nRangeMin)
932 infoPtr->nSelMin = infoPtr->nRangeMin;
933 if (infoPtr->nSelMax > infoPtr->nRangeMax)
934 infoPtr->nSelMax = infoPtr->nRangeMax;
937 InvalidateRect (hwnd, NULL, FALSE);
945 TRACKBAR_SetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
947 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
949 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
952 infoPtr->nSelMax = (INT)lParam;
953 infoPtr->flags |= TB_SELECTIONCHANGED;
955 if (infoPtr->nSelMax > infoPtr->nRangeMax)
956 infoPtr->nSelMax = infoPtr->nRangeMax;
959 InvalidateRect (hwnd, NULL, FALSE);
966 TRACKBAR_SetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
968 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
970 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
973 infoPtr->nSelMin = (INT)lParam;
974 infoPtr->flags |=TB_SELECTIONCHANGED;
976 if (infoPtr->nSelMin < infoPtr->nRangeMin)
977 infoPtr->nSelMin = infoPtr->nRangeMin;
980 InvalidateRect (hwnd, NULL, FALSE);
987 TRACKBAR_SetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
989 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
991 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_FIXEDLENGTH)
992 infoPtr->uThumbLen = (UINT)wParam;
994 infoPtr->flags |= TB_THUMBSIZECHANGED;
996 InvalidateRect (hwnd, NULL, FALSE);
1003 TRACKBAR_SetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
1005 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1006 INT nPos = (INT)lParam;
1008 if ((nPos < infoPtr->nRangeMin) || (nPos> infoPtr->nRangeMax))
1011 infoPtr->uNumTics++;
1012 infoPtr->tics=COMCTL32_ReAlloc( infoPtr->tics,
1013 (infoPtr->uNumTics)*sizeof (DWORD));
1014 infoPtr->tics[infoPtr->uNumTics-1]=nPos;
1016 InvalidateRect (hwnd, NULL, FALSE);
1023 TRACKBAR_SetTipSide (HWND hwnd, WPARAM wParam, LPARAM lParam)
1025 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1026 INT fTemp = infoPtr->fLocation;
1028 infoPtr->fLocation = (INT)wParam;
1035 TRACKBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1037 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1039 infoPtr->hwndToolTip = (HWND)wParam;
1045 /* case TBM_SETUNICODEFORMAT: */
1049 TRACKBAR_InitializeThumb (HWND hwnd)
1051 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1053 infoPtr->uThumbLen = 23; /* initial thumb length */
1055 TRACKBAR_CalcChannel (hwnd,infoPtr);
1056 TRACKBAR_CalcThumb (hwnd, infoPtr);
1057 infoPtr->flags &= ~TB_SELECTIONCHANGED;
1064 TRACKBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1066 TRACKBAR_INFO *infoPtr;
1068 infoPtr = (TRACKBAR_INFO *)COMCTL32_Alloc (sizeof(TRACKBAR_INFO));
1069 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1071 /* set default values */
1072 infoPtr->nRangeMin = 0;
1073 infoPtr->nRangeMax = 100;
1074 infoPtr->nLineSize = 1;
1075 infoPtr->nPageSize = 20;
1076 infoPtr->nSelMin = 0;
1077 infoPtr->nSelMax = 0;
1080 infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
1081 infoPtr->uTicFreq = 1;
1082 infoPtr->tics = NULL;
1083 infoPtr->clrBk = GetSysColor (COLOR_BACKGROUND);
1084 infoPtr->hwndNotify = GetParent (hwnd);
1086 TRACKBAR_InitializeThumb (hwnd);
1088 /* Create tooltip control */
1089 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) {
1092 infoPtr->hwndToolTip =
1093 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
1094 CW_USEDEFAULT, CW_USEDEFAULT,
1095 CW_USEDEFAULT, CW_USEDEFAULT,
1098 /* Send NM_TOOLTIPSCREATED notification */
1099 if (infoPtr->hwndToolTip) {
1100 NMTOOLTIPSCREATED nmttc;
1102 nmttc.hdr.hwndFrom = hwnd;
1103 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1104 nmttc.hdr.code = NM_TOOLTIPSCREATED;
1105 nmttc.hwndToolTips = infoPtr->hwndToolTip;
1107 SendMessageA (GetParent (hwnd), WM_NOTIFY,
1108 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
1111 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1112 ti.cbSize = sizeof(TTTOOLINFOA);
1113 ti.uFlags = TTF_IDISHWND | TTF_TRACK;
1116 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */
1117 SetRectEmpty (&ti.rect);
1119 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
1127 TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1129 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1131 /* delete tooltip control */
1132 if (infoPtr->hwndToolTip)
1133 DestroyWindow (infoPtr->hwndToolTip);
1135 COMCTL32_Free (infoPtr);
1141 TRACKBAR_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1143 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1147 infoPtr->bFocus = FALSE;
1148 infoPtr->flags &= ~TB_DRAG_MODE;
1150 InvalidateRect (hwnd, NULL, FALSE);
1157 TRACKBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1159 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1160 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1161 int clickPlace,prevPos,vertical;
1166 vertical = dwStyle & TBS_VERT;
1168 clickPlace=(INT)HIWORD(lParam);
1170 clickPlace=(INT)LOWORD(lParam);
1173 (clickPlace>infoPtr->rcThumb.top) &&
1174 (clickPlace<infoPtr->rcThumb.bottom)) ||
1176 (clickPlace>infoPtr->rcThumb.left) &&
1177 (clickPlace<infoPtr->rcThumb.right))) {
1178 infoPtr->flags |= TB_DRAG_MODE;
1179 if (dwStyle & TBS_TOOLTIPS) { /* enable tooltip */
1184 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,
1185 (LPARAM)MAKELPARAM(pt.x, pt.y));
1187 ti.cbSize = sizeof(TTTOOLINFOA);
1189 ti.hwnd = (UINT)hwnd;
1191 infoPtr->flags |= TB_SHOW_TOOLTIP;
1193 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1194 (WPARAM)TRUE, (LPARAM)&ti);
1199 clickPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, vertical);
1200 prevPos = infoPtr->nPos;
1202 if (clickPos > prevPos) { /* similar to VK_NEXT */
1203 infoPtr->nPos += infoPtr->nPageSize;
1204 if (infoPtr->nPos > infoPtr->nRangeMax)
1205 infoPtr->nPos = infoPtr->nRangeMax;
1206 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1208 infoPtr->nPos -= infoPtr->nPageSize; /* similar to VK_PRIOR */
1209 if (infoPtr->nPos < infoPtr->nRangeMin)
1210 infoPtr->nPos = infoPtr->nRangeMin;
1211 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1214 if (prevPos!=infoPtr->nPos) {
1215 infoPtr->flags |= TB_THUMBPOSCHANGED;
1216 InvalidateRect (hwnd, NULL, FALSE);
1224 TRACKBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
1226 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1228 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1230 if (infoPtr->flags & TB_DRAG_MODE)
1232 infoPtr->flags &= ~TB_DRAG_MODE;
1236 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) { /* disable tooltip */
1239 ti.cbSize = sizeof(TTTOOLINFOA);
1241 ti.hwnd = (UINT)hwnd;
1243 infoPtr->flags &= ~TB_SHOW_TOOLTIP;
1244 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1245 (WPARAM)FALSE, (LPARAM)&ti);
1248 InvalidateRect (hwnd, NULL, FALSE);
1255 TRACKBAR_CaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
1257 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1259 if (infoPtr->flags & TB_DRAGPOSVALID) {
1260 infoPtr->nPos=infoPtr->dragPos;
1261 InvalidateRect (hwnd, NULL, FALSE);
1264 infoPtr->flags &= ~ TB_DRAGPOSVALID;
1266 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1272 TRACKBAR_Paint (HWND hwnd, WPARAM wParam)
1277 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1278 TRACKBAR_Refresh (hwnd, hdc);
1280 EndPaint (hwnd, &ps);
1286 TRACKBAR_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1288 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1291 infoPtr->bFocus = TRUE;
1293 InvalidateRect (hwnd, NULL, FALSE);
1300 TRACKBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1302 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1304 TRACKBAR_CalcChannel (hwnd, infoPtr);
1305 TRACKBAR_AlignBuddies (hwnd, infoPtr);
1312 TRACKBAR_SendNotify (HWND hwnd, UINT code)
1316 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT)
1317 return (BOOL) SendMessageA (GetParent (hwnd),
1318 WM_VSCROLL, (WPARAM)code, (LPARAM)hwnd);
1320 return (BOOL) SendMessageA (GetParent (hwnd),
1321 WM_HSCROLL, (WPARAM)code, (LPARAM)hwnd);
1326 TRACKBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1328 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1329 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1334 TRACE("%x\n",wParam);
1336 if (dwStyle & TBS_VERT)
1337 clickPlace=(SHORT)HIWORD(lParam);
1339 clickPlace=(SHORT)LOWORD(lParam);
1341 if (!(infoPtr->flags & TB_DRAG_MODE))
1345 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace,
1346 dwStyle & TBS_VERT);
1347 if (dragPos > ((INT)dragPos) + 0.5)
1348 infoPtr->dragPos = dragPos + 1;
1350 infoPtr->dragPos = dragPos;
1352 infoPtr->flags |= TB_DRAGPOSVALID;
1353 TRACKBAR_SendNotify (hwnd, TB_THUMBTRACK | (infoPtr->nPos>>16));
1355 if (infoPtr->flags & TB_SHOW_TOOLTIP) {
1359 ti.cbSize = sizeof(TTTOOLINFOA);
1363 sprintf (buf,"%d",infoPtr->nPos);
1364 ti.lpszText = (LPSTR) buf;
1367 if (dwStyle & TBS_VERT) {
1368 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1369 0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15));
1371 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1372 0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5));
1374 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
1378 InvalidateRect (hwnd, NULL, FALSE);
1379 UpdateWindow (hwnd);
1386 TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1388 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1391 TRACE("%x\n",wParam);
1397 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1398 infoPtr->nPos -= infoPtr->nLineSize;
1399 if (infoPtr->nPos < infoPtr->nRangeMin)
1400 infoPtr->nPos = infoPtr->nRangeMin;
1401 TRACKBAR_SendNotify (hwnd, TB_LINEUP);
1405 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1406 infoPtr->nPos += infoPtr->nLineSize;
1407 if (infoPtr->nPos > infoPtr->nRangeMax)
1408 infoPtr->nPos = infoPtr->nRangeMax;
1409 TRACKBAR_SendNotify (hwnd, TB_LINEDOWN);
1412 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1413 infoPtr->nPos += infoPtr->nPageSize;
1414 if (infoPtr->nPos > infoPtr->nRangeMax)
1415 infoPtr->nPos = infoPtr->nRangeMax;
1416 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1419 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1420 infoPtr->nPos -= infoPtr->nPageSize;
1421 if (infoPtr->nPos < infoPtr->nRangeMin)
1422 infoPtr->nPos = infoPtr->nRangeMin;
1423 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1426 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1427 infoPtr->nPos = infoPtr->nRangeMin;
1428 TRACKBAR_SendNotify (hwnd, TB_TOP);
1431 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1432 infoPtr->nPos = infoPtr->nRangeMax;
1433 TRACKBAR_SendNotify (hwnd, TB_BOTTOM);
1437 if (pos!=infoPtr->nPos) {
1438 infoPtr->flags |=TB_THUMBPOSCHANGED;
1439 InvalidateRect (hwnd, NULL, FALSE);
1447 TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
1458 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1465 TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1470 return TRACKBAR_ClearSel (hwnd, wParam, lParam);
1473 return TRACKBAR_ClearTics (hwnd, wParam, lParam);
1476 return TRACKBAR_GetBuddy (hwnd, wParam, lParam);
1478 case TBM_GETCHANNELRECT:
1479 return TRACKBAR_GetChannelRect (hwnd, wParam, lParam);
1481 case TBM_GETLINESIZE:
1482 return TRACKBAR_GetLineSize (hwnd, wParam, lParam);
1484 case TBM_GETNUMTICS:
1485 return TRACKBAR_GetNumTics (hwnd, wParam, lParam);
1487 case TBM_GETPAGESIZE:
1488 return TRACKBAR_GetPageSize (hwnd, wParam, lParam);
1491 return TRACKBAR_GetPos (hwnd, wParam, lParam);
1494 return TRACKBAR_GetPTics (hwnd);
1496 case TBM_GETRANGEMAX:
1497 return TRACKBAR_GetRangeMax (hwnd, wParam, lParam);
1499 case TBM_GETRANGEMIN:
1500 return TRACKBAR_GetRangeMin (hwnd, wParam, lParam);
1503 return TRACKBAR_GetSelEnd (hwnd, wParam, lParam);
1505 case TBM_GETSELSTART:
1506 return TRACKBAR_GetSelStart (hwnd, wParam, lParam);
1508 case TBM_GETTHUMBLENGTH:
1509 return TRACKBAR_GetThumbLength (hwnd, wParam, lParam);
1511 case TBM_GETTHUMBRECT:
1512 return TRACKBAR_GetThumbRect (hwnd, wParam, lParam);
1515 return TRACKBAR_GetTic (hwnd, wParam, lParam);
1518 return TRACKBAR_GetTicPos (hwnd, wParam, lParam);
1520 case TBM_GETTOOLTIPS:
1521 return TRACKBAR_GetToolTips (hwnd, wParam, lParam);
1523 /* case TBM_GETUNICODEFORMAT: */
1526 return TRACKBAR_SetBuddy (hwnd, wParam, lParam);
1528 case TBM_SETLINESIZE:
1529 return TRACKBAR_SetLineSize (hwnd, wParam, lParam);
1531 case TBM_SETPAGESIZE:
1532 return TRACKBAR_SetPageSize (hwnd, wParam, lParam);
1535 return TRACKBAR_SetPos (hwnd, wParam, lParam);
1538 return TRACKBAR_SetRange (hwnd, wParam, lParam);
1540 case TBM_SETRANGEMAX:
1541 return TRACKBAR_SetRangeMax (hwnd, wParam, lParam);
1543 case TBM_SETRANGEMIN:
1544 return TRACKBAR_SetRangeMin (hwnd, wParam, lParam);
1547 return TRACKBAR_SetSel (hwnd, wParam, lParam);
1550 return TRACKBAR_SetSelEnd (hwnd, wParam, lParam);
1552 case TBM_SETSELSTART:
1553 return TRACKBAR_SetSelStart (hwnd, wParam, lParam);
1555 case TBM_SETTHUMBLENGTH:
1556 return TRACKBAR_SetThumbLength (hwnd, wParam, lParam);
1559 return TRACKBAR_SetTic (hwnd, wParam, lParam);
1561 case TBM_SETTICFREQ:
1562 return TRACKBAR_SetTicFreq (hwnd, wParam);
1564 case TBM_SETTIPSIDE:
1565 return TRACKBAR_SetTipSide (hwnd, wParam, lParam);
1567 case TBM_SETTOOLTIPS:
1568 return TRACKBAR_SetToolTips (hwnd, wParam, lParam);
1570 /* case TBM_SETUNICODEFORMAT: */
1573 case WM_CAPTURECHANGED:
1574 return TRACKBAR_CaptureChanged (hwnd, wParam, lParam);
1577 return TRACKBAR_Create (hwnd, wParam, lParam);
1580 return TRACKBAR_Destroy (hwnd, wParam, lParam);
1582 /* case WM_ENABLE: */
1584 /* case WM_ERASEBKGND: */
1588 return DLGC_WANTARROWS;
1591 return TRACKBAR_KeyDown (hwnd, wParam, lParam);
1594 return TRACKBAR_KeyUp (hwnd, wParam);
1597 return TRACKBAR_KillFocus (hwnd, wParam, lParam);
1599 case WM_LBUTTONDOWN:
1600 return TRACKBAR_LButtonDown (hwnd, wParam, lParam);
1603 return TRACKBAR_LButtonUp (hwnd, wParam, lParam);
1606 return TRACKBAR_MouseMove (hwnd, wParam, lParam);
1609 return TRACKBAR_Paint (hwnd, wParam);
1612 return TRACKBAR_SetFocus (hwnd, wParam, lParam);
1615 return TRACKBAR_Size (hwnd, wParam, lParam);
1617 case WM_WININICHANGE:
1618 return TRACKBAR_InitializeThumb (hwnd);
1621 if (uMsg >= WM_USER)
1622 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
1623 uMsg, wParam, lParam);
1624 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1631 TRACKBAR_Register (void)
1635 if (GlobalFindAtomA (TRACKBAR_CLASSA)) return;
1637 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1638 wndClass.style = CS_GLOBALCLASS;
1639 wndClass.lpfnWndProc = (WNDPROC)TRACKBAR_WindowProc;
1640 wndClass.cbClsExtra = 0;
1641 wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
1642 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
1643 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1644 wndClass.lpszClassName = TRACKBAR_CLASSA;
1646 RegisterClassA (&wndClass);
1651 TRACKBAR_Unregister (void)
1653 if (GlobalFindAtomA (TRACKBAR_CLASSA))
1654 UnregisterClassA (TRACKBAR_CLASSA, (HINSTANCE)NULL);