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);
34 #define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)GetWindowLongA (hwnd,0))
37 /* Used by TRACKBAR_Refresh to find out which parts of the control
38 need to be recalculated */
40 #define TB_THUMBPOSCHANGED 1
41 #define TB_THUMBSIZECHANGED 2
42 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBPOSCHANGED)
43 #define TB_SELECTIONCHANGED 4
44 #define TB_DRAG_MODE 16 /* we're dragging the slider */
45 #define TB_DRAGPOSVALID 32 /* current Position is in dragPos */
46 #define TB_SHOW_TOOLTIP 64 /* tooltip-style enabled and tooltip on */
48 /* helper defines for TRACKBAR_DrawTic */
49 #define TIC_LEFTEDGE 0x20
50 #define TIC_RIGHTEDGE 0x40
51 #define TIC_EDGE (TIC_LEFTEDGE | TIC_RIGHTEDGE)
52 #define TIC_SELECTIONMARKMAX 0x80
53 #define TIC_SELECTIONMARKMIN 0x100
54 #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
56 static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code);
58 static void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
62 if (infoPtr->uTicFreq && infoPtr->nRangeMax >= infoPtr->nRangeMin)
63 nrTics=(infoPtr->nRangeMax - infoPtr->nRangeMin)/infoPtr->uTicFreq;
66 COMCTL32_Free (infoPtr->tics);
72 if (nrTics!=infoPtr->uNumTics) {
73 infoPtr->tics=COMCTL32_ReAlloc (infoPtr->tics,
74 (nrTics+1)*sizeof (DWORD));
75 infoPtr->uNumTics=nrTics;
77 infoPtr->uNumTics=nrTics;
78 tic=infoPtr->nRangeMin+infoPtr->uTicFreq;
79 for (i=0; i<nrTics; i++,tic+=infoPtr->uTicFreq)
84 /* converts from physical (mouse) position to logical position
85 (in range of trackbar) */
88 TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place,
91 double range,width,pos;
93 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
95 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
96 pos=(range*(place - infoPtr->rcChannel.top)) / width;
98 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
99 pos=(range*(place - infoPtr->rcChannel.left)) / width;
101 pos+=infoPtr->nRangeMin;
102 if (pos > infoPtr->nRangeMax)
103 pos = infoPtr->nRangeMax;
104 else if (pos < infoPtr->nRangeMin)
105 pos = infoPtr->nRangeMin;
113 TRACKBAR_CalcChannel (HWND hwnd, TRACKBAR_INFO *infoPtr)
115 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
116 INT cyChannel,offsettop,offsetedge;
117 RECT lpRect,*channel = & infoPtr->rcChannel;
119 GetClientRect (hwnd, &lpRect);
121 if (dwStyle & TBS_ENABLESELRANGE)
122 cyChannel = ((int)(infoPtr->uThumbLen/4.5)+1)*3;
126 offsettop = (int)(infoPtr->uThumbLen/4.5);
127 offsetedge = (int)(infoPtr->uThumbLen/4.5) + 3;
129 if (dwStyle & TBS_VERT) {
130 channel->top = lpRect.top + offsetedge;
131 channel->bottom = lpRect.bottom - offsetedge;
133 if (dwStyle & (TBS_BOTH | TBS_LEFT)) {
134 channel->left = lpRect.left + offsettop + 8 ;
135 channel->right = channel->left + cyChannel;
137 else { /* TBS_RIGHT */
138 channel->left = lpRect.left + offsettop;
139 channel->right = channel->left + cyChannel;
143 channel->left = lpRect.left + offsetedge;
144 channel->right = lpRect.right - offsetedge;
146 if (dwStyle & (TBS_BOTH|TBS_TOP)) {
147 channel->top = lpRect.top + offsettop + 8 ;
148 channel->bottom = channel->top + cyChannel;
150 else { /* TBS_BOTTOM */
151 channel->top = lpRect.top + offsettop;
152 channel->bottom = channel->top + cyChannel;
158 TRACKBAR_CalcThumb (HWND hwnd, TRACKBAR_INFO *infoPtr)
161 int range, width, thumbdepth;
162 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
164 thumb=&infoPtr->rcThumb;
165 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
166 thumbdepth = ((INT)((FLOAT)infoPtr->uThumbLen / 4.5) * 2) + 2;
168 if (!range) return; /* FIXME: may this happen? */
170 if (dwStyle & TBS_VERT)
172 width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
174 if (dwStyle & (TBS_BOTH | TBS_LEFT))
178 thumb->right = thumb -> left + infoPtr->uThumbLen;
179 thumb->top = infoPtr->rcChannel.top +
180 (width*infoPtr->nPos)/range - thumbdepth/2;
181 thumb->bottom = thumb->top + thumbdepth;
185 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
187 thumb->left = infoPtr->rcChannel.left +
188 (width*infoPtr->nPos)/range - thumbdepth/2;
189 thumb->right = thumb->left + thumbdepth;
190 if (dwStyle & (TBS_BOTH | TBS_TOP))
194 thumb->bottom = thumb -> top + infoPtr->uThumbLen;
199 TRACKBAR_CalcSelection (HWND hwnd, TRACKBAR_INFO *infoPtr)
204 selection= & infoPtr->rcSelection;
205 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
206 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
209 SetRectEmpty (selection);
211 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
212 selection->left = infoPtr->rcChannel.left +
213 (width*infoPtr->nSelMin)/range;
214 selection->right = infoPtr->rcChannel.left +
215 (width*infoPtr->nSelMax)/range;
216 selection->top = infoPtr->rcChannel.top + 2;
217 selection->bottom = infoPtr->rcChannel.bottom - 2;
219 selection->top = infoPtr->rcChannel.top +
220 (width*infoPtr->nSelMin)/range;
221 selection->bottom = infoPtr->rcChannel.top +
222 (width*infoPtr->nSelMax)/range;
223 selection->left = infoPtr->rcChannel.left + 2;
224 selection->right = infoPtr->rcChannel.right - 2;
228 /* Trackbar drawing code. I like my spaghetti done milanese. */
230 /* ticPos is in tic-units, not in pixels */
233 TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
234 int flags, COLORREF clrTic)
236 RECT rcChannel=infoPtr->rcChannel;
237 int x,y,width,range,side;
239 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
240 width=rcChannel.right - rcChannel.left;
242 if (flags & TBS_TOP) {
246 y=rcChannel.bottom+2;
250 if (flags & TIC_SELECTIONMARK) {
251 if (flags & TIC_SELECTIONMARKMIN)
252 x=rcChannel.left + (width*ticPos)/range - 1;
254 x=rcChannel.left + (width*ticPos)/range + 1;
256 SetPixel (hdc, x,y+6*side, clrTic);
257 SetPixel (hdc, x,y+7*side, clrTic);
261 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
262 x=rcChannel.left + (width*ticPos)/range;
263 SetPixel (hdc, x,y+5*side, clrTic);
264 SetPixel (hdc, x,y+6*side, clrTic);
265 SetPixel (hdc, x,y+7*side, clrTic);
268 if (flags & TIC_EDGE) {
269 if (flags & TIC_LEFTEDGE)
274 SetPixel (hdc, x,y+5*side, clrTic);
275 SetPixel (hdc, x,y+6*side, clrTic);
276 SetPixel (hdc, x,y+7*side, clrTic);
277 SetPixel (hdc, x,y+8*side, clrTic);
283 TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
284 int flags, COLORREF clrTic)
286 RECT rcChannel=infoPtr->rcChannel;
287 int x,y,width,range,side;
289 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
290 width=rcChannel.bottom - rcChannel.top;
292 if (flags & TBS_TOP) {
301 if (flags & TIC_SELECTIONMARK) {
302 if (flags & TIC_SELECTIONMARKMIN)
303 y=rcChannel.top + (width*ticPos)/range - 1;
305 y=rcChannel.top + (width*ticPos)/range + 1;
307 SetPixel (hdc, x+6*side, y, clrTic);
308 SetPixel (hdc, x+7*side, y, clrTic);
312 if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
313 y=rcChannel.top + (width*ticPos)/range;
314 SetPixel (hdc, x+5*side, y, clrTic);
315 SetPixel (hdc, x+6*side, y, clrTic);
316 SetPixel (hdc, x+7*side, y, clrTic);
319 if (flags & TIC_EDGE) {
320 if (flags & TIC_LEFTEDGE)
325 SetPixel (hdc, x+5*side, y, clrTic);
326 SetPixel (hdc, x+6*side, y, clrTic);
327 SetPixel (hdc, x+7*side, y, clrTic);
328 SetPixel (hdc, x+8*side, y, clrTic);
335 TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
336 int flags, COLORREF clrTic)
339 if (flags & TBS_VERT) {
340 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
341 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos,
342 flags | TBS_TOP , clrTic);
343 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
344 TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos, flags, clrTic);
348 if ((flags & TBS_TOP) || (flags & TBS_BOTH))
349 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags | TBS_TOP , clrTic);
351 if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
352 TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags, clrTic);
357 TRACKBAR_DrawThumb(TRACKBAR_INFO *infoPtr, HDC hdc, DWORD dwStyle)
359 HBRUSH oldbr,hbr = GetSysColorBrush(COLOR_BTNFACE);
360 HPEN oldpen=(HPEN)NULL,hpn;
361 RECT thumb = infoPtr->rcThumb;
366 static INT PointDepth = 4;
368 oldbr = SelectObject (hdc, hbr);
369 SetPolyFillMode (hdc,WINDING);
371 if (dwStyle & TBS_BOTH)
373 points[0].x=thumb.right;
374 points[0].y=thumb.top;
375 points[1].x=thumb.right;
376 points[1].y=thumb.bottom;
377 points[2].x=thumb.left;
378 points[2].y=thumb.bottom;
379 points[3].x=thumb.left;
380 points[3].y=thumb.top;
381 points[4].x=points[0].x;
382 points[4].y=points[0].y;
388 if (dwStyle & TBS_VERT)
390 if (dwStyle & TBS_LEFT)
392 points[0].x=thumb.right;
393 points[0].y=thumb.top;
394 points[1].x=thumb.right;
395 points[1].y=thumb.bottom;
396 points[2].x=thumb.left + PointDepth;
397 points[2].y=thumb.bottom;
398 points[3].x=thumb.left;
399 points[3].y=(thumb.bottom - thumb.top) / 2 + thumb.top;
400 points[4].x=thumb.left + PointDepth;
401 points[4].y=thumb.top;
402 points[5].x=points[0].x;
403 points[5].y=points[0].y;
408 points[0].x=thumb.right;
409 points[0].y=(thumb.bottom - thumb.top) / 2 + thumb.top;
410 points[1].x=thumb.right - PointDepth;
411 points[1].y=thumb.bottom;
412 points[2].x=thumb.left;
413 points[2].y=thumb.bottom;
414 points[3].x=thumb.left;
415 points[3].y=thumb.top;
416 points[4].x=thumb.right - PointDepth;
417 points[4].y=thumb.top;
418 points[5].x=points[0].x;
419 points[5].y=points[0].y;
424 if (dwStyle & TBS_TOP)
426 points[0].x=(thumb.right - thumb.left) / 2 + thumb.left ;
427 points[0].y=thumb.top;
428 points[1].x=thumb.right;
429 points[1].y=thumb.top + PointDepth;
430 points[2].x=thumb.right;
431 points[2].y=thumb.bottom;
432 points[3].x=thumb.left;
433 points[3].y=thumb.bottom;
434 points[4].x=thumb.left;
435 points[4].y=thumb.top + PointDepth;
436 points[5].x=points[0].x;
437 points[5].y=points[0].y;
442 points[0].x=thumb.right;
443 points[0].y=thumb.top;
444 points[1].x=thumb.right;
445 points[1].y=thumb.bottom - PointDepth;
446 points[2].x=(thumb.right - thumb.left) / 2 + thumb.left ;
447 points[2].y=thumb.bottom;
448 points[3].x=thumb.left;
449 points[3].y=thumb.bottom - PointDepth;
450 points[4].x=thumb.left;
451 points[4].y=thumb.top;
452 points[5].x=points[0].x;
453 points[5].y=points[0].y;
462 Polygon (hdc, points, PointCount);
467 hpn = GetStockObject(BLACK_PEN);
468 oldpen = SelectObject(hdc,hpn);
473 Polyline(hdc,points,BlackUntil);
475 SelectObject(hdc,oldpen);
476 hpn = GetStockObject(WHITE_PEN);
477 SelectObject(hdc,hpn);
482 Polyline(hdc,&points[BlackUntil-1],PointCount+1-BlackUntil);
485 * restore the brush and pen
487 SelectObject(hdc,oldbr);
489 SelectObject(hdc,oldpen);
493 TRACKBAR_Refresh (HWND hwnd, HDC hdc)
495 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
496 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
497 RECT rcClient, rcChannel, rcSelection;
501 GetClientRect (hwnd, &rcClient);
502 hBrush = CreateSolidBrush (infoPtr->clrBk);
503 FillRect (hdc, &rcClient, hBrush);
504 DeleteObject (hBrush);
506 if (infoPtr->flags & TB_DRAGPOSVALID) {
507 infoPtr->nPos=infoPtr->dragPos;
508 infoPtr->flags |= TB_THUMBPOSCHANGED;
511 if (infoPtr->flags & TB_THUMBCHANGED) {
512 TRACKBAR_CalcThumb (hwnd, infoPtr);
513 if (infoPtr->flags & TB_THUMBSIZECHANGED)
514 TRACKBAR_CalcChannel (hwnd, infoPtr);
516 if (infoPtr->flags & TB_SELECTIONCHANGED)
517 TRACKBAR_CalcSelection (hwnd, infoPtr);
518 infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED |
523 rcChannel = infoPtr->rcChannel;
524 rcSelection= infoPtr->rcSelection;
525 DrawEdge (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
527 if (dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
528 HBRUSH hbr = CreateSolidBrush (RGB(255,255,255));
529 FillRect (hdc, &rcChannel, hbr);
530 if (((dwStyle & TBS_VERT) &&
531 (rcSelection.left!=rcSelection.right)) ||
532 ((!(dwStyle & TBS_VERT)) &&
533 (rcSelection.left!=rcSelection.right))) {
534 hbr=CreateSolidBrush (COLOR_HIGHLIGHT);
535 FillRect (hdc, &rcSelection, hbr);
543 if (!(dwStyle & TBS_NOTICKS)) {
544 int ticFlags = dwStyle & 0x0f;
545 COLORREF clrTic=GetSysColor (COLOR_3DDKSHADOW);
547 for (i=0; i<infoPtr->uNumTics; i++)
548 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->tics[i],
551 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_LEFTEDGE, clrTic);
552 TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_RIGHTEDGE, clrTic);
554 if ((dwStyle & TBS_ENABLESELRANGE) &&
555 (rcSelection.left!=rcSelection.right)) {
556 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMin,
557 ticFlags | TIC_SELECTIONMARKMIN, clrTic);
558 TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMax,
559 ticFlags | TIC_SELECTIONMARKMAX, clrTic);
565 if (!(dwStyle & TBS_NOTHUMB))
567 TRACKBAR_DrawThumb(infoPtr,hdc,dwStyle);
571 DrawFocusRect (hdc, &rcClient);
576 TRACKBAR_AlignBuddies (HWND hwnd, TRACKBAR_INFO *infoPtr)
578 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
579 HWND hwndParent = GetParent (hwnd);
580 RECT rcSelf, rcBuddy;
583 GetWindowRect (hwnd, &rcSelf);
584 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcSelf, 2);
586 /* align buddy left or above */
587 if (infoPtr->hwndBuddyLA) {
588 GetWindowRect (infoPtr->hwndBuddyLA, &rcBuddy);
589 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
591 if (dwStyle & TBS_VERT) {
592 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
593 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
594 y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
597 x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
598 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
599 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
602 SetWindowPos (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
603 SWP_NOZORDER | SWP_NOSIZE);
607 /* align buddy right or below */
608 if (infoPtr->hwndBuddyRB) {
609 GetWindowRect (infoPtr->hwndBuddyRB, &rcBuddy);
610 MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
612 if (dwStyle & TBS_VERT) {
613 x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
614 (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
619 y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
620 (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
622 SetWindowPos (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
623 SWP_NOZORDER | SWP_NOSIZE);
629 TRACKBAR_ClearSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
631 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
633 infoPtr->nSelMin = 0;
634 infoPtr->nSelMax = 0;
635 infoPtr->flags |= TB_SELECTIONCHANGED;
638 InvalidateRect (hwnd, NULL, FALSE);
645 TRACKBAR_ClearTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
647 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
650 COMCTL32_Free (infoPtr->tics);
651 infoPtr->tics = NULL;
652 infoPtr->uNumTics = 0;
656 InvalidateRect (hwnd, NULL, FALSE);
663 TRACKBAR_GetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
665 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
667 if (wParam) /* buddy is left or above */
668 return (LRESULT)infoPtr->hwndBuddyLA;
670 /* buddy is right or below */
671 return (LRESULT) infoPtr->hwndBuddyRB;
676 TRACKBAR_GetChannelRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
678 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
679 LPRECT lprc = (LPRECT)lParam;
684 lprc->left = infoPtr->rcChannel.left;
685 lprc->right = infoPtr->rcChannel.right;
686 lprc->bottom = infoPtr->rcChannel.bottom;
687 lprc->top = infoPtr->rcChannel.top;
694 TRACKBAR_GetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
696 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
698 return infoPtr->nLineSize;
703 TRACKBAR_GetNumTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
705 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
707 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_NOTICKS)
710 return infoPtr->uNumTics+2;
715 TRACKBAR_GetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
717 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
719 return infoPtr->nPageSize;
724 TRACKBAR_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
726 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
728 return infoPtr->nPos;
733 TRACKBAR_GetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
735 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
737 return infoPtr->nRangeMax;
742 TRACKBAR_GetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
744 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
746 return infoPtr->nRangeMin;
751 TRACKBAR_GetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
753 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
755 return infoPtr->nSelMax;
760 TRACKBAR_GetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
762 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
764 return infoPtr->nSelMin;
769 TRACKBAR_GetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
771 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
773 return infoPtr->uThumbLen;
777 TRACKBAR_GetPTics (HWND hwnd)
779 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
781 return (LRESULT) infoPtr->tics;
785 TRACKBAR_GetThumbRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
787 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
788 LPRECT lprc = (LPRECT)lParam;
793 lprc->left = infoPtr->rcThumb.left;
794 lprc->right = infoPtr->rcThumb.right;
795 lprc->bottom = infoPtr->rcThumb.bottom;
796 lprc->top = infoPtr->rcThumb.top;
803 TRACKBAR_GetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
805 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
809 if ((iTic<0) || (iTic>infoPtr->uNumTics))
812 return (LRESULT) infoPtr->tics[iTic];
818 TRACKBAR_GetTicPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
820 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
821 INT iTic, range, width, pos;
825 if ((iTic<0) || (iTic>infoPtr->uNumTics))
828 range=infoPtr->nRangeMax - infoPtr->nRangeMin;
829 width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
830 pos=infoPtr->rcChannel.left + (width * infoPtr->tics[iTic]) / range;
833 return (LRESULT) pos;
838 TRACKBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
840 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
842 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
843 return (LRESULT)infoPtr->hwndToolTip;
848 /* case TBM_GETUNICODEFORMAT: */
852 TRACKBAR_SetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
854 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
858 /* buddy is left or above */
859 hwndTemp = infoPtr->hwndBuddyLA;
860 infoPtr->hwndBuddyLA = (HWND)lParam;
862 FIXME("move buddy!\n");
865 /* buddy is right or below */
866 hwndTemp = infoPtr->hwndBuddyRB;
867 infoPtr->hwndBuddyRB = (HWND)lParam;
869 FIXME("move buddy!\n");
872 TRACKBAR_AlignBuddies (hwnd, infoPtr);
874 return (LRESULT)hwndTemp;
879 TRACKBAR_SetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
881 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
882 INT nTemp = infoPtr->nLineSize;
884 infoPtr->nLineSize = (INT)lParam;
891 TRACKBAR_SetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
893 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
894 INT nTemp = infoPtr->nPageSize;
896 infoPtr->nPageSize = (INT)lParam;
903 TRACKBAR_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
905 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
907 infoPtr->nPos = (INT)lParam;
909 if (infoPtr->nPos < infoPtr->nRangeMin)
910 infoPtr->nPos = infoPtr->nRangeMin;
912 if (infoPtr->nPos > infoPtr->nRangeMax)
913 infoPtr->nPos = infoPtr->nRangeMax;
914 infoPtr->flags |= TB_THUMBPOSCHANGED;
917 InvalidateRect (hwnd, NULL, FALSE);
924 TRACKBAR_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
926 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
927 infoPtr->nRangeMin = (INT)LOWORD(lParam);
928 infoPtr->nRangeMax = (INT)HIWORD(lParam);
930 if (infoPtr->nPos < infoPtr->nRangeMin) {
931 infoPtr->nPos = infoPtr->nRangeMin;
932 infoPtr->flags |=TB_THUMBPOSCHANGED;
935 if (infoPtr->nPos > infoPtr->nRangeMax) {
936 infoPtr->nPos = infoPtr->nRangeMax;
937 infoPtr->flags |=TB_THUMBPOSCHANGED;
940 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
941 if (infoPtr->nPageSize == 0)
942 infoPtr->nPageSize = 1;
943 TRACKBAR_RecalculateTics (infoPtr);
946 InvalidateRect (hwnd, NULL, FALSE);
953 TRACKBAR_SetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
955 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
957 infoPtr->nRangeMax = (INT)lParam;
958 if (infoPtr->nPos > infoPtr->nRangeMax) {
959 infoPtr->nPos = infoPtr->nRangeMax;
960 infoPtr->flags |=TB_THUMBPOSCHANGED;
963 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
964 if (infoPtr->nPageSize == 0)
965 infoPtr->nPageSize = 1;
966 TRACKBAR_RecalculateTics (infoPtr);
969 InvalidateRect (hwnd, NULL, FALSE);
976 TRACKBAR_SetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
978 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
980 infoPtr->nRangeMin = (INT)lParam;
981 if (infoPtr->nPos < infoPtr->nRangeMin) {
982 infoPtr->nPos = infoPtr->nRangeMin;
983 infoPtr->flags |=TB_THUMBPOSCHANGED;
986 infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
987 if (infoPtr->nPageSize == 0)
988 infoPtr->nPageSize = 1;
989 TRACKBAR_RecalculateTics (infoPtr);
992 InvalidateRect (hwnd, NULL, FALSE);
999 TRACKBAR_SetTicFreq (HWND hwnd, WPARAM wParam)
1001 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1003 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_AUTOTICKS)
1004 infoPtr->uTicFreq=(UINT) wParam;
1006 TRACKBAR_RecalculateTics (infoPtr);
1008 InvalidateRect (hwnd, NULL, FALSE);
1015 TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
1017 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1019 infoPtr->nSelMin = (INT)LOWORD(lParam);
1020 infoPtr->nSelMax = (INT)HIWORD(lParam);
1021 infoPtr->flags |=TB_SELECTIONCHANGED;
1023 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
1026 if (infoPtr->nSelMin < infoPtr->nRangeMin)
1027 infoPtr->nSelMin = infoPtr->nRangeMin;
1028 if (infoPtr->nSelMax > infoPtr->nRangeMax)
1029 infoPtr->nSelMax = infoPtr->nRangeMax;
1032 InvalidateRect (hwnd, NULL, FALSE);
1040 TRACKBAR_SetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
1042 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1044 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
1047 infoPtr->nSelMax = (INT)lParam;
1048 infoPtr->flags |= TB_SELECTIONCHANGED;
1050 if (infoPtr->nSelMax > infoPtr->nRangeMax)
1051 infoPtr->nSelMax = infoPtr->nRangeMax;
1054 InvalidateRect (hwnd, NULL, FALSE);
1061 TRACKBAR_SetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
1063 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1065 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
1068 infoPtr->nSelMin = (INT)lParam;
1069 infoPtr->flags |=TB_SELECTIONCHANGED;
1071 if (infoPtr->nSelMin < infoPtr->nRangeMin)
1072 infoPtr->nSelMin = infoPtr->nRangeMin;
1075 InvalidateRect (hwnd, NULL, FALSE);
1082 TRACKBAR_SetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
1084 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1086 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_FIXEDLENGTH)
1087 infoPtr->uThumbLen = (UINT)wParam;
1089 infoPtr->flags |= TB_THUMBSIZECHANGED;
1091 InvalidateRect (hwnd, NULL, FALSE);
1098 TRACKBAR_SetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
1100 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1101 INT nPos = (INT)lParam;
1103 if ((nPos < infoPtr->nRangeMin) || (nPos> infoPtr->nRangeMax))
1106 infoPtr->uNumTics++;
1107 infoPtr->tics=COMCTL32_ReAlloc( infoPtr->tics,
1108 (infoPtr->uNumTics)*sizeof (DWORD));
1109 infoPtr->tics[infoPtr->uNumTics-1]=nPos;
1111 InvalidateRect (hwnd, NULL, FALSE);
1118 TRACKBAR_SetTipSide (HWND hwnd, WPARAM wParam, LPARAM lParam)
1120 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1121 INT fTemp = infoPtr->fLocation;
1123 infoPtr->fLocation = (INT)wParam;
1130 TRACKBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1132 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1134 infoPtr->hwndToolTip = (HWND)wParam;
1140 /* case TBM_SETUNICODEFORMAT: */
1144 TRACKBAR_InitializeThumb (HWND hwnd)
1146 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1148 infoPtr->uThumbLen = 23; /* initial thumb length */
1150 TRACKBAR_CalcChannel (hwnd,infoPtr);
1151 TRACKBAR_CalcThumb (hwnd, infoPtr);
1152 infoPtr->flags &= ~TB_SELECTIONCHANGED;
1159 TRACKBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1161 TRACKBAR_INFO *infoPtr;
1163 infoPtr = (TRACKBAR_INFO *)COMCTL32_Alloc (sizeof(TRACKBAR_INFO));
1164 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1166 /* set default values */
1167 infoPtr->nRangeMin = 0;
1168 infoPtr->nRangeMax = 100;
1169 infoPtr->nLineSize = 1;
1170 infoPtr->nPageSize = 20;
1171 infoPtr->nSelMin = 0;
1172 infoPtr->nSelMax = 0;
1175 infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
1176 infoPtr->uTicFreq = 1;
1177 infoPtr->tics = NULL;
1178 infoPtr->clrBk = GetSysColor (COLOR_BTNFACE);
1179 infoPtr->hwndNotify = GetParent (hwnd);
1181 TRACKBAR_InitializeThumb (hwnd);
1183 /* Create tooltip control */
1184 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) {
1187 infoPtr->hwndToolTip =
1188 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
1189 CW_USEDEFAULT, CW_USEDEFAULT,
1190 CW_USEDEFAULT, CW_USEDEFAULT,
1193 /* Send NM_TOOLTIPSCREATED notification */
1194 if (infoPtr->hwndToolTip) {
1195 NMTOOLTIPSCREATED nmttc;
1197 nmttc.hdr.hwndFrom = hwnd;
1198 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1199 nmttc.hdr.code = NM_TOOLTIPSCREATED;
1200 nmttc.hwndToolTips = infoPtr->hwndToolTip;
1202 SendMessageA (GetParent (hwnd), WM_NOTIFY,
1203 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
1206 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1207 ti.cbSize = sizeof(TTTOOLINFOA);
1208 ti.uFlags = TTF_IDISHWND | TTF_TRACK;
1211 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */
1212 SetRectEmpty (&ti.rect);
1214 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
1222 TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1224 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1226 /* delete tooltip control */
1227 if (infoPtr->hwndToolTip)
1228 DestroyWindow (infoPtr->hwndToolTip);
1230 COMCTL32_Free (infoPtr);
1231 SetWindowLongA (hwnd, 0, 0);
1237 TRACKBAR_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1239 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1243 infoPtr->bFocus = FALSE;
1244 infoPtr->flags &= ~TB_DRAG_MODE;
1246 InvalidateRect (hwnd, NULL, FALSE);
1253 TRACKBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1255 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1256 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1261 clickPoint.y = HIWORD(lParam);
1262 clickPoint.x = LOWORD(lParam);
1264 if (PtInRect(&(infoPtr->rcThumb),clickPoint))
1266 infoPtr->flags |= TB_DRAG_MODE;
1267 if (dwStyle & TBS_TOOLTIPS) { /* enable tooltip */
1272 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,
1273 (LPARAM)MAKELPARAM(pt.x, pt.y));
1275 ti.cbSize = sizeof(TTTOOLINFOA);
1277 ti.hwnd = (UINT)hwnd;
1279 infoPtr->flags |= TB_SHOW_TOOLTIP;
1281 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1282 (WPARAM)TRUE, (LPARAM)&ti);
1286 else if (PtInRect(&(infoPtr->rcChannel),clickPoint))
1288 int clickPlace,prevPos,vertical;
1291 vertical = (dwStyle & TBS_VERT) ? 1 : 0;
1293 clickPlace=(INT)HIWORD(lParam);
1295 clickPlace=(INT)LOWORD(lParam);
1297 clickPos = TRACKBAR_ConvertPlaceToPosition(infoPtr, clickPlace,
1299 prevPos = infoPtr->nPos;
1300 if (clickPos > (int)prevPos)
1301 { /* similar to VK_NEXT */
1302 infoPtr->nPos += infoPtr->nPageSize;
1303 if (infoPtr->nPos > infoPtr->nRangeMax)
1304 infoPtr->nPos = infoPtr->nRangeMax;
1305 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1309 infoPtr->nPos -= infoPtr->nPageSize; /* similar to VK_PRIOR */
1310 if (infoPtr->nPos < infoPtr->nRangeMin)
1311 infoPtr->nPos = infoPtr->nRangeMin;
1312 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1315 if (prevPos!=infoPtr->nPos) {
1316 infoPtr->flags |= TB_THUMBPOSCHANGED;
1317 InvalidateRect (hwnd, NULL, FALSE);
1326 TRACKBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
1328 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1330 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1332 if (infoPtr->flags & TB_DRAG_MODE)
1334 infoPtr->flags &= ~TB_DRAG_MODE;
1338 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) { /* disable tooltip */
1341 ti.cbSize = sizeof(TTTOOLINFOA);
1343 ti.hwnd = (UINT)hwnd;
1345 infoPtr->flags &= ~TB_SHOW_TOOLTIP;
1346 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
1347 (WPARAM)FALSE, (LPARAM)&ti);
1350 InvalidateRect (hwnd, NULL, FALSE);
1357 TRACKBAR_CaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
1359 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1361 if (infoPtr->flags & TB_DRAGPOSVALID) {
1362 infoPtr->nPos=infoPtr->dragPos;
1363 InvalidateRect (hwnd, NULL, FALSE);
1366 infoPtr->flags &= ~ TB_DRAGPOSVALID;
1368 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1374 TRACKBAR_Paint (HWND hwnd, WPARAM wParam)
1379 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1380 TRACKBAR_Refresh (hwnd, hdc);
1382 EndPaint (hwnd, &ps);
1388 TRACKBAR_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1390 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1393 infoPtr->bFocus = TRUE;
1395 InvalidateRect (hwnd, NULL, FALSE);
1402 TRACKBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1404 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1406 TRACKBAR_CalcChannel (hwnd, infoPtr);
1407 TRACKBAR_AlignBuddies (hwnd, infoPtr);
1414 TRACKBAR_SendNotify (HWND hwnd, UINT code)
1418 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT)
1419 return (BOOL) SendMessageA (GetParent (hwnd),
1420 WM_VSCROLL, (WPARAM)code, (LPARAM)hwnd);
1422 return (BOOL) SendMessageA (GetParent (hwnd),
1423 WM_HSCROLL, (WPARAM)code, (LPARAM)hwnd);
1428 TRACKBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1430 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1431 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1436 TRACE("%x\n",wParam);
1438 if (dwStyle & TBS_VERT)
1439 clickPlace=(SHORT)HIWORD(lParam);
1441 clickPlace=(SHORT)LOWORD(lParam);
1443 if (!(infoPtr->flags & TB_DRAG_MODE))
1447 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace,
1448 dwStyle & TBS_VERT);
1449 if (dragPos > ((INT)dragPos) + 0.5)
1450 infoPtr->dragPos = dragPos + 1;
1452 infoPtr->dragPos = dragPos;
1454 infoPtr->flags |= TB_DRAGPOSVALID;
1455 TRACKBAR_SendNotify (hwnd, TB_THUMBTRACK | (infoPtr->nPos<<16));
1457 if (infoPtr->flags & TB_SHOW_TOOLTIP) {
1461 ti.cbSize = sizeof(TTTOOLINFOA);
1465 sprintf (buf,"%d",infoPtr->nPos);
1466 ti.lpszText = (LPSTR) buf;
1469 if (dwStyle & TBS_VERT) {
1470 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1471 0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15));
1473 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
1474 0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5));
1476 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
1480 InvalidateRect (hwnd, NULL, FALSE);
1481 UpdateWindow (hwnd);
1488 TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1490 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
1493 TRACE("%x\n",wParam);
1499 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1500 infoPtr->nPos -= infoPtr->nLineSize;
1501 if (infoPtr->nPos < infoPtr->nRangeMin)
1502 infoPtr->nPos = infoPtr->nRangeMin;
1503 TRACKBAR_SendNotify (hwnd, TB_LINEUP);
1507 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1508 infoPtr->nPos += infoPtr->nLineSize;
1509 if (infoPtr->nPos > infoPtr->nRangeMax)
1510 infoPtr->nPos = infoPtr->nRangeMax;
1511 TRACKBAR_SendNotify (hwnd, TB_LINEDOWN);
1514 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1515 infoPtr->nPos += infoPtr->nPageSize;
1516 if (infoPtr->nPos > infoPtr->nRangeMax)
1517 infoPtr->nPos = infoPtr->nRangeMax;
1518 TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
1521 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1522 infoPtr->nPos -= infoPtr->nPageSize;
1523 if (infoPtr->nPos < infoPtr->nRangeMin)
1524 infoPtr->nPos = infoPtr->nRangeMin;
1525 TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
1528 if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
1529 infoPtr->nPos = infoPtr->nRangeMin;
1530 TRACKBAR_SendNotify (hwnd, TB_TOP);
1533 if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
1534 infoPtr->nPos = infoPtr->nRangeMax;
1535 TRACKBAR_SendNotify (hwnd, TB_BOTTOM);
1539 if (pos!=infoPtr->nPos) {
1540 infoPtr->flags |=TB_THUMBPOSCHANGED;
1541 InvalidateRect (hwnd, NULL, FALSE);
1549 TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
1560 TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
1566 static LRESULT WINAPI
1567 TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1569 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
1570 if (!TRACKBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
1571 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1575 return TRACKBAR_ClearSel (hwnd, wParam, lParam);
1578 return TRACKBAR_ClearTics (hwnd, wParam, lParam);
1581 return TRACKBAR_GetBuddy (hwnd, wParam, lParam);
1583 case TBM_GETCHANNELRECT:
1584 return TRACKBAR_GetChannelRect (hwnd, wParam, lParam);
1586 case TBM_GETLINESIZE:
1587 return TRACKBAR_GetLineSize (hwnd, wParam, lParam);
1589 case TBM_GETNUMTICS:
1590 return TRACKBAR_GetNumTics (hwnd, wParam, lParam);
1592 case TBM_GETPAGESIZE:
1593 return TRACKBAR_GetPageSize (hwnd, wParam, lParam);
1596 return TRACKBAR_GetPos (hwnd, wParam, lParam);
1599 return TRACKBAR_GetPTics (hwnd);
1601 case TBM_GETRANGEMAX:
1602 return TRACKBAR_GetRangeMax (hwnd, wParam, lParam);
1604 case TBM_GETRANGEMIN:
1605 return TRACKBAR_GetRangeMin (hwnd, wParam, lParam);
1608 return TRACKBAR_GetSelEnd (hwnd, wParam, lParam);
1610 case TBM_GETSELSTART:
1611 return TRACKBAR_GetSelStart (hwnd, wParam, lParam);
1613 case TBM_GETTHUMBLENGTH:
1614 return TRACKBAR_GetThumbLength (hwnd, wParam, lParam);
1616 case TBM_GETTHUMBRECT:
1617 return TRACKBAR_GetThumbRect (hwnd, wParam, lParam);
1620 return TRACKBAR_GetTic (hwnd, wParam, lParam);
1623 return TRACKBAR_GetTicPos (hwnd, wParam, lParam);
1625 case TBM_GETTOOLTIPS:
1626 return TRACKBAR_GetToolTips (hwnd, wParam, lParam);
1628 /* case TBM_GETUNICODEFORMAT: */
1631 return TRACKBAR_SetBuddy (hwnd, wParam, lParam);
1633 case TBM_SETLINESIZE:
1634 return TRACKBAR_SetLineSize (hwnd, wParam, lParam);
1636 case TBM_SETPAGESIZE:
1637 return TRACKBAR_SetPageSize (hwnd, wParam, lParam);
1640 return TRACKBAR_SetPos (hwnd, wParam, lParam);
1643 return TRACKBAR_SetRange (hwnd, wParam, lParam);
1645 case TBM_SETRANGEMAX:
1646 return TRACKBAR_SetRangeMax (hwnd, wParam, lParam);
1648 case TBM_SETRANGEMIN:
1649 return TRACKBAR_SetRangeMin (hwnd, wParam, lParam);
1652 return TRACKBAR_SetSel (hwnd, wParam, lParam);
1655 return TRACKBAR_SetSelEnd (hwnd, wParam, lParam);
1657 case TBM_SETSELSTART:
1658 return TRACKBAR_SetSelStart (hwnd, wParam, lParam);
1660 case TBM_SETTHUMBLENGTH:
1661 return TRACKBAR_SetThumbLength (hwnd, wParam, lParam);
1664 return TRACKBAR_SetTic (hwnd, wParam, lParam);
1666 case TBM_SETTICFREQ:
1667 return TRACKBAR_SetTicFreq (hwnd, wParam);
1669 case TBM_SETTIPSIDE:
1670 return TRACKBAR_SetTipSide (hwnd, wParam, lParam);
1672 case TBM_SETTOOLTIPS:
1673 return TRACKBAR_SetToolTips (hwnd, wParam, lParam);
1675 /* case TBM_SETUNICODEFORMAT: */
1678 case WM_CAPTURECHANGED:
1679 return TRACKBAR_CaptureChanged (hwnd, wParam, lParam);
1682 return TRACKBAR_Create (hwnd, wParam, lParam);
1685 return TRACKBAR_Destroy (hwnd, wParam, lParam);
1687 /* case WM_ENABLE: */
1689 /* case WM_ERASEBKGND: */
1693 return DLGC_WANTARROWS;
1696 return TRACKBAR_KeyDown (hwnd, wParam, lParam);
1699 return TRACKBAR_KeyUp (hwnd, wParam);
1702 return TRACKBAR_KillFocus (hwnd, wParam, lParam);
1704 case WM_LBUTTONDOWN:
1705 return TRACKBAR_LButtonDown (hwnd, wParam, lParam);
1708 return TRACKBAR_LButtonUp (hwnd, wParam, lParam);
1711 return TRACKBAR_MouseMove (hwnd, wParam, lParam);
1714 return TRACKBAR_Paint (hwnd, wParam);
1717 return TRACKBAR_SetFocus (hwnd, wParam, lParam);
1720 return TRACKBAR_Size (hwnd, wParam, lParam);
1722 case WM_WININICHANGE:
1723 return TRACKBAR_InitializeThumb (hwnd);
1726 if (uMsg >= WM_USER)
1727 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
1728 uMsg, wParam, lParam);
1729 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1736 TRACKBAR_Register (void)
1740 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1741 wndClass.style = CS_GLOBALCLASS;
1742 wndClass.lpfnWndProc = (WNDPROC)TRACKBAR_WindowProc;
1743 wndClass.cbClsExtra = 0;
1744 wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
1745 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
1746 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1747 wndClass.lpszClassName = TRACKBAR_CLASSA;
1749 RegisterClassA (&wndClass);
1754 TRACKBAR_Unregister (void)
1756 UnregisterClassA (TRACKBAR_CLASSA, (HINSTANCE)NULL);