ddraw/tests: Rewrite LimitTest().
[wine.git] / dlls / comctl32 / updown.c
blob4f44b9032a7c7d21199f3c2a8462339f8e503cf8
1 /*
2 * Updown control
4 * Copyright 1997, 2002 Dimitrie O. Paun
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * NOTE
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features, or bugs, please note them below.
31 #include <stdlib.h>
32 #include <string.h>
33 #include <stdarg.h>
34 #include <stdio.h>
36 #include "windef.h"
37 #include "winbase.h"
38 #include "wingdi.h"
39 #include "winuser.h"
40 #include "winnls.h"
41 #include "commctrl.h"
42 #include "comctl32.h"
43 #include "uxtheme.h"
44 #include "vssym32.h"
45 #include "wine/unicode.h"
46 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(updown);
50 typedef struct
52 HWND Self; /* Handle to this up-down control */
53 HWND Notify; /* Handle to the parent window */
54 DWORD dwStyle; /* The GWL_STYLE for this window */
55 UINT AccelCount; /* Number of elements in AccelVect */
56 UDACCEL* AccelVect; /* Vector containing AccelCount elements */
57 INT AccelIndex; /* Current accel index, -1 if not accel'ing */
58 INT Base; /* Base to display nr in the buddy window */
59 INT CurVal; /* Current up-down value */
60 INT MinVal; /* Minimum up-down value */
61 INT MaxVal; /* Maximum up-down value */
62 HWND Buddy; /* Handle to the buddy window */
63 INT BuddyType; /* Remembers the buddy type BUDDY_TYPE_* */
64 INT Flags; /* Internal Flags FLAG_* */
65 BOOL UnicodeFormat; /* Marks the use of Unicode internally */
66 } UPDOWN_INFO;
68 /* Control configuration constants */
70 #define INITIAL_DELAY 500 /* initial timer until auto-inc kicks in */
71 #define AUTOPRESS_DELAY 250 /* time to keep arrow pressed on KEY_DOWN */
72 #define REPEAT_DELAY 50 /* delay between auto-increments */
74 #define DEFAULT_WIDTH 16 /* default width of the ctrl */
75 #define DEFAULT_XSEP 0 /* default separation between buddy and ctrl */
76 #define DEFAULT_ADDTOP 0 /* amount to extend above the buddy window */
77 #define DEFAULT_ADDBOT 0 /* amount to extend below the buddy window */
78 #define DEFAULT_BUDDYBORDER 2 /* Width/height of the buddy border */
79 #define DEFAULT_BUDDYSPACER 2 /* Spacer between the buddy and the ctrl */
80 #define DEFAULT_BUDDYBORDER_THEMED 1 /* buddy border when theming is enabled */
81 #define DEFAULT_BUDDYSPACER_THEMED 0 /* buddy spacer when theming is enabled */
83 /* Work constants */
85 #define FLAG_INCR 0x01
86 #define FLAG_DECR 0x02
87 #define FLAG_MOUSEIN 0x04
88 #define FLAG_PRESSED 0x08
89 #define FLAG_BUDDYINT 0x10 /* UDS_SETBUDDYINT was set on creation */
90 #define FLAG_ARROW (FLAG_INCR | FLAG_DECR)
92 #define BUDDY_TYPE_UNKNOWN 0
93 #define BUDDY_TYPE_LISTBOX 1
94 #define BUDDY_TYPE_EDIT 2
96 #define TIMER_AUTOREPEAT 1
97 #define TIMER_ACCEL 2
98 #define TIMER_AUTOPRESS 3
100 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))
101 #define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
103 /* id used for SetWindowSubclass */
104 #define BUDDY_SUBCLASSID 1
106 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action);
108 /***********************************************************************
109 * UPDOWN_IsBuddyEdit
110 * Tests if our buddy is an edit control.
112 static inline BOOL UPDOWN_IsBuddyEdit(const UPDOWN_INFO *infoPtr)
114 return infoPtr->BuddyType == BUDDY_TYPE_EDIT;
117 /***********************************************************************
118 * UPDOWN_IsBuddyListbox
119 * Tests if our buddy is a listbox control.
121 static inline BOOL UPDOWN_IsBuddyListbox(const UPDOWN_INFO *infoPtr)
123 return infoPtr->BuddyType == BUDDY_TYPE_LISTBOX;
126 /***********************************************************************
127 * UPDOWN_InBounds
128 * Tests if a given value 'val' is between the Min&Max limits
130 static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
132 if(infoPtr->MaxVal > infoPtr->MinVal)
133 return (infoPtr->MinVal <= val) && (val <= infoPtr->MaxVal);
134 else
135 return (infoPtr->MaxVal <= val) && (val <= infoPtr->MinVal);
138 /***********************************************************************
139 * UPDOWN_OffsetVal
140 * Change the current value by delta.
141 * It returns TRUE is the value was changed successfully, or FALSE
142 * if the value was not changed, as it would go out of bounds.
144 static BOOL UPDOWN_OffsetVal(UPDOWN_INFO *infoPtr, int delta)
146 /* check if we can do the modification first */
147 if(!UPDOWN_InBounds (infoPtr, infoPtr->CurVal+delta)) {
148 if (infoPtr->dwStyle & UDS_WRAP) {
149 delta += (delta < 0 ? -1 : 1) *
150 (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) *
151 (infoPtr->MinVal - infoPtr->MaxVal) +
152 (delta < 0 ? 1 : -1);
153 } else if ((infoPtr->MaxVal > infoPtr->MinVal && infoPtr->CurVal+delta > infoPtr->MaxVal)
154 || (infoPtr->MaxVal < infoPtr->MinVal && infoPtr->CurVal+delta < infoPtr->MaxVal)) {
155 delta = infoPtr->MaxVal - infoPtr->CurVal;
156 } else {
157 delta = infoPtr->MinVal - infoPtr->CurVal;
161 infoPtr->CurVal += delta;
162 return delta != 0;
165 /***********************************************************************
166 * UPDOWN_HasBuddyBorder
168 * When we have a buddy set and that we are aligned on our buddy, we
169 * want to draw a sunken edge to make like we are part of that control.
171 static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr)
173 return ( ((infoPtr->dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) &&
174 UPDOWN_IsBuddyEdit(infoPtr) );
177 /***********************************************************************
178 * UPDOWN_GetArrowRect
179 * wndPtr - pointer to the up-down wnd
180 * rect - will hold the rectangle
181 * arrow - FLAG_INCR to get the "increment" rect (up or right)
182 * FLAG_DECR to get the "decrement" rect (down or left)
183 * If both flags are present, the envelope is returned.
185 static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, int arrow)
187 HTHEME theme = GetWindowTheme (infoPtr->Self);
188 const int border = theme ? DEFAULT_BUDDYBORDER_THEMED : DEFAULT_BUDDYBORDER;
189 const int spacer = theme ? DEFAULT_BUDDYSPACER_THEMED : DEFAULT_BUDDYSPACER;
190 GetClientRect (infoPtr->Self, rect);
193 * Make sure we calculate the rectangle to fit even if we draw the
194 * border.
196 if (UPDOWN_HasBuddyBorder(infoPtr)) {
197 if (infoPtr->dwStyle & UDS_ALIGNLEFT)
198 rect->left += border;
199 else
200 rect->right -= border;
202 InflateRect(rect, 0, -border);
205 /* now figure out if we need a space away from the buddy */
206 if (IsWindow(infoPtr->Buddy) ) {
207 if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= spacer;
208 else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) rect->left += spacer;
212 * We're calculating the midpoint to figure-out where the
213 * separation between the buttons will lay. We make sure that we
214 * round the uneven numbers by adding 1.
216 if (infoPtr->dwStyle & UDS_HORZ) {
217 int len = rect->right - rect->left + 1; /* compute the width */
218 if (arrow & FLAG_INCR)
219 rect->left = rect->left + len/2;
220 if (arrow & FLAG_DECR)
221 rect->right = rect->left + len/2 - (theme ? 0 : 1);
222 } else {
223 int len = rect->bottom - rect->top + 1; /* compute the height */
224 if (arrow & FLAG_INCR)
225 rect->bottom = rect->top + len/2 - (theme ? 0 : 1);
226 if (arrow & FLAG_DECR)
227 rect->top = rect->top + len/2;
231 /***********************************************************************
232 * UPDOWN_GetArrowFromPoint
233 * Returns the rectagle (for the up or down arrow) that contains pt.
234 * If it returns the up rect, it returns FLAG_INCR.
235 * If it returns the down rect, it returns FLAG_DECR.
237 static INT UPDOWN_GetArrowFromPoint (const UPDOWN_INFO *infoPtr, RECT *rect, POINT pt)
239 UPDOWN_GetArrowRect (infoPtr, rect, FLAG_INCR);
240 if(PtInRect(rect, pt)) return FLAG_INCR;
242 UPDOWN_GetArrowRect (infoPtr, rect, FLAG_DECR);
243 if(PtInRect(rect, pt)) return FLAG_DECR;
245 return 0;
249 /***********************************************************************
250 * UPDOWN_GetThousandSep
251 * Returns the thousand sep. If an error occurs, it returns ','.
253 static WCHAR UPDOWN_GetThousandSep(void)
255 WCHAR sep[2];
257 if(GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, sep, 2) != 1)
258 sep[0] = ',';
260 return sep[0];
263 /***********************************************************************
264 * UPDOWN_GetBuddyInt
265 * Tries to read the pos from the buddy window and if it succeeds,
266 * it stores it in the control's CurVal
267 * returns:
268 * TRUE - if it read the integer from the buddy successfully
269 * FALSE - if an error occurred
271 static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
273 WCHAR txt[20], sep, *src, *dst;
274 int newVal;
276 if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
277 return FALSE;
279 /*if the buddy is a list window, we must set curr index */
280 if (UPDOWN_IsBuddyListbox(infoPtr)) {
281 newVal = SendMessageW(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);
282 if(newVal < 0) return FALSE;
283 } else {
284 /* we have a regular window, so will get the text */
285 /* note that a zero-length string is a legitimate value for 'txt',
286 * and ought to result in a successful conversion to '0'. */
287 if (GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt)) < 0)
288 return FALSE;
290 sep = UPDOWN_GetThousandSep();
292 /* now get rid of the separators */
293 for(src = dst = txt; *src; src++)
294 if(*src != sep) *dst++ = *src;
295 *dst = 0;
297 /* try to convert the number and validate it */
298 newVal = strtolW(txt, &src, infoPtr->Base);
299 if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
302 TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
303 infoPtr->CurVal = newVal;
304 return TRUE;
308 /***********************************************************************
309 * UPDOWN_SetBuddyInt
310 * Tries to set the pos to the buddy window based on current pos
311 * returns:
312 * TRUE - if it set the caption of the buddy successfully
313 * FALSE - if an error occurred
315 static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
317 static const WCHAR fmt_hex[] = { '0', 'x', '%', '0', '4', 'X', 0 };
318 static const WCHAR fmt_dec_oct[] = { '%', 'd', '\0' };
319 const WCHAR *fmt;
320 WCHAR txt[20], txt_old[20] = { 0 };
321 int len;
323 if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
324 return FALSE;
326 TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal);
328 /*if the buddy is a list window, we must set curr index */
329 if (UPDOWN_IsBuddyListbox(infoPtr)) {
330 return SendMessageW(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0) != LB_ERR;
333 /* Regular window, so set caption to the number */
334 fmt = (infoPtr->Base == 16) ? fmt_hex : fmt_dec_oct;
335 len = wsprintfW(txt, fmt, infoPtr->CurVal);
338 /* Do thousands separation if necessary */
339 if ((infoPtr->Base == 10) && !(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) {
340 WCHAR tmp[COUNT_OF(txt)], *src = tmp, *dst = txt;
341 WCHAR sep = UPDOWN_GetThousandSep();
342 int start = len % 3;
344 memcpy(tmp, txt, sizeof(txt));
345 if (start == 0) start = 3;
346 dst += start;
347 src += start;
348 for (len=0; *src; len++) {
349 if (len % 3 == 0) *dst++ = sep;
350 *dst++ = *src++;
352 *dst = 0;
355 /* if nothing changed exit earlier */
356 GetWindowTextW(infoPtr->Buddy, txt_old, sizeof(txt_old)/sizeof(WCHAR));
357 if (lstrcmpiW(txt_old, txt) == 0) return FALSE;
359 return SetWindowTextW(infoPtr->Buddy, txt);
362 /***********************************************************************
363 * UPDOWN_DrawBuddyBackground
365 * Draw buddy background for visual integration.
367 static BOOL UPDOWN_DrawBuddyBackground (const UPDOWN_INFO *infoPtr, HDC hdc)
369 RECT br, r;
370 HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy);
371 if (!buddyTheme) return FALSE;
373 GetWindowRect (infoPtr->Buddy, &br);
374 MapWindowPoints (NULL, infoPtr->Self, (POINT*)&br, 2);
375 GetClientRect (infoPtr->Self, &r);
377 if (infoPtr->dwStyle & UDS_ALIGNLEFT)
378 br.left = r.left;
379 else if (infoPtr->dwStyle & UDS_ALIGNRIGHT)
380 br.right = r.right;
381 /* FIXME: take disabled etc. into account */
382 DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL);
383 return TRUE;
386 /***********************************************************************
387 * UPDOWN_Draw
389 * Draw the arrows. The background need not be erased.
391 static LRESULT UPDOWN_Draw (const UPDOWN_INFO *infoPtr, HDC hdc)
393 BOOL uPressed, uHot, dPressed, dHot;
394 RECT rect;
395 HTHEME theme = GetWindowTheme (infoPtr->Self);
396 int uPart = 0, uState = 0, dPart = 0, dState = 0;
397 BOOL needBuddyBg = FALSE;
399 uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR);
400 uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
401 dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR);
402 dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
403 if (theme) {
404 uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP;
405 uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
406 : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL));
407 dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN;
408 dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
409 : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL));
410 needBuddyBg = IsWindow (infoPtr->Buddy)
411 && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState)
412 || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState));
415 /* Draw the common border between ourselves and our buddy */
416 if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) {
417 if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) {
418 GetClientRect(infoPtr->Self, &rect);
419 DrawEdge(hdc, &rect, EDGE_SUNKEN,
420 BF_BOTTOM | BF_TOP |
421 (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT));
425 /* Draw the incr button */
426 UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR);
427 if (theme) {
428 DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL);
429 } else {
430 DrawFrameControl(hdc, &rect, DFC_SCROLL,
431 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) |
432 ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) |
433 (uPressed ? DFCS_PUSHED : 0) |
434 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
437 /* Draw the decr button */
438 UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR);
439 if (theme) {
440 DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL);
441 } else {
442 DrawFrameControl(hdc, &rect, DFC_SCROLL,
443 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) |
444 ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) |
445 (dPressed ? DFCS_PUSHED : 0) |
446 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
449 return 0;
452 /***********************************************************************
453 * UPDOWN_Paint
455 * Asynchronous drawing (must ONLY be used in WM_PAINT).
456 * Calls UPDOWN_Draw.
458 static LRESULT UPDOWN_Paint (const UPDOWN_INFO *infoPtr, HDC hdc)
460 PAINTSTRUCT ps;
461 if (hdc) return UPDOWN_Draw (infoPtr, hdc);
462 hdc = BeginPaint (infoPtr->Self, &ps);
463 UPDOWN_Draw (infoPtr, hdc);
464 EndPaint (infoPtr->Self, &ps);
465 return 0;
468 /***********************************************************************
469 * UPDOWN_KeyPressed
471 * Handle key presses (up & down) when we have to do so
473 static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
475 int arrow, accel;
477 if (key == VK_UP) arrow = FLAG_INCR;
478 else if (key == VK_DOWN) arrow = FLAG_DECR;
479 else return 1;
481 UPDOWN_GetBuddyInt (infoPtr);
482 infoPtr->Flags &= ~FLAG_ARROW;
483 infoPtr->Flags |= FLAG_PRESSED | arrow;
484 InvalidateRect (infoPtr->Self, NULL, FALSE);
485 SetTimer(infoPtr->Self, TIMER_AUTOPRESS, AUTOPRESS_DELAY, 0);
486 accel = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
487 UPDOWN_DoAction (infoPtr, accel, arrow);
488 return 0;
491 static int UPDOWN_GetPos(UPDOWN_INFO *infoPtr, BOOL *err)
493 BOOL succ = UPDOWN_GetBuddyInt(infoPtr);
494 int val = infoPtr->CurVal;
496 if(!UPDOWN_InBounds(infoPtr, val)) {
497 if((infoPtr->MinVal < infoPtr->MaxVal && val < infoPtr->MinVal)
498 || (infoPtr->MinVal > infoPtr->MaxVal && val > infoPtr->MinVal))
499 val = infoPtr->MinVal;
500 else
501 val = infoPtr->MaxVal;
503 succ = FALSE;
506 if(err) *err = !succ;
507 return val;
510 static int UPDOWN_SetPos(UPDOWN_INFO *infoPtr, int pos)
512 int ret = infoPtr->CurVal;
514 if(!UPDOWN_InBounds(infoPtr, pos)) {
515 if((infoPtr->MinVal < infoPtr->MaxVal && pos < infoPtr->MinVal)
516 || (infoPtr->MinVal > infoPtr->MaxVal && pos > infoPtr->MinVal))
517 pos = infoPtr->MinVal;
518 else
519 pos = infoPtr->MaxVal;
522 infoPtr->CurVal = pos;
523 UPDOWN_SetBuddyInt(infoPtr);
525 if(!UPDOWN_InBounds(infoPtr, ret)) {
526 if((infoPtr->MinVal < infoPtr->MaxVal && ret < infoPtr->MinVal)
527 || (infoPtr->MinVal > infoPtr->MaxVal && ret > infoPtr->MinVal))
528 ret = infoPtr->MinVal;
529 else
530 ret = infoPtr->MaxVal;
532 return ret;
536 /***********************************************************************
537 * UPDOWN_SetRange
539 * Handle UDM_SETRANGE, UDM_SETRANGE32
541 * FIXME: handle Max == Min properly:
542 * - arrows should be disabled (without WS_DISABLED set),
543 * visually they can't be pressed and don't respond;
544 * - all input messages should still pass in.
546 static LRESULT UPDOWN_SetRange(UPDOWN_INFO *infoPtr, INT Max, INT Min)
548 infoPtr->MaxVal = Max;
549 infoPtr->MinVal = Min;
551 TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
552 infoPtr->MinVal, infoPtr->MaxVal, infoPtr->Self);
554 return 0;
557 /***********************************************************************
558 * UPDOWN_MouseWheel
560 * Handle mouse wheel scrolling
562 static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
564 int iWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
566 if (wParam & (MK_SHIFT | MK_CONTROL))
567 return 0;
569 if (iWheelDelta != 0)
571 UPDOWN_GetBuddyInt(infoPtr);
572 UPDOWN_DoAction(infoPtr, abs(iWheelDelta), iWheelDelta > 0 ? FLAG_INCR : FLAG_DECR);
575 return 1;
579 /***********************************************************************
580 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
581 * control.
583 static LRESULT CALLBACK
584 UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
585 UINT_PTR uId, DWORD_PTR ref_data)
587 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr((HWND)ref_data);
589 TRACE("hwnd=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
590 hwnd, uMsg, wParam, lParam);
592 switch(uMsg)
594 case WM_KEYDOWN:
595 UPDOWN_KeyPressed(infoPtr, (int)wParam);
596 if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
597 break;
599 case WM_MOUSEWHEEL:
600 UPDOWN_MouseWheel(infoPtr, (int)wParam);
601 break;
603 default:
604 break;
607 return DefSubclassProc(hwnd, uMsg, wParam, lParam);
610 /***********************************************************************
611 * UPDOWN_SetBuddy
613 * Sets bud as a new Buddy.
614 * Then, it should subclass the buddy
615 * If window has the UDS_ARROWKEYS, it subclasses the buddy window to
616 * process the UP/DOWN arrow keys.
617 * If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style
618 * the size/pos of the buddy and the control are adjusted accordingly.
620 static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
622 RECT budRect; /* new coord for the buddy */
623 int x, width; /* new x position and width for the up-down */
624 WCHAR buddyClass[40];
625 HWND old_buddy;
627 TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
629 old_buddy = infoPtr->Buddy;
631 /* there is already a buddy assigned */
632 if (infoPtr->Buddy) RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
633 BUDDY_SUBCLASSID);
634 if (!IsWindow(bud)) bud = NULL;
636 /* Store buddy window handle */
637 infoPtr->Buddy = bud;
639 if(bud) {
640 /* Store buddy window class type */
641 infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
642 if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) {
643 if (lstrcmpiW(buddyClass, WC_EDITW) == 0)
644 infoPtr->BuddyType = BUDDY_TYPE_EDIT;
645 else if (lstrcmpiW(buddyClass, WC_LISTBOXW) == 0)
646 infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
649 if (infoPtr->dwStyle & UDS_ARROWKEYS)
650 SetWindowSubclass(bud, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID,
651 (DWORD_PTR)infoPtr->Self);
653 /* Get the rect of the buddy relative to its parent */
654 GetWindowRect(infoPtr->Buddy, &budRect);
655 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2);
657 /* now do the positioning */
658 if (infoPtr->dwStyle & UDS_ALIGNLEFT) {
659 x = budRect.left;
660 budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP;
661 } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) {
662 budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
663 x = budRect.right+DEFAULT_XSEP;
664 } else {
665 /* nothing to do */
666 return old_buddy;
669 /* first adjust the buddy to accommodate the up/down */
670 SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
671 budRect.right - budRect.left, budRect.bottom - budRect.top,
672 SWP_NOACTIVATE|SWP_NOZORDER);
674 /* now position the up/down */
675 /* Since the UDS_ALIGN* flags were used, */
676 /* we will pick the position and size of the window. */
677 width = DEFAULT_WIDTH;
680 * If the updown has a buddy border, it has to overlap with the buddy
681 * to look as if it is integrated with the buddy control.
682 * We nudge the control or change its size to overlap.
684 if (UPDOWN_HasBuddyBorder(infoPtr)) {
685 if(infoPtr->dwStyle & UDS_ALIGNLEFT)
686 width += DEFAULT_BUDDYBORDER;
687 else
688 x -= DEFAULT_BUDDYBORDER;
691 SetWindowPos(infoPtr->Self, 0, x,
692 budRect.top - DEFAULT_ADDTOP, width,
693 budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
694 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
695 } else if (!(infoPtr->dwStyle & UDS_HORZ) && old_buddy != NULL) {
696 RECT rect;
697 GetWindowRect(infoPtr->Self, &rect);
698 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
699 SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
700 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
703 return old_buddy;
706 /***********************************************************************
707 * UPDOWN_DoAction
709 * This function increments/decrements the CurVal by the
710 * 'delta' amount according to the 'action' flag which can be a
711 * combination of FLAG_INCR and FLAG_DECR
712 * It notifies the parent as required.
713 * It handles wrapping and non-wrapping correctly.
714 * It is assumed that delta>0
716 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action)
718 NM_UPDOWN ni;
720 TRACE("%d by %d\n", action, delta);
722 /* check if we can do the modification first */
723 delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
724 if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
726 TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
728 /* We must notify parent now to obtain permission */
729 ni.iPos = infoPtr->CurVal;
730 ni.iDelta = delta;
731 ni.hdr.hwndFrom = infoPtr->Self;
732 ni.hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
733 ni.hdr.code = UDN_DELTAPOS;
734 if (!SendMessageW(infoPtr->Notify, WM_NOTIFY, ni.hdr.idFrom, (LPARAM)&ni)) {
735 /* Parent said: OK to adjust */
737 /* Now adjust value with (maybe new) delta */
738 if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
739 TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
741 /* Now take care about our buddy */
742 UPDOWN_SetBuddyInt (infoPtr);
746 /* Also, notify it. This message is sent in any case. */
747 SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
748 MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self);
751 /***********************************************************************
752 * UPDOWN_IsEnabled
754 * Returns TRUE if it is enabled as well as its buddy (if any)
755 * FALSE otherwise
757 static BOOL UPDOWN_IsEnabled (const UPDOWN_INFO *infoPtr)
759 if (!IsWindowEnabled(infoPtr->Self))
760 return FALSE;
761 if(infoPtr->Buddy)
762 return IsWindowEnabled(infoPtr->Buddy);
763 return TRUE;
766 /***********************************************************************
767 * UPDOWN_CancelMode
769 * Deletes any timers, releases the mouse and does redraw if necessary.
770 * If the control is not in "capture" mode, it does nothing.
771 * If the control was not in cancel mode, it returns FALSE.
772 * If the control was in cancel mode, it returns TRUE.
774 static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr)
776 if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
778 KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
779 KillTimer (infoPtr->Self, TIMER_ACCEL);
780 KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
782 if (GetCapture() == infoPtr->Self) {
783 NMHDR hdr;
784 hdr.hwndFrom = infoPtr->Self;
785 hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
786 hdr.code = NM_RELEASEDCAPTURE;
787 SendMessageW(infoPtr->Notify, WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);
788 ReleaseCapture();
791 infoPtr->Flags &= ~FLAG_PRESSED;
792 InvalidateRect (infoPtr->Self, NULL, FALSE);
794 return TRUE;
797 /***********************************************************************
798 * UPDOWN_HandleMouseEvent
800 * Handle a mouse event for the updown.
801 * 'pt' is the location of the mouse event in client or
802 * windows coordinates.
804 static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
806 POINT pt = { x, y };
807 RECT rect;
808 int temp, arrow;
809 TRACKMOUSEEVENT tme;
811 TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
813 switch(msg)
815 case WM_LBUTTONDOWN: /* Initialise mouse tracking */
817 /* If the buddy is an edit, will set focus to it */
818 if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
820 /* Now see which one is the 'active' arrow */
821 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
823 /* Update the flags if we are in/out */
824 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
825 if (arrow)
826 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
827 else
828 if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
830 if (infoPtr->Flags & FLAG_ARROW) {
832 /* Update the CurVal if necessary */
833 UPDOWN_GetBuddyInt (infoPtr);
835 /* Set up the correct flags */
836 infoPtr->Flags |= FLAG_PRESSED;
838 /* repaint the control */
839 InvalidateRect (infoPtr->Self, NULL, FALSE);
841 /* process the click */
842 temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
843 UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
845 /* now capture all mouse messages */
846 SetCapture (infoPtr->Self);
848 /* and startup the first timer */
849 SetTimer(infoPtr->Self, TIMER_AUTOREPEAT, INITIAL_DELAY, 0);
851 break;
853 case WM_MOUSEMOVE:
854 /* save the flags to see if any got modified */
855 temp = infoPtr->Flags;
857 /* Now see which one is the 'active' arrow */
858 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
860 /* Update the flags if we are in/out */
861 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
862 if(arrow) {
863 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
864 } else {
865 if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
868 /* If state changed, redraw the control */
869 if(temp != infoPtr->Flags)
870 InvalidateRect (infoPtr->Self, NULL, FALSE);
872 /* Set up tracking so the mousein flags can be reset when the
873 * mouse leaves the control */
874 tme.cbSize = sizeof( tme );
875 tme.dwFlags = TME_LEAVE;
876 tme.hwndTrack = infoPtr->Self;
877 TrackMouseEvent (&tme);
879 break;
880 case WM_MOUSELEAVE:
881 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
882 InvalidateRect (infoPtr->Self, NULL, FALSE);
883 break;
885 default:
886 ERR("Impossible case (msg=%x)!\n", msg);
891 /***********************************************************************
892 * UpDownWndProc
894 static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
896 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
897 static const WCHAR themeClass[] = {'S','p','i','n',0};
898 HTHEME theme;
900 TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam);
902 if (!infoPtr && (message != WM_CREATE))
903 return DefWindowProcW (hwnd, message, wParam, lParam);
905 switch(message)
907 case WM_CREATE:
909 CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam;
911 infoPtr = Alloc (sizeof(UPDOWN_INFO));
912 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
914 /* initialize the info struct */
915 infoPtr->Self = hwnd;
916 infoPtr->Notify = pcs->hwndParent;
917 infoPtr->dwStyle = pcs->style;
918 infoPtr->AccelCount = 0;
919 infoPtr->AccelVect = 0;
920 infoPtr->AccelIndex = -1;
921 infoPtr->CurVal = 0;
922 infoPtr->MinVal = 100;
923 infoPtr->MaxVal = 0;
924 infoPtr->Base = 10; /* Default to base 10 */
925 infoPtr->Buddy = 0; /* No buddy window yet */
926 infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
928 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
929 if (!(infoPtr->dwStyle & UDS_HORZ))
930 SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy,
931 SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
933 /* Do we pick the buddy win ourselves? */
934 if (infoPtr->dwStyle & UDS_AUTOBUDDY)
935 UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV));
937 OpenThemeData (hwnd, themeClass);
939 TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
941 break;
943 case WM_DESTROY:
944 Free (infoPtr->AccelVect);
946 if (infoPtr->Buddy)
947 RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
948 BUDDY_SUBCLASSID);
949 Free (infoPtr);
950 SetWindowLongPtrW (hwnd, 0, 0);
951 theme = GetWindowTheme (hwnd);
952 CloseThemeData (theme);
953 TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
954 break;
956 case WM_ENABLE:
957 if (wParam) {
958 infoPtr->dwStyle &= ~WS_DISABLED;
959 } else {
960 infoPtr->dwStyle |= WS_DISABLED;
961 UPDOWN_CancelMode (infoPtr);
963 InvalidateRect (infoPtr->Self, NULL, FALSE);
964 break;
966 case WM_STYLECHANGED:
967 if (wParam == GWL_STYLE) {
968 infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
969 InvalidateRect (infoPtr->Self, NULL, FALSE);
971 break;
973 case WM_THEMECHANGED:
974 theme = GetWindowTheme (hwnd);
975 CloseThemeData (theme);
976 OpenThemeData (hwnd, themeClass);
977 InvalidateRect (hwnd, NULL, FALSE);
978 break;
980 case WM_TIMER:
981 /* is this the auto-press timer? */
982 if(wParam == TIMER_AUTOPRESS) {
983 KillTimer(hwnd, TIMER_AUTOPRESS);
984 infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW);
985 InvalidateRect(infoPtr->Self, NULL, FALSE);
988 /* if initial timer, kill it and start the repeat timer */
989 if(wParam == TIMER_AUTOREPEAT) {
990 INT delay;
992 KillTimer(hwnd, TIMER_AUTOREPEAT);
993 /* if no accel info given, used default timer */
994 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) {
995 infoPtr->AccelIndex = -1;
996 delay = REPEAT_DELAY;
997 } else {
998 infoPtr->AccelIndex = 0; /* otherwise, use it */
999 delay = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1001 SetTimer(hwnd, TIMER_ACCEL, delay, 0);
1004 /* now, if the mouse is above us, do the thing...*/
1005 if(infoPtr->Flags & FLAG_MOUSEIN) {
1006 int temp;
1008 temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
1009 UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
1011 if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
1012 KillTimer(hwnd, TIMER_ACCEL);
1013 infoPtr->AccelIndex++; /* move to the next accel info */
1014 temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1015 /* make sure we have at least 1ms intervals */
1016 SetTimer(hwnd, TIMER_ACCEL, temp, 0);
1019 break;
1021 case WM_CANCELMODE:
1022 return UPDOWN_CancelMode (infoPtr);
1024 case WM_LBUTTONUP:
1025 if (GetCapture() != infoPtr->Self) break;
1027 if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
1028 (infoPtr->Flags & FLAG_ARROW) ) {
1030 SendMessageW( infoPtr->Notify,
1031 (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
1032 MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
1033 (LPARAM)hwnd);
1034 if (UPDOWN_IsBuddyEdit(infoPtr))
1035 SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
1037 UPDOWN_CancelMode(infoPtr);
1038 break;
1040 case WM_LBUTTONDOWN:
1041 case WM_MOUSEMOVE:
1042 case WM_MOUSELEAVE:
1043 if(UPDOWN_IsEnabled(infoPtr))
1044 UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1045 break;
1047 case WM_MOUSEWHEEL:
1048 UPDOWN_MouseWheel(infoPtr, wParam);
1049 break;
1051 case WM_KEYDOWN:
1052 if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
1053 return UPDOWN_KeyPressed(infoPtr, (int)wParam);
1054 break;
1056 case WM_PRINTCLIENT:
1057 case WM_PAINT:
1058 return UPDOWN_Paint (infoPtr, (HDC)wParam);
1060 case UDM_GETACCEL:
1061 if (wParam==0 && lParam==0) return infoPtr->AccelCount;
1062 if (wParam && lParam) {
1063 int temp = min(infoPtr->AccelCount, wParam);
1064 memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL));
1065 return temp;
1067 return 0;
1069 case UDM_SETACCEL:
1071 TRACE("UDM_SETACCEL\n");
1073 if(infoPtr->AccelVect) {
1074 Free (infoPtr->AccelVect);
1075 infoPtr->AccelCount = 0;
1076 infoPtr->AccelVect = 0;
1078 if(wParam==0) return TRUE;
1079 infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL));
1080 if(infoPtr->AccelVect == 0) return FALSE;
1081 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
1082 infoPtr->AccelCount = wParam;
1084 if (TRACE_ON(updown))
1086 UINT i;
1088 for (i = 0; i < wParam; i++)
1089 TRACE("%u: nSec %u nInc %u\n", i,
1090 infoPtr->AccelVect[i].nSec, infoPtr->AccelVect[i].nInc);
1093 return TRUE;
1095 case UDM_GETBASE:
1096 return infoPtr->Base;
1098 case UDM_SETBASE:
1099 TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd);
1100 if (wParam==10 || wParam==16) {
1101 WPARAM old_base = infoPtr->Base;
1102 infoPtr->Base = wParam;
1104 if (old_base != infoPtr->Base)
1105 UPDOWN_SetBuddyInt(infoPtr);
1107 return old_base;
1109 break;
1111 case UDM_GETBUDDY:
1112 return (LRESULT)infoPtr->Buddy;
1114 case UDM_SETBUDDY:
1115 return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
1117 case UDM_GETPOS:
1119 BOOL err;
1120 int pos;
1122 pos = UPDOWN_GetPos(infoPtr, &err);
1123 return MAKELONG(pos, err);
1125 case UDM_SETPOS:
1127 return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam));
1129 case UDM_GETRANGE:
1130 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
1132 case UDM_SETRANGE:
1133 /* we must have:
1134 UD_MINVAL <= Max <= UD_MAXVAL
1135 UD_MINVAL <= Min <= UD_MAXVAL
1136 |Max-Min| <= UD_MAXVAL */
1137 UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
1138 break;
1140 case UDM_GETRANGE32:
1141 if (wParam) *(LPINT)wParam = infoPtr->MinVal;
1142 if (lParam) *(LPINT)lParam = infoPtr->MaxVal;
1143 break;
1145 case UDM_SETRANGE32:
1146 UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
1147 break;
1149 case UDM_GETPOS32:
1151 return UPDOWN_GetPos(infoPtr, (BOOL*)lParam);
1153 case UDM_SETPOS32:
1155 return UPDOWN_SetPos(infoPtr, (int)lParam);
1157 case UDM_GETUNICODEFORMAT:
1158 /* we lie a bit here, we're always using Unicode internally */
1159 return infoPtr->UnicodeFormat;
1161 case UDM_SETUNICODEFORMAT:
1163 /* do we really need to honour this flag? */
1164 int temp = infoPtr->UnicodeFormat;
1165 infoPtr->UnicodeFormat = (BOOL)wParam;
1166 return temp;
1168 default:
1169 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
1170 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam);
1171 return DefWindowProcW (hwnd, message, wParam, lParam);
1174 return 0;
1177 /***********************************************************************
1178 * UPDOWN_Register [Internal]
1180 * Registers the updown window class.
1182 void UPDOWN_Register(void)
1184 WNDCLASSW wndClass;
1186 ZeroMemory( &wndClass, sizeof( WNDCLASSW ) );
1187 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1188 wndClass.lpfnWndProc = UpDownWindowProc;
1189 wndClass.cbClsExtra = 0;
1190 wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
1191 wndClass.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
1192 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1193 wndClass.lpszClassName = UPDOWN_CLASSW;
1195 RegisterClassW( &wndClass );
1199 /***********************************************************************
1200 * UPDOWN_Unregister [Internal]
1202 * Unregisters the updown window class.
1204 void UPDOWN_Unregister (void)
1206 UnregisterClassW (UPDOWN_CLASSW, NULL);