ntdll: Translate signal to trap when trap code is 0 on ARM.
[wine.git] / dlls / comctl32 / updown.c
bloba48f1e437cad13fb66c3c909cc687559a5f206a6
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
21 #include <assert.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdarg.h>
25 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winnls.h"
32 #include "commctrl.h"
33 #include "comctl32.h"
34 #include "uxtheme.h"
35 #include "vssym32.h"
36 #include "wine/heap.h"
37 #include "wine/unicode.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(updown);
42 typedef struct
44 HWND Self; /* Handle to this up-down control */
45 HWND Notify; /* Handle to the parent window */
46 DWORD dwStyle; /* The GWL_STYLE for this window */
47 UINT AccelCount; /* Number of elements in AccelVect */
48 UDACCEL* AccelVect; /* Vector containing AccelCount elements */
49 INT AccelIndex; /* Current accel index, -1 if not accel'ing */
50 INT Base; /* Base to display nr in the buddy window */
51 INT CurVal; /* Current up-down value */
52 INT MinVal; /* Minimum up-down value */
53 INT MaxVal; /* Maximum up-down value */
54 HWND Buddy; /* Handle to the buddy window */
55 INT BuddyType; /* Remembers the buddy type BUDDY_TYPE_* */
56 INT Flags; /* Internal Flags FLAG_* */
57 BOOL UnicodeFormat; /* Marks the use of Unicode internally */
58 } UPDOWN_INFO;
60 /* Control configuration constants */
62 #define INITIAL_DELAY 500 /* initial timer until auto-inc kicks in */
63 #define AUTOPRESS_DELAY 250 /* time to keep arrow pressed on KEY_DOWN */
64 #define REPEAT_DELAY 50 /* delay between auto-increments */
66 #define DEFAULT_WIDTH 16 /* default width of the ctrl */
67 #define DEFAULT_XSEP 0 /* default separation between buddy and ctrl */
68 #define DEFAULT_ADDTOP 0 /* amount to extend above the buddy window */
69 #define DEFAULT_ADDBOT 0 /* amount to extend below the buddy window */
70 #define DEFAULT_BUDDYBORDER 2 /* Width/height of the buddy border */
71 #define DEFAULT_BUDDYSPACER 2 /* Spacer between the buddy and the ctrl */
72 #define DEFAULT_BUDDYBORDER_THEMED 1 /* buddy border when theming is enabled */
73 #define DEFAULT_BUDDYSPACER_THEMED 0 /* buddy spacer when theming is enabled */
75 /* Work constants */
77 #define FLAG_INCR 0x01
78 #define FLAG_DECR 0x02
79 #define FLAG_MOUSEIN 0x04
80 #define FLAG_PRESSED 0x08
81 #define FLAG_BUDDYINT 0x10 /* UDS_SETBUDDYINT was set on creation */
82 #define FLAG_ARROW (FLAG_INCR | FLAG_DECR)
84 #define BUDDY_TYPE_UNKNOWN 0
85 #define BUDDY_TYPE_LISTBOX 1
86 #define BUDDY_TYPE_EDIT 2
88 #define TIMER_AUTOREPEAT 1
89 #define TIMER_ACCEL 2
90 #define TIMER_AUTOPRESS 3
92 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))
94 /* id used for SetWindowSubclass */
95 #define BUDDY_SUBCLASSID 1
97 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action);
99 /***********************************************************************
100 * UPDOWN_IsBuddyEdit
101 * Tests if our buddy is an edit control.
103 static inline BOOL UPDOWN_IsBuddyEdit(const UPDOWN_INFO *infoPtr)
105 return infoPtr->BuddyType == BUDDY_TYPE_EDIT;
108 /***********************************************************************
109 * UPDOWN_IsBuddyListbox
110 * Tests if our buddy is a listbox control.
112 static inline BOOL UPDOWN_IsBuddyListbox(const UPDOWN_INFO *infoPtr)
114 return infoPtr->BuddyType == BUDDY_TYPE_LISTBOX;
117 /***********************************************************************
118 * UPDOWN_InBounds
119 * Tests if a given value 'val' is between the Min&Max limits
121 static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
123 if(infoPtr->MaxVal > infoPtr->MinVal)
124 return (infoPtr->MinVal <= val) && (val <= infoPtr->MaxVal);
125 else
126 return (infoPtr->MaxVal <= val) && (val <= infoPtr->MinVal);
129 /***********************************************************************
130 * UPDOWN_OffsetVal
131 * Change the current value by delta.
132 * It returns TRUE is the value was changed successfully, or FALSE
133 * if the value was not changed, as it would go out of bounds.
135 static BOOL UPDOWN_OffsetVal(UPDOWN_INFO *infoPtr, int delta)
137 /* check if we can do the modification first */
138 if(!UPDOWN_InBounds (infoPtr, infoPtr->CurVal+delta)) {
139 if (infoPtr->dwStyle & UDS_WRAP) {
140 delta += (delta < 0 ? -1 : 1) *
141 (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) *
142 (infoPtr->MinVal - infoPtr->MaxVal) +
143 (delta < 0 ? 1 : -1);
144 } else if ((infoPtr->MaxVal > infoPtr->MinVal && infoPtr->CurVal+delta > infoPtr->MaxVal)
145 || (infoPtr->MaxVal < infoPtr->MinVal && infoPtr->CurVal+delta < infoPtr->MaxVal)) {
146 delta = infoPtr->MaxVal - infoPtr->CurVal;
147 } else {
148 delta = infoPtr->MinVal - infoPtr->CurVal;
152 infoPtr->CurVal += delta;
153 return delta != 0;
156 /***********************************************************************
157 * UPDOWN_HasBuddyBorder
159 * When we have a buddy set and that we are aligned on our buddy, we
160 * want to draw a sunken edge to make like we are part of that control.
162 static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr)
164 return ( ((infoPtr->dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) &&
165 UPDOWN_IsBuddyEdit(infoPtr) );
168 /***********************************************************************
169 * UPDOWN_GetArrowRect
170 * wndPtr - pointer to the up-down wnd
171 * rect - will hold the rectangle
172 * arrow - FLAG_INCR to get the "increment" rect (up or right)
173 * FLAG_DECR to get the "decrement" rect (down or left)
175 static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, unsigned int arrow)
177 HTHEME theme = GetWindowTheme (infoPtr->Self);
178 const int border = theme ? DEFAULT_BUDDYBORDER_THEMED : DEFAULT_BUDDYBORDER;
179 const int spacer = theme ? DEFAULT_BUDDYSPACER_THEMED : DEFAULT_BUDDYSPACER;
180 int size;
182 assert(arrow && (arrow & (FLAG_INCR | FLAG_DECR)) != (FLAG_INCR | FLAG_DECR));
184 GetClientRect (infoPtr->Self, rect);
187 * Make sure we calculate the rectangle to fit even if we draw the
188 * border.
190 if (UPDOWN_HasBuddyBorder(infoPtr)) {
191 if (infoPtr->dwStyle & UDS_ALIGNLEFT)
192 rect->left += border;
193 else
194 rect->right -= border;
196 InflateRect(rect, 0, -border);
199 /* now figure out if we need a space away from the buddy */
200 if (IsWindow(infoPtr->Buddy) ) {
201 if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= spacer;
202 else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) rect->left += spacer;
206 * We're calculating the midpoint to figure-out where the
207 * separation between the buttons will lay.
209 if (infoPtr->dwStyle & UDS_HORZ) {
210 size = (rect->right - rect->left) / 2;
211 if (arrow & FLAG_INCR)
212 rect->left = rect->right - size;
213 else if (arrow & FLAG_DECR)
214 rect->right = rect->left + size;
215 } else {
216 size = (rect->bottom - rect->top) / 2;
217 if (arrow & FLAG_INCR)
218 rect->bottom = rect->top + size;
219 else if (arrow & FLAG_DECR)
220 rect->top = rect->bottom - size;
224 /***********************************************************************
225 * UPDOWN_GetArrowFromPoint
226 * Returns the rectagle (for the up or down arrow) that contains pt.
227 * If it returns the up rect, it returns FLAG_INCR.
228 * If it returns the down rect, it returns FLAG_DECR.
230 static INT UPDOWN_GetArrowFromPoint (const UPDOWN_INFO *infoPtr, RECT *rect, POINT pt)
232 UPDOWN_GetArrowRect (infoPtr, rect, FLAG_INCR);
233 if(PtInRect(rect, pt)) return FLAG_INCR;
235 UPDOWN_GetArrowRect (infoPtr, rect, FLAG_DECR);
236 if(PtInRect(rect, pt)) return FLAG_DECR;
238 return 0;
242 /***********************************************************************
243 * UPDOWN_GetThousandSep
244 * Returns the thousand sep. If an error occurs, it returns ','.
246 static WCHAR UPDOWN_GetThousandSep(void)
248 WCHAR sep[2];
250 if(GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, sep, 2) != 1)
251 sep[0] = ',';
253 return sep[0];
256 /***********************************************************************
257 * UPDOWN_GetBuddyInt
258 * Tries to read the pos from the buddy window and if it succeeds,
259 * it stores it in the control's CurVal
260 * returns:
261 * TRUE - if it read the integer from the buddy successfully
262 * FALSE - if an error occurred
264 static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
266 WCHAR txt[20], sep, *src, *dst;
267 int newVal;
269 if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
270 return FALSE;
272 /*if the buddy is a list window, we must set curr index */
273 if (UPDOWN_IsBuddyListbox(infoPtr)) {
274 newVal = SendMessageW(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);
275 if(newVal < 0) return FALSE;
276 } else {
277 /* we have a regular window, so will get the text */
278 /* note that a zero-length string is a legitimate value for 'txt',
279 * and ought to result in a successful conversion to '0'. */
280 if (GetWindowTextW(infoPtr->Buddy, txt, ARRAY_SIZE(txt)) < 0)
281 return FALSE;
283 sep = UPDOWN_GetThousandSep();
285 /* now get rid of the separators */
286 for(src = dst = txt; *src; src++)
287 if(*src != sep) *dst++ = *src;
288 *dst = 0;
290 /* try to convert the number and validate it */
291 newVal = strtolW(txt, &src, infoPtr->Base);
292 if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
295 TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
296 infoPtr->CurVal = newVal;
297 return TRUE;
301 /***********************************************************************
302 * UPDOWN_SetBuddyInt
303 * Tries to set the pos to the buddy window based on current pos
304 * returns:
305 * TRUE - if it set the caption of the buddy successfully
306 * FALSE - if an error occurred
308 static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
310 static const WCHAR fmt_hex[] = { '0', 'x', '%', '0', '4', 'X', 0 };
311 static const WCHAR fmt_dec_oct[] = { '%', 'd', '\0' };
312 const WCHAR *fmt;
313 WCHAR txt[20], txt_old[20] = { 0 };
314 int len;
316 if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
317 return FALSE;
319 TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal);
321 /*if the buddy is a list window, we must set curr index */
322 if (UPDOWN_IsBuddyListbox(infoPtr)) {
323 return SendMessageW(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0) != LB_ERR;
326 /* Regular window, so set caption to the number */
327 fmt = (infoPtr->Base == 16) ? fmt_hex : fmt_dec_oct;
328 len = wsprintfW(txt, fmt, infoPtr->CurVal);
331 /* Do thousands separation if necessary */
332 if ((infoPtr->Base == 10) && !(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) {
333 WCHAR tmp[ARRAY_SIZE(txt)], *src = tmp, *dst = txt;
334 WCHAR sep = UPDOWN_GetThousandSep();
335 int start = len % 3;
337 memcpy(tmp, txt, sizeof(txt));
338 if (start == 0) start = 3;
339 dst += start;
340 src += start;
341 for (len=0; *src; len++) {
342 if (len % 3 == 0) *dst++ = sep;
343 *dst++ = *src++;
345 *dst = 0;
348 /* if nothing changed exit earlier */
349 GetWindowTextW(infoPtr->Buddy, txt_old, ARRAY_SIZE(txt_old));
350 if (lstrcmpiW(txt_old, txt) == 0) return FALSE;
352 return SetWindowTextW(infoPtr->Buddy, txt);
355 /***********************************************************************
356 * UPDOWN_DrawBuddyBackground
358 * Draw buddy background for visual integration.
360 static BOOL UPDOWN_DrawBuddyBackground (const UPDOWN_INFO *infoPtr, HDC hdc)
362 RECT br, r;
363 HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy);
364 if (!buddyTheme) return FALSE;
366 GetWindowRect (infoPtr->Buddy, &br);
367 MapWindowPoints (NULL, infoPtr->Self, (POINT*)&br, 2);
368 GetClientRect (infoPtr->Self, &r);
370 if (infoPtr->dwStyle & UDS_ALIGNLEFT)
371 br.left = r.left;
372 else if (infoPtr->dwStyle & UDS_ALIGNRIGHT)
373 br.right = r.right;
374 /* FIXME: take disabled etc. into account */
375 DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL);
376 return TRUE;
379 /***********************************************************************
380 * UPDOWN_Draw
382 * Draw the arrows. The background need not be erased.
384 static LRESULT UPDOWN_Draw (const UPDOWN_INFO *infoPtr, HDC hdc)
386 BOOL uPressed, uHot, dPressed, dHot;
387 RECT rect;
388 HTHEME theme = GetWindowTheme (infoPtr->Self);
389 int uPart = 0, uState = 0, dPart = 0, dState = 0;
390 BOOL needBuddyBg = FALSE;
392 uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR);
393 uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
394 dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR);
395 dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
396 if (theme) {
397 uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP;
398 uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
399 : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL));
400 dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN;
401 dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
402 : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL));
403 needBuddyBg = IsWindow (infoPtr->Buddy)
404 && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState)
405 || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState));
408 /* Draw the common border between ourselves and our buddy */
409 if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) {
410 if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) {
411 GetClientRect(infoPtr->Self, &rect);
412 DrawEdge(hdc, &rect, EDGE_SUNKEN,
413 BF_BOTTOM | BF_TOP |
414 (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT));
418 /* Draw the incr button */
419 UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR);
420 if (theme) {
421 DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL);
422 } else {
423 DrawFrameControl(hdc, &rect, DFC_SCROLL,
424 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) |
425 ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) |
426 (uPressed ? DFCS_PUSHED : 0) |
427 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
430 /* Draw the decr button */
431 UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR);
432 if (theme) {
433 DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL);
434 } else {
435 DrawFrameControl(hdc, &rect, DFC_SCROLL,
436 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) |
437 ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) |
438 (dPressed ? DFCS_PUSHED : 0) |
439 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
442 return 0;
445 /***********************************************************************
446 * UPDOWN_Paint
448 * Asynchronous drawing (must ONLY be used in WM_PAINT).
449 * Calls UPDOWN_Draw.
451 static LRESULT UPDOWN_Paint (const UPDOWN_INFO *infoPtr, HDC hdc)
453 PAINTSTRUCT ps;
454 if (hdc) return UPDOWN_Draw (infoPtr, hdc);
455 hdc = BeginPaint (infoPtr->Self, &ps);
456 UPDOWN_Draw (infoPtr, hdc);
457 EndPaint (infoPtr->Self, &ps);
458 return 0;
461 /***********************************************************************
462 * UPDOWN_KeyPressed
464 * Handle key presses (up & down) when we have to do so
466 static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
468 int arrow, accel;
470 if (key == VK_UP) arrow = FLAG_INCR;
471 else if (key == VK_DOWN) arrow = FLAG_DECR;
472 else return 1;
474 UPDOWN_GetBuddyInt (infoPtr);
475 infoPtr->Flags &= ~FLAG_ARROW;
476 infoPtr->Flags |= FLAG_PRESSED | arrow;
477 InvalidateRect (infoPtr->Self, NULL, FALSE);
478 SetTimer(infoPtr->Self, TIMER_AUTOPRESS, AUTOPRESS_DELAY, 0);
479 accel = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
480 UPDOWN_DoAction (infoPtr, accel, arrow);
481 return 0;
484 static int UPDOWN_GetPos(UPDOWN_INFO *infoPtr, BOOL *err)
486 BOOL succ = UPDOWN_GetBuddyInt(infoPtr);
487 int val = infoPtr->CurVal;
489 if(!UPDOWN_InBounds(infoPtr, val)) {
490 if((infoPtr->MinVal < infoPtr->MaxVal && val < infoPtr->MinVal)
491 || (infoPtr->MinVal > infoPtr->MaxVal && val > infoPtr->MinVal))
492 val = infoPtr->MinVal;
493 else
494 val = infoPtr->MaxVal;
496 succ = FALSE;
499 if(err) *err = !succ;
500 return val;
503 static int UPDOWN_SetPos(UPDOWN_INFO *infoPtr, int pos)
505 int ret = infoPtr->CurVal;
507 if(!UPDOWN_InBounds(infoPtr, pos)) {
508 if((infoPtr->MinVal < infoPtr->MaxVal && pos < infoPtr->MinVal)
509 || (infoPtr->MinVal > infoPtr->MaxVal && pos > infoPtr->MinVal))
510 pos = infoPtr->MinVal;
511 else
512 pos = infoPtr->MaxVal;
515 infoPtr->CurVal = pos;
516 UPDOWN_SetBuddyInt(infoPtr);
518 if(!UPDOWN_InBounds(infoPtr, ret)) {
519 if((infoPtr->MinVal < infoPtr->MaxVal && ret < infoPtr->MinVal)
520 || (infoPtr->MinVal > infoPtr->MaxVal && ret > infoPtr->MinVal))
521 ret = infoPtr->MinVal;
522 else
523 ret = infoPtr->MaxVal;
525 return ret;
529 /***********************************************************************
530 * UPDOWN_SetRange
532 * Handle UDM_SETRANGE, UDM_SETRANGE32
534 * FIXME: handle Max == Min properly:
535 * - arrows should be disabled (without WS_DISABLED set),
536 * visually they can't be pressed and don't respond;
537 * - all input messages should still pass in.
539 static LRESULT UPDOWN_SetRange(UPDOWN_INFO *infoPtr, INT Max, INT Min)
541 infoPtr->MaxVal = Max;
542 infoPtr->MinVal = Min;
544 TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
545 infoPtr->MinVal, infoPtr->MaxVal, infoPtr->Self);
547 return 0;
550 /***********************************************************************
551 * UPDOWN_MouseWheel
553 * Handle mouse wheel scrolling
555 static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
557 int iWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
559 if (wParam & (MK_SHIFT | MK_CONTROL))
560 return 0;
562 if (iWheelDelta != 0)
564 UPDOWN_GetBuddyInt(infoPtr);
565 UPDOWN_DoAction(infoPtr, abs(iWheelDelta), iWheelDelta > 0 ? FLAG_INCR : FLAG_DECR);
568 return 1;
572 /***********************************************************************
573 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
574 * control.
576 static LRESULT CALLBACK
577 UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
578 UINT_PTR uId, DWORD_PTR ref_data)
580 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr((HWND)ref_data);
582 TRACE("hwnd=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
583 hwnd, uMsg, wParam, lParam);
585 switch(uMsg)
587 case WM_KEYDOWN:
588 if (infoPtr)
590 UPDOWN_KeyPressed(infoPtr, (int)wParam);
591 if (wParam == VK_UP || wParam == VK_DOWN)
592 return 0;
594 break;
596 case WM_MOUSEWHEEL:
597 if (infoPtr)
598 UPDOWN_MouseWheel(infoPtr, (int)wParam);
599 break;
601 case WM_NCDESTROY:
602 RemoveWindowSubclass(hwnd, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID);
603 break;
604 default:
605 break;
608 return DefSubclassProc(hwnd, uMsg, wParam, lParam);
611 static void UPDOWN_ResetSubclass (UPDOWN_INFO *infoPtr)
613 SetWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID, 0);
616 /***********************************************************************
617 * UPDOWN_SetBuddy
619 * Sets bud as a new Buddy.
620 * Then, it should subclass the buddy
621 * If window has the UDS_ARROWKEYS, it subclasses the buddy window to
622 * process the UP/DOWN arrow keys.
623 * If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style
624 * the size/pos of the buddy and the control are adjusted accordingly.
626 static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
628 RECT budRect; /* new coord for the buddy */
629 int x, width; /* new x position and width for the up-down */
630 WCHAR buddyClass[40];
631 HWND old_buddy;
633 TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
635 old_buddy = infoPtr->Buddy;
637 UPDOWN_ResetSubclass (infoPtr);
639 if (!IsWindow(bud)) bud = NULL;
641 /* Store buddy window handle */
642 infoPtr->Buddy = bud;
644 if(bud) {
645 /* Store buddy window class type */
646 infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
647 if (GetClassNameW(bud, buddyClass, ARRAY_SIZE(buddyClass))) {
648 if (lstrcmpiW(buddyClass, WC_EDITW) == 0)
649 infoPtr->BuddyType = BUDDY_TYPE_EDIT;
650 else if (lstrcmpiW(buddyClass, WC_LISTBOXW) == 0)
651 infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
654 if (infoPtr->dwStyle & UDS_ARROWKEYS)
655 SetWindowSubclass(bud, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID,
656 (DWORD_PTR)infoPtr->Self);
658 /* Get the rect of the buddy relative to its parent */
659 GetWindowRect(infoPtr->Buddy, &budRect);
660 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2);
662 /* now do the positioning */
663 if (infoPtr->dwStyle & UDS_ALIGNLEFT) {
664 x = budRect.left;
665 budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP;
666 } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) {
667 budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
668 x = budRect.right+DEFAULT_XSEP;
669 } else {
670 /* nothing to do */
671 return old_buddy;
674 /* first adjust the buddy to accommodate the up/down */
675 SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
676 budRect.right - budRect.left, budRect.bottom - budRect.top,
677 SWP_NOACTIVATE|SWP_NOZORDER);
679 /* now position the up/down */
680 /* Since the UDS_ALIGN* flags were used, */
681 /* we will pick the position and size of the window. */
682 width = DEFAULT_WIDTH;
685 * If the updown has a buddy border, it has to overlap with the buddy
686 * to look as if it is integrated with the buddy control.
687 * We nudge the control or change its size to overlap.
689 if (UPDOWN_HasBuddyBorder(infoPtr)) {
690 if(infoPtr->dwStyle & UDS_ALIGNLEFT)
691 width += DEFAULT_BUDDYBORDER;
692 else
693 x -= DEFAULT_BUDDYBORDER;
696 SetWindowPos(infoPtr->Self, 0, x,
697 budRect.top - DEFAULT_ADDTOP, width,
698 budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
699 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
700 } else if (!(infoPtr->dwStyle & UDS_HORZ) && old_buddy != NULL) {
701 RECT rect;
702 GetWindowRect(infoPtr->Self, &rect);
703 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
704 SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
705 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
708 return old_buddy;
711 /***********************************************************************
712 * UPDOWN_DoAction
714 * This function increments/decrements the CurVal by the
715 * 'delta' amount according to the 'action' flag which can be a
716 * combination of FLAG_INCR and FLAG_DECR
717 * It notifies the parent as required.
718 * It handles wrapping and non-wrapping correctly.
719 * It is assumed that delta>0
721 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action)
723 NM_UPDOWN ni;
725 TRACE("%d by %d\n", action, delta);
727 /* check if we can do the modification first */
728 delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
729 if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
731 TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
733 /* We must notify parent now to obtain permission */
734 ni.iPos = infoPtr->CurVal;
735 ni.iDelta = delta;
736 ni.hdr.hwndFrom = infoPtr->Self;
737 ni.hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
738 ni.hdr.code = UDN_DELTAPOS;
739 if (!SendMessageW(infoPtr->Notify, WM_NOTIFY, ni.hdr.idFrom, (LPARAM)&ni)) {
740 /* Parent said: OK to adjust */
742 /* Now adjust value with (maybe new) delta */
743 if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
744 TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
746 /* Now take care about our buddy */
747 UPDOWN_SetBuddyInt (infoPtr);
751 /* Also, notify it. This message is sent in any case. */
752 SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
753 MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self);
756 /***********************************************************************
757 * UPDOWN_IsEnabled
759 * Returns TRUE if it is enabled as well as its buddy (if any)
760 * FALSE otherwise
762 static BOOL UPDOWN_IsEnabled (const UPDOWN_INFO *infoPtr)
764 if (!IsWindowEnabled(infoPtr->Self))
765 return FALSE;
766 if(infoPtr->Buddy)
767 return IsWindowEnabled(infoPtr->Buddy);
768 return TRUE;
771 /***********************************************************************
772 * UPDOWN_CancelMode
774 * Deletes any timers, releases the mouse and does redraw if necessary.
775 * If the control is not in "capture" mode, it does nothing.
776 * If the control was not in cancel mode, it returns FALSE.
777 * If the control was in cancel mode, it returns TRUE.
779 static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr)
781 if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
783 KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
784 KillTimer (infoPtr->Self, TIMER_ACCEL);
785 KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
787 if (GetCapture() == infoPtr->Self) {
788 NMHDR hdr;
789 hdr.hwndFrom = infoPtr->Self;
790 hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
791 hdr.code = NM_RELEASEDCAPTURE;
792 SendMessageW(infoPtr->Notify, WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);
793 ReleaseCapture();
796 infoPtr->Flags &= ~FLAG_PRESSED;
797 InvalidateRect (infoPtr->Self, NULL, FALSE);
799 return TRUE;
802 /***********************************************************************
803 * UPDOWN_HandleMouseEvent
805 * Handle a mouse event for the updown.
806 * 'pt' is the location of the mouse event in client or
807 * windows coordinates.
809 static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
811 POINT pt = { x, y };
812 RECT rect;
813 int temp, arrow;
814 TRACKMOUSEEVENT tme;
816 TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
818 switch(msg)
820 case WM_LBUTTONDOWN: /* Initialise mouse tracking */
822 /* If the buddy is an edit, will set focus to it */
823 if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
825 /* Now see which one is the 'active' arrow */
826 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
828 /* Update the flags if we are in/out */
829 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
830 if (arrow)
831 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
832 else
833 if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
835 if (infoPtr->Flags & FLAG_ARROW) {
837 /* Update the CurVal if necessary */
838 UPDOWN_GetBuddyInt (infoPtr);
840 /* Set up the correct flags */
841 infoPtr->Flags |= FLAG_PRESSED;
843 /* repaint the control */
844 InvalidateRect (infoPtr->Self, NULL, FALSE);
846 /* process the click */
847 temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
848 UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
850 /* now capture all mouse messages */
851 SetCapture (infoPtr->Self);
853 /* and startup the first timer */
854 SetTimer(infoPtr->Self, TIMER_AUTOREPEAT, INITIAL_DELAY, 0);
856 break;
858 case WM_MOUSEMOVE:
859 /* save the flags to see if any got modified */
860 temp = infoPtr->Flags;
862 /* Now see which one is the 'active' arrow */
863 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
865 /* Update the flags if we are in/out */
866 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
867 if(arrow) {
868 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
869 } else {
870 if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
873 /* If state changed, redraw the control */
874 if(temp != infoPtr->Flags)
875 InvalidateRect (infoPtr->Self, NULL, FALSE);
877 /* Set up tracking so the mousein flags can be reset when the
878 * mouse leaves the control */
879 tme.cbSize = sizeof( tme );
880 tme.dwFlags = TME_LEAVE;
881 tme.hwndTrack = infoPtr->Self;
882 TrackMouseEvent (&tme);
884 break;
885 case WM_MOUSELEAVE:
886 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
887 InvalidateRect (infoPtr->Self, NULL, FALSE);
888 break;
890 default:
891 ERR("Impossible case (msg=%x)!\n", msg);
896 /***********************************************************************
897 * UpDownWndProc
899 static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
901 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
902 static const WCHAR themeClass[] = {'S','p','i','n',0};
903 HTHEME theme;
905 TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam);
907 if (!infoPtr && (message != WM_CREATE))
908 return DefWindowProcW (hwnd, message, wParam, lParam);
910 switch(message)
912 case WM_CREATE:
914 CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam;
916 infoPtr = heap_alloc_zero(sizeof(*infoPtr));
917 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
919 /* initialize the info struct */
920 infoPtr->Self = hwnd;
921 infoPtr->Notify = pcs->hwndParent;
922 infoPtr->dwStyle = pcs->style;
923 infoPtr->AccelCount = 0;
924 infoPtr->AccelVect = 0;
925 infoPtr->AccelIndex = -1;
926 infoPtr->CurVal = 0;
927 infoPtr->MinVal = 100;
928 infoPtr->MaxVal = 0;
929 infoPtr->Base = 10; /* Default to base 10 */
930 infoPtr->Buddy = 0; /* No buddy window yet */
931 infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
933 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
934 if (!(infoPtr->dwStyle & UDS_HORZ))
935 SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy,
936 SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
938 /* Do we pick the buddy win ourselves? */
939 if (infoPtr->dwStyle & UDS_AUTOBUDDY)
940 UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV));
942 OpenThemeData (hwnd, themeClass);
944 TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
946 break;
948 case WM_DESTROY:
949 heap_free (infoPtr->AccelVect);
950 UPDOWN_ResetSubclass (infoPtr);
951 heap_free (infoPtr);
952 SetWindowLongPtrW (hwnd, 0, 0);
953 theme = GetWindowTheme (hwnd);
954 CloseThemeData (theme);
955 TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
956 break;
958 case WM_ENABLE:
959 if (wParam) {
960 infoPtr->dwStyle &= ~WS_DISABLED;
961 } else {
962 infoPtr->dwStyle |= WS_DISABLED;
963 UPDOWN_CancelMode (infoPtr);
965 InvalidateRect (infoPtr->Self, NULL, FALSE);
966 break;
968 case WM_STYLECHANGED:
969 if (wParam == GWL_STYLE) {
970 infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
971 InvalidateRect (infoPtr->Self, NULL, FALSE);
973 break;
975 case WM_THEMECHANGED:
976 theme = GetWindowTheme (hwnd);
977 CloseThemeData (theme);
978 OpenThemeData (hwnd, themeClass);
979 InvalidateRect (hwnd, NULL, FALSE);
980 break;
982 case WM_TIMER:
983 /* is this the auto-press timer? */
984 if(wParam == TIMER_AUTOPRESS) {
985 KillTimer(hwnd, TIMER_AUTOPRESS);
986 infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW);
987 InvalidateRect(infoPtr->Self, NULL, FALSE);
990 /* if initial timer, kill it and start the repeat timer */
991 if(wParam == TIMER_AUTOREPEAT) {
992 INT delay;
994 KillTimer(hwnd, TIMER_AUTOREPEAT);
995 /* if no accel info given, used default timer */
996 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) {
997 infoPtr->AccelIndex = -1;
998 delay = REPEAT_DELAY;
999 } else {
1000 infoPtr->AccelIndex = 0; /* otherwise, use it */
1001 delay = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1003 SetTimer(hwnd, TIMER_ACCEL, delay, 0);
1006 /* now, if the mouse is above us, do the thing...*/
1007 if(infoPtr->Flags & FLAG_MOUSEIN) {
1008 int temp;
1010 temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
1011 UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
1013 if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
1014 KillTimer(hwnd, TIMER_ACCEL);
1015 infoPtr->AccelIndex++; /* move to the next accel info */
1016 temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1017 /* make sure we have at least 1ms intervals */
1018 SetTimer(hwnd, TIMER_ACCEL, temp, 0);
1021 break;
1023 case WM_CANCELMODE:
1024 return UPDOWN_CancelMode (infoPtr);
1026 case WM_LBUTTONUP:
1027 if (GetCapture() != infoPtr->Self) break;
1029 if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
1030 (infoPtr->Flags & FLAG_ARROW) ) {
1032 SendMessageW( infoPtr->Notify,
1033 (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
1034 MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
1035 (LPARAM)hwnd);
1036 if (UPDOWN_IsBuddyEdit(infoPtr))
1037 SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
1039 UPDOWN_CancelMode(infoPtr);
1040 break;
1042 case WM_LBUTTONDOWN:
1043 case WM_MOUSEMOVE:
1044 case WM_MOUSELEAVE:
1045 if(UPDOWN_IsEnabled(infoPtr))
1046 UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1047 break;
1049 case WM_MOUSEWHEEL:
1050 UPDOWN_MouseWheel(infoPtr, wParam);
1051 break;
1053 case WM_KEYDOWN:
1054 if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
1055 return UPDOWN_KeyPressed(infoPtr, (int)wParam);
1056 break;
1058 case WM_PRINTCLIENT:
1059 case WM_PAINT:
1060 return UPDOWN_Paint (infoPtr, (HDC)wParam);
1062 case UDM_GETACCEL:
1063 if (wParam==0 && lParam==0) return infoPtr->AccelCount;
1064 if (wParam && lParam) {
1065 int temp = min(infoPtr->AccelCount, wParam);
1066 memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL));
1067 return temp;
1069 return 0;
1071 case UDM_SETACCEL:
1073 TRACE("UDM_SETACCEL\n");
1075 if(infoPtr->AccelVect) {
1076 heap_free (infoPtr->AccelVect);
1077 infoPtr->AccelCount = 0;
1078 infoPtr->AccelVect = 0;
1080 if(wParam==0) return TRUE;
1081 infoPtr->AccelVect = heap_alloc(wParam*sizeof(UDACCEL));
1082 if(!infoPtr->AccelVect) return FALSE;
1083 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
1084 infoPtr->AccelCount = wParam;
1086 if (TRACE_ON(updown))
1088 UINT i;
1090 for (i = 0; i < wParam; i++)
1091 TRACE("%u: nSec %u nInc %u\n", i,
1092 infoPtr->AccelVect[i].nSec, infoPtr->AccelVect[i].nInc);
1095 return TRUE;
1097 case UDM_GETBASE:
1098 return infoPtr->Base;
1100 case UDM_SETBASE:
1101 TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd);
1102 if (wParam==10 || wParam==16) {
1103 WPARAM old_base = infoPtr->Base;
1104 infoPtr->Base = wParam;
1106 if (old_base != infoPtr->Base)
1107 UPDOWN_SetBuddyInt(infoPtr);
1109 return old_base;
1111 break;
1113 case UDM_GETBUDDY:
1114 return (LRESULT)infoPtr->Buddy;
1116 case UDM_SETBUDDY:
1117 return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
1119 case UDM_GETPOS:
1121 BOOL err;
1122 int pos;
1124 pos = UPDOWN_GetPos(infoPtr, &err);
1125 return MAKELONG(pos, err);
1127 case UDM_SETPOS:
1129 return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam));
1131 case UDM_GETRANGE:
1132 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
1134 case UDM_SETRANGE:
1135 /* we must have:
1136 UD_MINVAL <= Max <= UD_MAXVAL
1137 UD_MINVAL <= Min <= UD_MAXVAL
1138 |Max-Min| <= UD_MAXVAL */
1139 UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
1140 break;
1142 case UDM_GETRANGE32:
1143 if (wParam) *(LPINT)wParam = infoPtr->MinVal;
1144 if (lParam) *(LPINT)lParam = infoPtr->MaxVal;
1145 break;
1147 case UDM_SETRANGE32:
1148 UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
1149 break;
1151 case UDM_GETPOS32:
1153 return UPDOWN_GetPos(infoPtr, (BOOL*)lParam);
1155 case UDM_SETPOS32:
1157 return UPDOWN_SetPos(infoPtr, (int)lParam);
1159 case UDM_GETUNICODEFORMAT:
1160 /* we lie a bit here, we're always using Unicode internally */
1161 return infoPtr->UnicodeFormat;
1163 case UDM_SETUNICODEFORMAT:
1165 /* do we really need to honour this flag? */
1166 int temp = infoPtr->UnicodeFormat;
1167 infoPtr->UnicodeFormat = (BOOL)wParam;
1168 return temp;
1170 default:
1171 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
1172 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam);
1173 return DefWindowProcW (hwnd, message, wParam, lParam);
1176 return 0;
1179 /***********************************************************************
1180 * UPDOWN_Register [Internal]
1182 * Registers the updown window class.
1184 void UPDOWN_Register(void)
1186 WNDCLASSW wndClass;
1188 ZeroMemory( &wndClass, sizeof( WNDCLASSW ) );
1189 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1190 wndClass.lpfnWndProc = UpDownWindowProc;
1191 wndClass.cbClsExtra = 0;
1192 wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
1193 wndClass.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
1194 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1195 wndClass.lpszClassName = UPDOWN_CLASSW;
1197 RegisterClassW( &wndClass );
1201 /***********************************************************************
1202 * UPDOWN_Unregister [Internal]
1204 * Unregisters the updown window class.
1206 void UPDOWN_Unregister (void)
1208 UnregisterClassW (UPDOWN_CLASSW, NULL);