4 * Copyright 1998, 1999 Eric Kohl <ekohl@abo.rhein-zeitung.de>
5 * Copyright 1998,1999 Alex Priem <alexp@sci.kun.nl>
10 * - handle dragging slider better
11 * - better tic handling.
12 * - more notifications.
18 -TBM_SETRANGEMAX & TBM_SETRANGEMIN should only change the view of the
19 trackbar, not the actual amount of tics in the list.
20 -TBM_GETTIC & TBM_GETTICPOS shouldn't rely on infoPtr->tics being sorted.
29 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(trackbar);
60 /* #define TB_REFRESH_TIMER 1 */
61 /* #define TB_REFRESH_DELAY 1 */
63 #define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)GetWindowLongA (hwnd,0))
66 /* Used by TRACKBAR_Refresh to find out which parts of the control
67 need to be recalculated */
69 #define TB_THUMBPOSCHANGED 1
70 #define TB_THUMBSIZECHANGED 2
71 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBPOSCHANGED)
72 #define TB_SELECTIONCHANGED 4
73 #define TB_DRAG_MODE 16 /* we're dragging the slider */
74 #define TB_DRAGPOSVALID 32 /* current Position is in dragPos */
75 #define TB_SHOW_TOOLTIP 64 /* tooltip-style enabled and tooltip on */
77 /* helper defines for TRACKBAR_DrawTic */
78 #define TIC_LEFTEDGE 0x20
79 #define TIC_RIGHTEDGE 0x40
80 #define TIC_EDGE (TIC_LEFTEDGE | TIC_RIGHTEDGE)
81 #define TIC_SELECTIONMARKMAX 0x80
82 #define TIC_SELECTIONMARKMIN 0x100
83 #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
85 static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code);
87 static void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
91 if (infoPtr->uTicFreq && infoPtr->nRangeMax >= infoPtr->nRangeMin)
92 nrTics=(infoPtr->nRangeMax - infoPtr->nRangeMin)/infoPtr->uTicFreq;
95 COMCTL32_Free (infoPtr->tics);
101 if (nrTics!=infoPtr->uNumTics) {
102 infoPtr->tics=COMCTL32_ReAlloc (infoPtr->tics,
103 (nrTics+1)*sizeof (DWORD));
104 infoPtr->uNumTics=nrTics;
106 infoPtr->uNumTics=nrTics;
107 tic=infoPtr->nRangeMin+infoPtr->uTicFreq;
108 for (i=0; i<nrTics; i++,tic+=infoPtr->uTicFreq)
109 infoPtr->tics[i]=tic;
113 /* converts from physical (mouse) position to logical position
114 (in range of trackbar) */
117 TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place,
120 double range,width,pos;
122 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
124 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
125 pos=(range*(place - infoPtr->rcChannel.top)) / width;
127 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
128 pos=(range*(place - infoPtr->rcChannel.left)) / width;
130 pos+=infoPtr->nRangeMin;
131 if (pos > infoPtr->nRangeMax)
132 pos = infoPtr->nRangeMax;
133 else if (pos < infoPtr->nRangeMin)
134 pos = infoPtr->nRangeMin;
142 TRACKBAR_CalcChannel (HWND hwnd, TRACKBAR_INFO *infoPtr)
144 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
145 INT cyChannel,offsettop,offsetedge;
146 RECT lpRect,*channel = & infoPtr->rcChannel;
148 GetClientRect (hwnd, &lpRect);
150 if (dwStyle & TBS_ENABLESELRANGE)
151 cyChannel = ((int)(infoPtr->uThumbLen/4.5)+1)*3;
155 offsettop = (int)(infoPtr->uThumbLen/4.5);
156 offsetedge = (int)(infoPtr->uThumbLen/4.5) + 3;
158 if (dwStyle & TBS_VERT) {
159 channel->top = lpRect.top + offsetedge;
160 channel->bottom = lpRect.bottom - offsetedge;
162 if (dwStyle & (TBS_BOTH | TBS_LEFT)) {
163 channel->left = lpRect.left + offsettop + 8 ;
164 channel->right = channel->left + cyChannel;
166 else { /* TBS_RIGHT */
167 channel->left = lpRect.left + offsettop;
168 channel->right = channel->left + cyChannel;
172 channel->left = lpRect.left + offsetedge;
173 channel->right = lpRect.right - offsetedge;
175 if (dwStyle & (TBS_BOTH|TBS_TOP)) {
176 channel->top = lpRect.top + offsettop + 8 ;
177 channel->bottom = channel->top + cyChannel;
179 else { /* TBS_BOTTOM */
180 channel->top = lpRect.top + offsettop;
181 channel->bottom = channel->top + cyChannel;
187 TRACKBAR_CalcThumb (HWND hwnd, TRACKBAR_INFO *infoPtr)
190 int range, width, thumbdepth;
191 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
193 thumb=&infoPtr->rcThumb;
194 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
195 thumbdepth = ((INT)((FLOAT)infoPtr->uThumbLen / 4.5) * 2) + 2;
197 if (!range) return; /* FIXME: may this happen? */
199 if (dwStyle & TBS_VERT)
201 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
203 if (dwStyle & (TBS_BOTH | TBS_LEFT))
207 thumb->right = thumb -> left + infoPtr->uThumbLen;
208 thumb->top = infoPtr->rcChannel.top +
209 (width*(infoPtr->nPos - infoPtr->nRangeMin))/range -
211 thumb->bottom = thumb->top + thumbdepth;
215 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
217 thumb->left = infoPtr->rcChannel.left +
218 (width*(infoPtr->nPos - infoPtr->nRangeMin))/range -
220 thumb->right = thumb->left + thumbdepth;
221 if (dwStyle & (TBS_BOTH | TBS_TOP))
225 thumb->bottom = thumb -> top + infoPtr->uThumbLen;
230 TRACKBAR_CalcSelection (HWND hwnd, TRACKBAR_INFO *infoPtr)
235 selection= & infoPtr->rcSelection;
236 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
237 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
240 SetRectEmpty (selection);
242 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
243 selection->left = infoPtr->rcChannel.left +
244 (width*infoPtr->nSelMin)/range;
245 selection->right = infoPtr->rcChannel.left +
246 (width*infoPtr->nSelMax)/range;
247 selection->top = infoPtr->rcChannel.top + 2;
248 selection->bottom = infoPtr->rcChannel.bottom - 2;
250 selection->top = infoPtr->rcChannel.top +
251 (width*infoPtr->nSelMin)/range;
252 selection->bottom = infoPtr->rcChannel.top +
253 (width*infoPtr->nSelMax)/range;
254 selection->left = infoPtr->rcChannel.left + 2;
255 selection->right = infoPtr->rcChannel.right - 2;
259 /* Trackbar drawing code. I like my spaghetti done milanese. */
261 /* ticPos is in tic-units, not in pixels */
264 TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
265 int flags, COLORREF clrTic)
267 RECT rcChannel=infoPtr->rcChannel;
268 int x,y,width,range,side;
270 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
271 width=rcChannel.right - rcChannel.left;
273 if (flags & TBS_TOP) {
277 y=rcChannel.bottom+2;
281 if (flags & TIC_SELECTIONMARK) {
282 if (flags & TIC_SELECTIONMARKMIN)
283 x=rcChannel.left + (width*(ticPos - infoPtr->nRangeMin))/range - 1;
285 x=rcChannel.left + (width*(ticPos - infoPtr->nRangeMin))/range + 1;
287 SetPixel (hdc, x,y+6*side, clrTic);
288 SetPixel (hdc, x,y+7*side, clrTic);
292 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
293 x=rcChannel.left + (width*(ticPos - infoPtr->nRangeMin))/range;
294 SetPixel (hdc, x,y+5*side, clrTic);
295 SetPixel (hdc, x,y+6*side, clrTic);
296 SetPixel (hdc, x,y+7*side, clrTic);
299 if (flags & TIC_EDGE) {
300 if (flags & TIC_LEFTEDGE)
305 SetPixel (hdc, x,y+5*side, clrTic);
306 SetPixel (hdc, x,y+6*side, clrTic);
307 SetPixel (hdc, x,y+7*side, clrTic);
308 SetPixel (hdc, x,y+8*side, clrTic);
314 TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
315 int flags, COLORREF clrTic)
317 RECT rcChannel=infoPtr->rcChannel;
318 int x,y,width,range,side;
320 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
321 width=rcChannel.bottom - rcChannel.top;
323 if (flags & TBS_TOP) {
332 if (flags & TIC_SELECTIONMARK) {
333 if (flags & TIC_SELECTIONMARKMIN)
334 y=rcChannel.top + (width*(ticPos - infoPtr->nRangeMin))/range - 1;
336 y=rcChannel.top + (width*(ticPos - infoPtr->nRangeMin))/range + 1;
338 SetPixel (hdc, x+6*side, y, clrTic);
339 SetPixel (hdc, x+7*side, y, clrTic);
343 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
344 y=rcChannel.top + (width*(ticPos - infoPtr->nRangeMin))/range;
345 SetPixel (hdc, x+5*side, y, clrTic);
346 SetPixel (hdc, x+6*side, y, clrTic);
347 SetPixel (hdc, x+7*side, y, clrTic);
350 if (flags & TIC_EDGE) {
351 if (flags & TIC_LEFTEDGE)
356 SetPixel (hdc, x+5*side, y, clrTic);
357 SetPixel (hdc, x+6*side, y, clrTic);
358 SetPixel (hdc, x+7*side, y, clrTic);
359 SetPixel (hdc, x+8*side, y, clrTic);
366 TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
367 int flags, COLORREF clrTic)
370 if (flags & TBS_VERT) {
371 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
372 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos,
373 flags | TBS_TOP , clrTic);
374 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
375 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos, flags, clrTic);
379 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
380 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags | TBS_TOP , clrTic);
382 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
383 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags, clrTic);
388 TRACKBAR_DrawThumb(TRACKBAR_INFO *infoPtr, HDC hdc, DWORD dwStyle)
390 HBRUSH oldbr,hbr = GetSysColorBrush(COLOR_BTNFACE);
391 HPEN oldpen=(HPEN)NULL,hpn;
392 RECT thumb = infoPtr->rcThumb;
397 static INT PointDepth = 4;
399 oldbr = SelectObject (hdc, hbr);
400 SetPolyFillMode (hdc,WINDING);
402 if (dwStyle & TBS_BOTH)
404 points[0].x=thumb.right;
405 points[0].y=thumb.top;
406 points[1].x=thumb.right;
407 points[1].y=thumb.bottom;
408 points[2].x=thumb.left;
409 points[2].y=thumb.bottom;
410 points[3].x=thumb.left;
411 points[3].y=thumb.top;
412 points[4].x=points[0].x;
413 points[4].y=points[0].y;
419 if (dwStyle & TBS_VERT)
421 if (dwStyle & TBS_LEFT)
423 points[0].x=thumb.right;
424 points[0].y=thumb.top;
425 points[1].x=thumb.right;
426 points[1].y=thumb.bottom;
427 points[2].x=thumb.left + PointDepth;
428 points[2].y=thumb.bottom;
429 points[3].x=thumb.left;
430 points[3].y=(thumb.bottom - thumb.top) / 2 + thumb.top;
431 points[4].x=thumb.left + PointDepth;
432 points[4].y=thumb.top;
433 points[5].x=points[0].x;
434 points[5].y=points[0].y;
439 points[0].x=thumb.right;
440 points[0].y=(thumb.bottom - thumb.top) / 2 + thumb.top;
441 points[1].x=thumb.right - PointDepth;
442 points[1].y=thumb.bottom;
443 points[2].x=thumb.left;
444 points[2].y=thumb.bottom;
445 points[3].x=thumb.left;
446 points[3].y=thumb.top;
447 points[4].x=thumb.right - PointDepth;
448 points[4].y=thumb.top;
449 points[5].x=points[0].x;
450 points[5].y=points[0].y;
455 if (dwStyle & TBS_TOP)
457 points[0].x=(thumb.right - thumb.left) / 2 + thumb.left ;
458 points[0].y=thumb.top;
459 points[1].x=thumb.right;
460 points[1].y=thumb.top + PointDepth;
461 points[2].x=thumb.right;
462 points[2].y=thumb.bottom;
463 points[3].x=thumb.left;
464 points[3].y=thumb.bottom;
465 points[4].x=thumb.left;
466 points[4].y=thumb.top + PointDepth;
467 points[5].x=points[0].x;
468 points[5].y=points[0].y;
473 points[0].x=thumb.right;
474 points[0].y=thumb.top;
475 points[1].x=thumb.right;
476 points[1].y=thumb.bottom - PointDepth;
477 points[2].x=(thumb.right - thumb.left) / 2 + thumb.left ;
478 points[2].y=thumb.bottom;
479 points[3].x=thumb.left;
480 points[3].y=thumb.bottom - PointDepth;
481 points[4].x=thumb.left;
482 points[4].y=thumb.top;
483 points[5].x=points[0].x;
484 points[5].y=points[0].y;
493 Polygon (hdc, points, PointCount);
498 hpn = GetStockObject(BLACK_PEN);
499 oldpen = SelectObject(hdc,hpn);
504 Polyline(hdc,points,BlackUntil);
506 SelectObject(hdc,oldpen);
507 hpn = GetStockObject(WHITE_PEN);
508 SelectObject(hdc,hpn);
513 Polyline(hdc,&points[BlackUntil-1],PointCount+1-BlackUntil);
516 * restore the brush and pen
518 SelectObject(hdc,oldbr);
520 SelectObject(hdc,oldpen);
524 TRACKBAR_Refresh (HWND hwnd, HDC hdc)
526 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
527 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
528 RECT rcClient, rcChannel, rcSelection;
532 GetClientRect (hwnd, &rcClient);
533 hBrush = CreateSolidBrush (infoPtr->clrBk);
534 FillRect (hdc, &rcClient, hBrush);
535 DeleteObject (hBrush);
537 if (infoPtr->flags & TB_DRAGPOSVALID) {
538 infoPtr->nPos=infoPtr->dragPos;
539 infoPtr->flags |= TB_THUMBPOSCHANGED;
542 if (infoPtr->flags & TB_THUMBCHANGED) {
543 TRACKBAR_CalcThumb (hwnd, infoPtr);
544 if (infoPtr->flags & TB_THUMBSIZECHANGED)
545 TRACKBAR_CalcChannel (hwnd, infoPtr);
547 if (infoPtr->flags & TB_SELECTIONCHANGED)
548 TRACKBAR_CalcSelection (hwnd, infoPtr);
549 infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED |
554 rcChannel = infoPtr->rcChannel;
555 rcSelection= infoPtr->rcSelection;
556 DrawEdge (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
558 if (dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
559 HBRUSH hbr = CreateSolidBrush (RGB(255,255,255));
560 FillRect (hdc, &rcChannel, hbr);
561 if (((dwStyle & TBS_VERT) &&
562 (rcSelection.left!=rcSelection.right)) ||
563 ((!(dwStyle & TBS_VERT)) &&
564 (rcSelection.left!=rcSelection.right))) {
565 hbr=CreateSolidBrush (COLOR_HIGHLIGHT);
566 FillRect (hdc, &rcSelection, hbr);
574 if (!(dwStyle & TBS_NOTICKS)) {
575 int ticFlags = dwStyle & 0x0f;
576 COLORREF clrTic=GetSysColor (COLOR_3DDKSHADOW);
578 for (i=0; i<infoPtr->uNumTics; i++)
579 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->tics[i],
582 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_LEFTEDGE, clrTic);
583 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_RIGHTEDGE, clrTic);
585 if ((dwStyle & TBS_ENABLESELRANGE) &&
586 (rcSelection.left!=rcSelection.right)) {
587 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMin,
588 ticFlags | TIC_SELECTIONMARKMIN, clrTic);
589 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMax,
590 ticFlags | TIC_SELECTIONMARKMAX, clrTic);
596 if (!(dwStyle & TBS_NOTHUMB))
598 TRACKBAR_DrawThumb(infoPtr,hdc,dwStyle);
602 DrawFocusRect (hdc, &rcClient);
607 TRACKBAR_AlignBuddies (HWND hwnd, TRACKBAR_INFO *infoPtr)
609 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
610 HWND hwndParent = GetParent (hwnd);
611 RECT rcSelf, rcBuddy;
614 GetWindowRect (hwnd, &rcSelf);
615 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcSelf, 2);
617 /* align buddy left or above */
618 if (infoPtr->hwndBuddyLA) {
619 GetWindowRect (infoPtr->hwndBuddyLA, &rcBuddy);
620 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
622 if (dwStyle & TBS_VERT) {
623 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
624 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
625 y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
628 x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
629 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
630 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
633 SetWindowPos (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
634 SWP_NOZORDER | SWP_NOSIZE);
638 /* align buddy right or below */
639 if (infoPtr->hwndBuddyRB) {
640 GetWindowRect (infoPtr->hwndBuddyRB, &rcBuddy);
641 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
643 if (dwStyle & TBS_VERT) {
644 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
645 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
650 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
651 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
653 SetWindowPos (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
654 SWP_NOZORDER | SWP_NOSIZE);
660 TRACKBAR_ClearSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
662 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
664 infoPtr->nSelMin = 0;
665 infoPtr->nSelMax = 0;
666 infoPtr->flags |= TB_SELECTIONCHANGED;
669 InvalidateRect (hwnd, NULL, FALSE);
676 TRACKBAR_ClearTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
678 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
681 COMCTL32_Free (infoPtr->tics);
682 infoPtr->tics = NULL;
683 infoPtr->uNumTics = 0;
687 InvalidateRect (hwnd, NULL, FALSE);
694 TRACKBAR_GetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
696 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
698 if (wParam) /* buddy is left or above */
699 return (LRESULT)infoPtr->hwndBuddyLA;
701 /* buddy is right or below */
702 return (LRESULT) infoPtr->hwndBuddyRB;
707 TRACKBAR_GetChannelRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
709 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
710 LPRECT lprc = (LPRECT)lParam;
715 lprc->left = infoPtr->rcChannel.left;
716 lprc->right = infoPtr->rcChannel.right;
717 lprc->bottom = infoPtr->rcChannel.bottom;
718 lprc->top = infoPtr->rcChannel.top;
725 TRACKBAR_GetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
727 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
729 return infoPtr->nLineSize;
734 TRACKBAR_GetNumTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
736 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
738 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_NOTICKS)
741 return infoPtr->uNumTics+2;
746 TRACKBAR_GetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
748 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
750 return infoPtr->nPageSize;
755 TRACKBAR_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
757 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
759 return infoPtr->nPos;
764 TRACKBAR_GetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
766 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
768 return infoPtr->nRangeMax;
773 TRACKBAR_GetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
775 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
777 return infoPtr->nRangeMin;
782 TRACKBAR_GetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
784 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
786 return infoPtr->nSelMax;
791 TRACKBAR_GetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
793 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
795 return infoPtr->nSelMin;
800 TRACKBAR_GetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
802 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
804 return infoPtr->uThumbLen;
808 TRACKBAR_GetPTics (HWND hwnd)
810 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
812 return (LRESULT) infoPtr->tics;
816 TRACKBAR_GetThumbRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
818 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
819 LPRECT lprc = (LPRECT)lParam;
824 lprc->left = infoPtr->rcThumb.left;
825 lprc->right = infoPtr->rcThumb.right;
826 lprc->bottom = infoPtr->rcThumb.bottom;
827 lprc->top = infoPtr->rcThumb.top;
834 TRACKBAR_GetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
836 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
840 if ((iTic<0) || (iTic>infoPtr->uNumTics))
843 return (LRESULT) infoPtr->tics[iTic];
849 TRACKBAR_GetTicPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
851 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
852 INT iTic, range, width, pos;
856 if ((iTic<0) || (iTic>infoPtr->uNumTics))
859 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
860 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
861 pos=infoPtr->rcChannel.left + (width * infoPtr->tics[iTic]) / range;
864 return (LRESULT) pos;
869 TRACKBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
871 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
873 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
874 return (LRESULT)infoPtr->hwndToolTip;
879 /* case TBM_GETUNICODEFORMAT: */
883 TRACKBAR_SetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
885 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
889 /* buddy is left or above */
890 hwndTemp = infoPtr->hwndBuddyLA;
891 infoPtr->hwndBuddyLA = (HWND)lParam;
893 FIXME("move buddy!\n");
896 /* buddy is right or below */
897 hwndTemp = infoPtr->hwndBuddyRB;
898 infoPtr->hwndBuddyRB = (HWND)lParam;
900 FIXME("move buddy!\n");
903 TRACKBAR_AlignBuddies (hwnd, infoPtr);
905 return (LRESULT)hwndTemp;
910 TRACKBAR_SetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
912 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
913 INT nTemp = infoPtr->nLineSize;
915 infoPtr->nLineSize = (INT)lParam;
922 TRACKBAR_SetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
924 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
925 INT nTemp = infoPtr->nPageSize;
927 infoPtr->nPageSize = (INT)lParam;
934 TRACKBAR_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
936 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
938 infoPtr->nPos = (INT)lParam;
940 if (infoPtr->nPos < infoPtr->nRangeMin)
941 infoPtr->nPos = infoPtr->nRangeMin;
943 if (infoPtr->nPos > infoPtr->nRangeMax)
944 infoPtr->nPos = infoPtr->nRangeMax;
945 infoPtr->flags |= TB_THUMBPOSCHANGED;
948 InvalidateRect (hwnd, NULL, FALSE);
955 TRACKBAR_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
957 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
958 infoPtr->nRangeMin = (INT)LOWORD(lParam);
959 infoPtr->nRangeMax = (INT)HIWORD(lParam);
961 if (infoPtr->nPos < infoPtr->nRangeMin) {
962 infoPtr->nPos = infoPtr->nRangeMin;
963 infoPtr->flags |=TB_THUMBPOSCHANGED;
966 if (infoPtr->nPos > infoPtr->nRangeMax) {
967 infoPtr->nPos = infoPtr->nRangeMax;
968 infoPtr->flags |=TB_THUMBPOSCHANGED;
971 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
972 if (infoPtr->nPageSize == 0)
973 infoPtr->nPageSize = 1;
974 TRACKBAR_RecalculateTics (infoPtr);
977 InvalidateRect (hwnd, NULL, FALSE);
984 TRACKBAR_SetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
986 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
988 infoPtr->nRangeMax = (INT)lParam;
989 if (infoPtr->nPos > infoPtr->nRangeMax) {
990 infoPtr->nPos = infoPtr->nRangeMax;
991 infoPtr->flags |=TB_THUMBPOSCHANGED;
994 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
995 if (infoPtr->nPageSize == 0)
996 infoPtr->nPageSize = 1;
997 TRACKBAR_RecalculateTics (infoPtr);
1000 InvalidateRect (hwnd, NULL, FALSE);
1007 TRACKBAR_SetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1009 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1011 infoPtr->nRangeMin = (INT)lParam;
1012 if (infoPtr->nPos < infoPtr->nRangeMin) {
1013 infoPtr->nPos = infoPtr->nRangeMin;
1014 infoPtr->flags |=TB_THUMBPOSCHANGED;
1017 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
1018 if (infoPtr->nPageSize == 0)
1019 infoPtr->nPageSize = 1;
1020 TRACKBAR_RecalculateTics (infoPtr);
1023 InvalidateRect (hwnd, NULL, FALSE);
1030 TRACKBAR_SetTicFreq (HWND hwnd, WPARAM wParam)
1032 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1034 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_AUTOTICKS)
1035 infoPtr->uTicFreq=(UINT) wParam;
1037 TRACKBAR_RecalculateTics (infoPtr);
1039 InvalidateRect (hwnd, NULL, FALSE);
1046 TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
1048 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1050 infoPtr->nSelMin = (INT)LOWORD(lParam);
1051 infoPtr->nSelMax = (INT)HIWORD(lParam);
1052 infoPtr->flags |=TB_SELECTIONCHANGED;
1054 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
1057 if (infoPtr->nSelMin < infoPtr->nRangeMin)
1058 infoPtr->nSelMin = infoPtr->nRangeMin;
1059 if (infoPtr->nSelMax > infoPtr->nRangeMax)
1060 infoPtr->nSelMax = infoPtr->nRangeMax;
1063 InvalidateRect (hwnd, NULL, FALSE);
1071 TRACKBAR_SetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
1073 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1075 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
1078 infoPtr->nSelMax = (INT)lParam;
1079 infoPtr->flags |= TB_SELECTIONCHANGED;
1081 if (infoPtr->nSelMax > infoPtr->nRangeMax)
1082 infoPtr->nSelMax = infoPtr->nRangeMax;
1085 InvalidateRect (hwnd, NULL, FALSE);
1092 TRACKBAR_SetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
1094 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1096 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
1099 infoPtr->nSelMin = (INT)lParam;
1100 infoPtr->flags |=TB_SELECTIONCHANGED;
1102 if (infoPtr->nSelMin < infoPtr->nRangeMin)
1103 infoPtr->nSelMin = infoPtr->nRangeMin;
1106 InvalidateRect (hwnd, NULL, FALSE);
1113 TRACKBAR_SetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
1115 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1117 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_FIXEDLENGTH)
1118 infoPtr->uThumbLen = (UINT)wParam;
1120 infoPtr->flags |= TB_THUMBSIZECHANGED;
1122 InvalidateRect (hwnd, NULL, FALSE);
1129 TRACKBAR_SetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
1131 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1132 INT nPos = (INT)lParam;
1134 if ((nPos < infoPtr->nRangeMin) || (nPos> infoPtr->nRangeMax))
1137 infoPtr->uNumTics++;
1138 infoPtr->tics=COMCTL32_ReAlloc( infoPtr->tics,
1139 (infoPtr->uNumTics)*sizeof (DWORD));
1140 infoPtr->tics[infoPtr->uNumTics-1]=nPos;
1142 InvalidateRect (hwnd, NULL, FALSE);
1149 TRACKBAR_SetTipSide (HWND hwnd, WPARAM wParam, LPARAM lParam)
1151 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1152 INT fTemp = infoPtr->fLocation;
1154 infoPtr->fLocation = (INT)wParam;
1161 TRACKBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1163 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1165 infoPtr->hwndToolTip = (HWND)wParam;
1171 /* case TBM_SETUNICODEFORMAT: */
1175 TRACKBAR_InitializeThumb (HWND hwnd)
1177 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1179 infoPtr->uThumbLen = 23; /* initial thumb length */
1181 TRACKBAR_CalcChannel (hwnd,infoPtr);
1182 TRACKBAR_CalcThumb (hwnd, infoPtr);
1183 infoPtr->flags &= ~TB_SELECTIONCHANGED;
1190 TRACKBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1192 TRACKBAR_INFO *infoPtr;
1194 infoPtr = (TRACKBAR_INFO *)COMCTL32_Alloc (sizeof(TRACKBAR_INFO));
1195 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1197 /* set default values */
1198 infoPtr->nRangeMin = 0;
1199 infoPtr->nRangeMax = 100;
1200 infoPtr->nLineSize = 1;
1201 infoPtr->nPageSize = 20;
1202 infoPtr->nSelMin = 0;
1203 infoPtr->nSelMax = 0;
1206 infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
1207 infoPtr->uTicFreq = 1;
1208 infoPtr->tics = NULL;
1209 infoPtr->clrBk = GetSysColor (COLOR_BTNFACE);
1210 infoPtr->hwndNotify = GetParent (hwnd);
1212 TRACKBAR_InitializeThumb (hwnd);
1214 /* Create tooltip control */
1215 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) {
1218 infoPtr->hwndToolTip =
1219 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
1220 CW_USEDEFAULT, CW_USEDEFAULT,
1221 CW_USEDEFAULT, CW_USEDEFAULT,
1224 /* Send NM_TOOLTIPSCREATED notification */
1225 if (infoPtr->hwndToolTip) {
1226 NMTOOLTIPSCREATED nmttc;
1228 nmttc.hdr.hwndFrom = hwnd;
1229 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1230 nmttc.hdr.code = NM_TOOLTIPSCREATED;
1231 nmttc.hwndToolTips = infoPtr->hwndToolTip;
1233 SendMessageA (GetParent (hwnd), WM_NOTIFY,
1234 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
1237 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1238 ti.cbSize = sizeof(TTTOOLINFOA);
1239 ti.uFlags = TTF_IDISHWND | TTF_TRACK;
1242 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */
1243 SetRectEmpty (&ti.rect);
1245 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
1253 TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1255 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1257 /* delete tooltip control */
1258 if (infoPtr->hwndToolTip)
1259 DestroyWindow (infoPtr->hwndToolTip);
1261 COMCTL32_Free (infoPtr);
1262 SetWindowLongA (hwnd, 0, 0);
1268 TRACKBAR_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1270 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1274 infoPtr->bFocus = FALSE;
1275 infoPtr->flags &= ~TB_DRAG_MODE;
1277 InvalidateRect (hwnd, NULL, FALSE);
1284 TRACKBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1286 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1287 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1292 clickPoint.y = HIWORD(lParam);
1293 clickPoint.x = LOWORD(lParam);
1295 if (PtInRect(&(infoPtr->rcThumb),clickPoint))
1297 infoPtr->flags |= TB_DRAG_MODE;
1298 if (dwStyle & TBS_TOOLTIPS) { /* enable tooltip */
1303 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,
1304 (LPARAM)MAKELPARAM(pt.x, pt.y));
1306 ti.cbSize = sizeof(TTTOOLINFOA);
1308 ti.hwnd = (UINT)hwnd;
1310 infoPtr->flags |= TB_SHOW_TOOLTIP;
1312 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1313 (WPARAM)TRUE, (LPARAM)&ti);
1317 else if (PtInRect(&(infoPtr->rcChannel),clickPoint))
1319 int clickPlace,prevPos,vertical;
1322 vertical = (dwStyle & TBS_VERT) ? 1 : 0;
1324 clickPlace=(INT)HIWORD(lParam);
1326 clickPlace=(INT)LOWORD(lParam);
1328 clickPos = TRACKBAR_ConvertPlaceToPosition(infoPtr, clickPlace,
1330 prevPos = infoPtr->nPos;
1331 if (clickPos > (int)prevPos)
1332 { /* similar to VK_NEXT */
1333 infoPtr->nPos += infoPtr->nPageSize;
1334 if (infoPtr->nPos > infoPtr->nRangeMax)
1335 infoPtr->nPos = infoPtr->nRangeMax;
1336 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1340 infoPtr->nPos -= infoPtr->nPageSize; /* similar to VK_PRIOR */
1341 if (infoPtr->nPos < infoPtr->nRangeMin)
1342 infoPtr->nPos = infoPtr->nRangeMin;
1343 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1346 if (prevPos!=infoPtr->nPos) {
1347 infoPtr->flags |= TB_THUMBPOSCHANGED;
1348 InvalidateRect (hwnd, NULL, FALSE);
1357 TRACKBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
1359 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1361 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1363 if (infoPtr->flags & TB_DRAG_MODE)
1365 infoPtr->flags &= ~TB_DRAG_MODE;
1369 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) { /* disable tooltip */
1372 ti.cbSize = sizeof(TTTOOLINFOA);
1374 ti.hwnd = (UINT)hwnd;
1376 infoPtr->flags &= ~TB_SHOW_TOOLTIP;
1377 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1378 (WPARAM)FALSE, (LPARAM)&ti);
1381 InvalidateRect (hwnd, NULL, FALSE);
1388 TRACKBAR_CaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
1390 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1392 if (infoPtr->flags & TB_DRAGPOSVALID) {
1393 infoPtr->nPos=infoPtr->dragPos;
1394 InvalidateRect (hwnd, NULL, FALSE);
1397 infoPtr->flags &= ~ TB_DRAGPOSVALID;
1399 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1405 TRACKBAR_Paint (HWND hwnd, WPARAM wParam)
1410 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1411 TRACKBAR_Refresh (hwnd, hdc);
1413 EndPaint (hwnd, &ps);
1419 TRACKBAR_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1421 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1424 infoPtr->bFocus = TRUE;
1426 InvalidateRect (hwnd, NULL, FALSE);
1433 TRACKBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1435 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1437 TRACKBAR_CalcChannel (hwnd, infoPtr);
1438 TRACKBAR_AlignBuddies (hwnd, infoPtr);
1445 TRACKBAR_SendNotify (HWND hwnd, UINT code)
1449 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT)
1450 return (BOOL) SendMessageA (GetParent (hwnd),
1451 WM_VSCROLL, (WPARAM)code, (LPARAM)hwnd);
1453 return (BOOL) SendMessageA (GetParent (hwnd),
1454 WM_HSCROLL, (WPARAM)code, (LPARAM)hwnd);
1459 TRACKBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1461 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1462 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1467 TRACE("%x\n",wParam);
1469 if (dwStyle & TBS_VERT)
1470 clickPlace=(SHORT)HIWORD(lParam);
1472 clickPlace=(SHORT)LOWORD(lParam);
1474 if (!(infoPtr->flags & TB_DRAG_MODE))
1478 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace,
1479 dwStyle & TBS_VERT);
1480 if (dragPos > ((INT)dragPos) + 0.5)
1481 infoPtr->dragPos = dragPos + 1;
1483 infoPtr->dragPos = dragPos;
1485 infoPtr->flags |= TB_DRAGPOSVALID;
1486 TRACKBAR_SendNotify (hwnd, TB_THUMBTRACK | (infoPtr->nPos<<16));
1488 if (infoPtr->flags & TB_SHOW_TOOLTIP) {
1492 ti.cbSize = sizeof(TTTOOLINFOA);
1496 sprintf (buf,"%d",infoPtr->nPos);
1497 ti.lpszText = (LPSTR) buf;
1500 if (dwStyle & TBS_VERT) {
1501 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1502 0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15));
1504 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1505 0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5));
1507 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
1511 InvalidateRect (hwnd, NULL, FALSE);
1512 UpdateWindow (hwnd);
1519 TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1521 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1524 TRACE("%x\n",wParam);
1530 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1531 infoPtr->nPos -= infoPtr->nLineSize;
1532 if (infoPtr->nPos < infoPtr->nRangeMin)
1533 infoPtr->nPos = infoPtr->nRangeMin;
1534 TRACKBAR_SendNotify (hwnd, TB_LINEUP);
1538 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1539 infoPtr->nPos += infoPtr->nLineSize;
1540 if (infoPtr->nPos > infoPtr->nRangeMax)
1541 infoPtr->nPos = infoPtr->nRangeMax;
1542 TRACKBAR_SendNotify (hwnd, TB_LINEDOWN);
1545 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1546 infoPtr->nPos += infoPtr->nPageSize;
1547 if (infoPtr->nPos > infoPtr->nRangeMax)
1548 infoPtr->nPos = infoPtr->nRangeMax;
1549 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1552 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1553 infoPtr->nPos -= infoPtr->nPageSize;
1554 if (infoPtr->nPos < infoPtr->nRangeMin)
1555 infoPtr->nPos = infoPtr->nRangeMin;
1556 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1559 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1560 infoPtr->nPos = infoPtr->nRangeMin;
1561 TRACKBAR_SendNotify (hwnd, TB_TOP);
1564 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1565 infoPtr->nPos = infoPtr->nRangeMax;
1566 TRACKBAR_SendNotify (hwnd, TB_BOTTOM);
1570 if (pos!=infoPtr->nPos) {
1571 infoPtr->flags |=TB_THUMBPOSCHANGED;
1572 InvalidateRect (hwnd, NULL, FALSE);
1580 TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
1591 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1597 static LRESULT WINAPI
1598 TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1600 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
1601 if (!TRACKBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
1602 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1606 return TRACKBAR_ClearSel (hwnd, wParam, lParam);
1609 return TRACKBAR_ClearTics (hwnd, wParam, lParam);
1612 return TRACKBAR_GetBuddy (hwnd, wParam, lParam);
1614 case TBM_GETCHANNELRECT:
1615 return TRACKBAR_GetChannelRect (hwnd, wParam, lParam);
1617 case TBM_GETLINESIZE:
1618 return TRACKBAR_GetLineSize (hwnd, wParam, lParam);
1620 case TBM_GETNUMTICS:
1621 return TRACKBAR_GetNumTics (hwnd, wParam, lParam);
1623 case TBM_GETPAGESIZE:
1624 return TRACKBAR_GetPageSize (hwnd, wParam, lParam);
1627 return TRACKBAR_GetPos (hwnd, wParam, lParam);
1630 return TRACKBAR_GetPTics (hwnd);
1632 case TBM_GETRANGEMAX:
1633 return TRACKBAR_GetRangeMax (hwnd, wParam, lParam);
1635 case TBM_GETRANGEMIN:
1636 return TRACKBAR_GetRangeMin (hwnd, wParam, lParam);
1639 return TRACKBAR_GetSelEnd (hwnd, wParam, lParam);
1641 case TBM_GETSELSTART:
1642 return TRACKBAR_GetSelStart (hwnd, wParam, lParam);
1644 case TBM_GETTHUMBLENGTH:
1645 return TRACKBAR_GetThumbLength (hwnd, wParam, lParam);
1647 case TBM_GETTHUMBRECT:
1648 return TRACKBAR_GetThumbRect (hwnd, wParam, lParam);
1651 return TRACKBAR_GetTic (hwnd, wParam, lParam);
1654 return TRACKBAR_GetTicPos (hwnd, wParam, lParam);
1656 case TBM_GETTOOLTIPS:
1657 return TRACKBAR_GetToolTips (hwnd, wParam, lParam);
1659 /* case TBM_GETUNICODEFORMAT: */
1662 return TRACKBAR_SetBuddy (hwnd, wParam, lParam);
1664 case TBM_SETLINESIZE:
1665 return TRACKBAR_SetLineSize (hwnd, wParam, lParam);
1667 case TBM_SETPAGESIZE:
1668 return TRACKBAR_SetPageSize (hwnd, wParam, lParam);
1671 return TRACKBAR_SetPos (hwnd, wParam, lParam);
1674 return TRACKBAR_SetRange (hwnd, wParam, lParam);
1676 case TBM_SETRANGEMAX:
1677 return TRACKBAR_SetRangeMax (hwnd, wParam, lParam);
1679 case TBM_SETRANGEMIN:
1680 return TRACKBAR_SetRangeMin (hwnd, wParam, lParam);
1683 return TRACKBAR_SetSel (hwnd, wParam, lParam);
1686 return TRACKBAR_SetSelEnd (hwnd, wParam, lParam);
1688 case TBM_SETSELSTART:
1689 return TRACKBAR_SetSelStart (hwnd, wParam, lParam);
1691 case TBM_SETTHUMBLENGTH:
1692 return TRACKBAR_SetThumbLength (hwnd, wParam, lParam);
1695 return TRACKBAR_SetTic (hwnd, wParam, lParam);
1697 case TBM_SETTICFREQ:
1698 return TRACKBAR_SetTicFreq (hwnd, wParam);
1700 case TBM_SETTIPSIDE:
1701 return TRACKBAR_SetTipSide (hwnd, wParam, lParam);
1703 case TBM_SETTOOLTIPS:
1704 return TRACKBAR_SetToolTips (hwnd, wParam, lParam);
1706 /* case TBM_SETUNICODEFORMAT: */
1709 case WM_CAPTURECHANGED:
1710 return TRACKBAR_CaptureChanged (hwnd, wParam, lParam);
1713 return TRACKBAR_Create (hwnd, wParam, lParam);
1716 return TRACKBAR_Destroy (hwnd, wParam, lParam);
1718 /* case WM_ENABLE: */
1720 /* case WM_ERASEBKGND: */
1724 return DLGC_WANTARROWS;
1727 return TRACKBAR_KeyDown (hwnd, wParam, lParam);
1730 return TRACKBAR_KeyUp (hwnd, wParam);
1733 return TRACKBAR_KillFocus (hwnd, wParam, lParam);
1735 case WM_LBUTTONDOWN:
1736 return TRACKBAR_LButtonDown (hwnd, wParam, lParam);
1739 return TRACKBAR_LButtonUp (hwnd, wParam, lParam);
1742 return TRACKBAR_MouseMove (hwnd, wParam, lParam);
1745 return TRACKBAR_Paint (hwnd, wParam);
1748 return TRACKBAR_SetFocus (hwnd, wParam, lParam);
1751 return TRACKBAR_Size (hwnd, wParam, lParam);
1753 case WM_WININICHANGE:
1754 return TRACKBAR_InitializeThumb (hwnd);
1757 if (uMsg >= WM_USER)
1758 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
1759 uMsg, wParam, lParam);
1760 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1767 TRACKBAR_Register (void)
1771 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1772 wndClass.style = CS_GLOBALCLASS;
1773 wndClass.lpfnWndProc = (WNDPROC)TRACKBAR_WindowProc;
1774 wndClass.cbClsExtra = 0;
1775 wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
1776 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
1777 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1778 wndClass.lpszClassName = TRACKBAR_CLASSA;
1780 RegisterClassA (&wndClass);
1785 TRACKBAR_Unregister (void)
1787 UnregisterClassA (TRACKBAR_CLASSA, (HINSTANCE)NULL);