wininet: Don't update *lpdwIndex if HttpQueryInfoW fails with ERROR_INSUFFICIENT_BUFFER.
[wine/wine-gecko.git] / dlls / comctl32 / updown.c
blob28dd5e3ee234d7c964996cebcaa7b68676b0de40
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;
370 HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy);
371 if (!buddyTheme) return FALSE;
373 GetClientRect (infoPtr->Buddy, &br);
374 MapWindowPoints (infoPtr->Buddy, infoPtr->Self, (POINT*)&br, 2);
375 /* FIXME: take disabled etc. into account */
376 DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL);
377 return TRUE;
380 /***********************************************************************
381 * UPDOWN_Draw
383 * Draw the arrows. The background need not be erased.
385 static LRESULT UPDOWN_Draw (const UPDOWN_INFO *infoPtr, HDC hdc)
387 BOOL uPressed, uHot, dPressed, dHot;
388 RECT rect;
389 HTHEME theme = GetWindowTheme (infoPtr->Self);
390 int uPart = 0, uState = 0, dPart = 0, dState = 0;
391 BOOL needBuddyBg = FALSE;
393 uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR);
394 uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
395 dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR);
396 dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
397 if (theme) {
398 uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP;
399 uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
400 : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL));
401 dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN;
402 dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
403 : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL));
404 needBuddyBg = IsWindow (infoPtr->Buddy)
405 && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState)
406 || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState));
409 /* Draw the common border between ourselves and our buddy */
410 if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) {
411 if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) {
412 GetClientRect(infoPtr->Self, &rect);
413 DrawEdge(hdc, &rect, EDGE_SUNKEN,
414 BF_BOTTOM | BF_TOP |
415 (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT));
419 /* Draw the incr button */
420 UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR);
421 if (theme) {
422 DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL);
423 } else {
424 DrawFrameControl(hdc, &rect, DFC_SCROLL,
425 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) |
426 ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) |
427 (uPressed ? DFCS_PUSHED : 0) |
428 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
431 /* Draw the decr button */
432 UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR);
433 if (theme) {
434 DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL);
435 } else {
436 DrawFrameControl(hdc, &rect, DFC_SCROLL,
437 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) |
438 ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) |
439 (dPressed ? DFCS_PUSHED : 0) |
440 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
443 return 0;
446 /***********************************************************************
447 * UPDOWN_Paint
449 * Asynchronous drawing (must ONLY be used in WM_PAINT).
450 * Calls UPDOWN_Draw.
452 static LRESULT UPDOWN_Paint (const UPDOWN_INFO *infoPtr, HDC hdc)
454 PAINTSTRUCT ps;
455 if (hdc) return UPDOWN_Draw (infoPtr, hdc);
456 hdc = BeginPaint (infoPtr->Self, &ps);
457 UPDOWN_Draw (infoPtr, hdc);
458 EndPaint (infoPtr->Self, &ps);
459 return 0;
462 /***********************************************************************
463 * UPDOWN_KeyPressed
465 * Handle key presses (up & down) when we have to do so
467 static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
469 int arrow, accel;
471 if (key == VK_UP) arrow = FLAG_INCR;
472 else if (key == VK_DOWN) arrow = FLAG_DECR;
473 else return 1;
475 UPDOWN_GetBuddyInt (infoPtr);
476 infoPtr->Flags &= ~FLAG_ARROW;
477 infoPtr->Flags |= FLAG_PRESSED | arrow;
478 InvalidateRect (infoPtr->Self, NULL, FALSE);
479 SetTimer(infoPtr->Self, TIMER_AUTOPRESS, AUTOPRESS_DELAY, 0);
480 accel = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
481 UPDOWN_DoAction (infoPtr, accel, arrow);
482 return 0;
485 static int UPDOWN_GetPos(UPDOWN_INFO *infoPtr, BOOL *err)
487 BOOL succ = UPDOWN_GetBuddyInt(infoPtr);
488 int val = infoPtr->CurVal;
490 if(!UPDOWN_InBounds(infoPtr, val)) {
491 if((infoPtr->MinVal < infoPtr->MaxVal && val < infoPtr->MinVal)
492 || (infoPtr->MinVal > infoPtr->MaxVal && val > infoPtr->MinVal))
493 val = infoPtr->MinVal;
494 else
495 val = infoPtr->MaxVal;
497 succ = FALSE;
500 if(err) *err = !succ;
501 return val;
504 static int UPDOWN_SetPos(UPDOWN_INFO *infoPtr, int pos)
506 int ret = infoPtr->CurVal;
508 if(!UPDOWN_InBounds(infoPtr, pos)) {
509 if((infoPtr->MinVal < infoPtr->MaxVal && pos < infoPtr->MinVal)
510 || (infoPtr->MinVal > infoPtr->MaxVal && pos > infoPtr->MinVal))
511 pos = infoPtr->MinVal;
512 else
513 pos = infoPtr->MaxVal;
516 infoPtr->CurVal = pos;
517 UPDOWN_SetBuddyInt(infoPtr);
519 if(!UPDOWN_InBounds(infoPtr, ret)) {
520 if((infoPtr->MinVal < infoPtr->MaxVal && ret < infoPtr->MinVal)
521 || (infoPtr->MinVal > infoPtr->MaxVal && ret > infoPtr->MinVal))
522 ret = infoPtr->MinVal;
523 else
524 ret = infoPtr->MaxVal;
526 return ret;
530 /***********************************************************************
531 * UPDOWN_SetRange
533 * Handle UDM_SETRANGE, UDM_SETRANGE32
535 * FIXME: handle Max == Min properly:
536 * - arrows should be disabled (without WS_DISABLED set),
537 * visually they can't be pressed and don't respond;
538 * - all input messages should still pass in.
540 static LRESULT UPDOWN_SetRange(UPDOWN_INFO *infoPtr, INT Max, INT Min)
542 infoPtr->MaxVal = Max;
543 infoPtr->MinVal = Min;
545 TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
546 infoPtr->MinVal, infoPtr->MaxVal, infoPtr->Self);
548 return 0;
551 /***********************************************************************
552 * UPDOWN_MouseWheel
554 * Handle mouse wheel scrolling
556 static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
558 int iWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
560 if (wParam & (MK_SHIFT | MK_CONTROL))
561 return 0;
563 if (iWheelDelta != 0)
565 UPDOWN_GetBuddyInt(infoPtr);
566 UPDOWN_DoAction(infoPtr, abs(iWheelDelta), iWheelDelta > 0 ? FLAG_INCR : FLAG_DECR);
569 return 1;
573 /***********************************************************************
574 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
575 * control.
577 static LRESULT CALLBACK
578 UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
579 UINT_PTR uId, DWORD_PTR ref_data)
581 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr((HWND)ref_data);
583 TRACE("hwnd=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
584 hwnd, uMsg, wParam, lParam);
586 switch(uMsg)
588 case WM_KEYDOWN:
589 UPDOWN_KeyPressed(infoPtr, (int)wParam);
590 if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
591 break;
593 case WM_MOUSEWHEEL:
594 UPDOWN_MouseWheel(infoPtr, (int)wParam);
595 break;
597 default:
598 break;
601 return DefSubclassProc(hwnd, uMsg, wParam, lParam);
604 /***********************************************************************
605 * UPDOWN_SetBuddy
607 * Sets bud as a new Buddy.
608 * Then, it should subclass the buddy
609 * If window has the UDS_ARROWKEYS, it subclasses the buddy window to
610 * process the UP/DOWN arrow keys.
611 * If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style
612 * the size/pos of the buddy and the control are adjusted accordingly.
614 static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
616 RECT budRect; /* new coord for the buddy */
617 int x, width; /* new x position and width for the up-down */
618 WCHAR buddyClass[40];
619 HWND ret;
621 TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
623 ret = infoPtr->Buddy;
625 /* there is already a buddy assigned */
626 if (infoPtr->Buddy) RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
627 BUDDY_SUBCLASSID);
628 if (!IsWindow(bud)) bud = NULL;
630 /* Store buddy window handle */
631 infoPtr->Buddy = bud;
633 if(bud) {
634 /* Store buddy window class type */
635 infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
636 if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) {
637 if (lstrcmpiW(buddyClass, WC_EDITW) == 0)
638 infoPtr->BuddyType = BUDDY_TYPE_EDIT;
639 else if (lstrcmpiW(buddyClass, WC_LISTBOXW) == 0)
640 infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
643 if (infoPtr->dwStyle & UDS_ARROWKEYS)
644 SetWindowSubclass(bud, UPDOWN_Buddy_SubclassProc, BUDDY_SUBCLASSID,
645 (DWORD_PTR)infoPtr->Self);
647 /* Get the rect of the buddy relative to its parent */
648 GetWindowRect(infoPtr->Buddy, &budRect);
649 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2);
651 /* now do the positioning */
652 if (infoPtr->dwStyle & UDS_ALIGNLEFT) {
653 x = budRect.left;
654 budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP;
655 } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) {
656 budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
657 x = budRect.right+DEFAULT_XSEP;
658 } else {
659 /* nothing to do */
660 return ret;
663 /* first adjust the buddy to accommodate the up/down */
664 SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
665 budRect.right - budRect.left, budRect.bottom - budRect.top,
666 SWP_NOACTIVATE|SWP_NOZORDER);
668 /* now position the up/down */
669 /* Since the UDS_ALIGN* flags were used, */
670 /* we will pick the position and size of the window. */
671 width = DEFAULT_WIDTH;
674 * If the updown has a buddy border, it has to overlap with the buddy
675 * to look as if it is integrated with the buddy control.
676 * We nudge the control or change its size to overlap.
678 if (UPDOWN_HasBuddyBorder(infoPtr)) {
679 if(infoPtr->dwStyle & UDS_ALIGNLEFT)
680 width += DEFAULT_BUDDYBORDER;
681 else
682 x -= DEFAULT_BUDDYBORDER;
685 SetWindowPos(infoPtr->Self, 0, x,
686 budRect.top - DEFAULT_ADDTOP, width,
687 budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
688 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
689 } else {
690 RECT rect;
691 GetWindowRect(infoPtr->Self, &rect);
692 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
693 SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
694 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
696 return ret;
699 /***********************************************************************
700 * UPDOWN_DoAction
702 * This function increments/decrements the CurVal by the
703 * 'delta' amount according to the 'action' flag which can be a
704 * combination of FLAG_INCR and FLAG_DECR
705 * It notifies the parent as required.
706 * It handles wrapping and non-wrapping correctly.
707 * It is assumed that delta>0
709 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action)
711 NM_UPDOWN ni;
713 TRACE("%d by %d\n", action, delta);
715 /* check if we can do the modification first */
716 delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
717 if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
719 TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
721 /* We must notify parent now to obtain permission */
722 ni.iPos = infoPtr->CurVal;
723 ni.iDelta = delta;
724 ni.hdr.hwndFrom = infoPtr->Self;
725 ni.hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
726 ni.hdr.code = UDN_DELTAPOS;
727 if (!SendMessageW(infoPtr->Notify, WM_NOTIFY, ni.hdr.idFrom, (LPARAM)&ni)) {
728 /* Parent said: OK to adjust */
730 /* Now adjust value with (maybe new) delta */
731 if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
732 TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
734 /* Now take care about our buddy */
735 UPDOWN_SetBuddyInt (infoPtr);
739 /* Also, notify it. This message is sent in any case. */
740 SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
741 MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self);
744 /***********************************************************************
745 * UPDOWN_IsEnabled
747 * Returns TRUE if it is enabled as well as its buddy (if any)
748 * FALSE otherwise
750 static BOOL UPDOWN_IsEnabled (const UPDOWN_INFO *infoPtr)
752 if (!IsWindowEnabled(infoPtr->Self))
753 return FALSE;
754 if(infoPtr->Buddy)
755 return IsWindowEnabled(infoPtr->Buddy);
756 return TRUE;
759 /***********************************************************************
760 * UPDOWN_CancelMode
762 * Deletes any timers, releases the mouse and does redraw if necessary.
763 * If the control is not in "capture" mode, it does nothing.
764 * If the control was not in cancel mode, it returns FALSE.
765 * If the control was in cancel mode, it returns TRUE.
767 static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr)
769 if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
771 KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
772 KillTimer (infoPtr->Self, TIMER_ACCEL);
773 KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
775 if (GetCapture() == infoPtr->Self) {
776 NMHDR hdr;
777 hdr.hwndFrom = infoPtr->Self;
778 hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
779 hdr.code = NM_RELEASEDCAPTURE;
780 SendMessageW(infoPtr->Notify, WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);
781 ReleaseCapture();
784 infoPtr->Flags &= ~FLAG_PRESSED;
785 InvalidateRect (infoPtr->Self, NULL, FALSE);
787 return TRUE;
790 /***********************************************************************
791 * UPDOWN_HandleMouseEvent
793 * Handle a mouse event for the updown.
794 * 'pt' is the location of the mouse event in client or
795 * windows coordinates.
797 static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
799 POINT pt = { x, y };
800 RECT rect;
801 int temp, arrow;
802 TRACKMOUSEEVENT tme;
804 TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
806 switch(msg)
808 case WM_LBUTTONDOWN: /* Initialise mouse tracking */
810 /* If the buddy is an edit, will set focus to it */
811 if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
813 /* Now see which one is the 'active' arrow */
814 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
816 /* Update the flags if we are in/out */
817 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
818 if (arrow)
819 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
820 else
821 if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
823 if (infoPtr->Flags & FLAG_ARROW) {
825 /* Update the CurVal if necessary */
826 UPDOWN_GetBuddyInt (infoPtr);
828 /* Set up the correct flags */
829 infoPtr->Flags |= FLAG_PRESSED;
831 /* repaint the control */
832 InvalidateRect (infoPtr->Self, NULL, FALSE);
834 /* process the click */
835 temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
836 UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
838 /* now capture all mouse messages */
839 SetCapture (infoPtr->Self);
841 /* and startup the first timer */
842 SetTimer(infoPtr->Self, TIMER_AUTOREPEAT, INITIAL_DELAY, 0);
844 break;
846 case WM_MOUSEMOVE:
847 /* save the flags to see if any got modified */
848 temp = infoPtr->Flags;
850 /* Now see which one is the 'active' arrow */
851 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
853 /* Update the flags if we are in/out */
854 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
855 if(arrow) {
856 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
857 } else {
858 if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
861 /* If state changed, redraw the control */
862 if(temp != infoPtr->Flags)
863 InvalidateRect (infoPtr->Self, NULL, FALSE);
865 /* Set up tracking so the mousein flags can be reset when the
866 * mouse leaves the control */
867 tme.cbSize = sizeof( tme );
868 tme.dwFlags = TME_LEAVE;
869 tme.hwndTrack = infoPtr->Self;
870 TrackMouseEvent (&tme);
872 break;
873 case WM_MOUSELEAVE:
874 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
875 InvalidateRect (infoPtr->Self, NULL, FALSE);
876 break;
878 default:
879 ERR("Impossible case (msg=%x)!\n", msg);
884 /***********************************************************************
885 * UpDownWndProc
887 static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
889 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
890 static const WCHAR themeClass[] = {'S','p','i','n',0};
891 HTHEME theme;
893 TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam);
895 if (!infoPtr && (message != WM_CREATE))
896 return DefWindowProcW (hwnd, message, wParam, lParam);
898 switch(message)
900 case WM_CREATE:
902 CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam;
904 infoPtr = Alloc (sizeof(UPDOWN_INFO));
905 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
907 /* initialize the info struct */
908 infoPtr->Self = hwnd;
909 infoPtr->Notify = pcs->hwndParent;
910 infoPtr->dwStyle = pcs->style;
911 infoPtr->AccelCount = 0;
912 infoPtr->AccelVect = 0;
913 infoPtr->AccelIndex = -1;
914 infoPtr->CurVal = 0;
915 infoPtr->MinVal = 100;
916 infoPtr->MaxVal = 0;
917 infoPtr->Base = 10; /* Default to base 10 */
918 infoPtr->Buddy = 0; /* No buddy window yet */
919 infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
921 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
922 if (!(infoPtr->dwStyle & UDS_HORZ))
923 SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy,
924 SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
926 /* Do we pick the buddy win ourselves? */
927 if (infoPtr->dwStyle & UDS_AUTOBUDDY)
928 UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV));
930 OpenThemeData (hwnd, themeClass);
932 TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
934 break;
936 case WM_DESTROY:
937 Free (infoPtr->AccelVect);
939 if (infoPtr->Buddy)
940 RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
941 BUDDY_SUBCLASSID);
942 Free (infoPtr);
943 SetWindowLongPtrW (hwnd, 0, 0);
944 theme = GetWindowTheme (hwnd);
945 CloseThemeData (theme);
946 TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
947 break;
949 case WM_ENABLE:
950 if (wParam) {
951 infoPtr->dwStyle &= ~WS_DISABLED;
952 } else {
953 infoPtr->dwStyle |= WS_DISABLED;
954 UPDOWN_CancelMode (infoPtr);
956 InvalidateRect (infoPtr->Self, NULL, FALSE);
957 break;
959 case WM_STYLECHANGED:
960 if (wParam == GWL_STYLE) {
961 infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
962 InvalidateRect (infoPtr->Self, NULL, FALSE);
964 break;
966 case WM_THEMECHANGED:
967 theme = GetWindowTheme (hwnd);
968 CloseThemeData (theme);
969 OpenThemeData (hwnd, themeClass);
970 InvalidateRect (hwnd, NULL, FALSE);
971 break;
973 case WM_TIMER:
974 /* is this the auto-press timer? */
975 if(wParam == TIMER_AUTOPRESS) {
976 KillTimer(hwnd, TIMER_AUTOPRESS);
977 infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW);
978 InvalidateRect(infoPtr->Self, NULL, FALSE);
981 /* if initial timer, kill it and start the repeat timer */
982 if(wParam == TIMER_AUTOREPEAT) {
983 INT delay;
985 KillTimer(hwnd, TIMER_AUTOREPEAT);
986 /* if no accel info given, used default timer */
987 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) {
988 infoPtr->AccelIndex = -1;
989 delay = REPEAT_DELAY;
990 } else {
991 infoPtr->AccelIndex = 0; /* otherwise, use it */
992 delay = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
994 SetTimer(hwnd, TIMER_ACCEL, delay, 0);
997 /* now, if the mouse is above us, do the thing...*/
998 if(infoPtr->Flags & FLAG_MOUSEIN) {
999 int temp;
1001 temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
1002 UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
1004 if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
1005 KillTimer(hwnd, TIMER_ACCEL);
1006 infoPtr->AccelIndex++; /* move to the next accel info */
1007 temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1008 /* make sure we have at least 1ms intervals */
1009 SetTimer(hwnd, TIMER_ACCEL, temp, 0);
1012 break;
1014 case WM_CANCELMODE:
1015 return UPDOWN_CancelMode (infoPtr);
1017 case WM_LBUTTONUP:
1018 if (GetCapture() != infoPtr->Self) break;
1020 if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
1021 (infoPtr->Flags & FLAG_ARROW) ) {
1023 SendMessageW( infoPtr->Notify,
1024 (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
1025 MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
1026 (LPARAM)hwnd);
1027 if (UPDOWN_IsBuddyEdit(infoPtr))
1028 SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
1030 UPDOWN_CancelMode(infoPtr);
1031 break;
1033 case WM_LBUTTONDOWN:
1034 case WM_MOUSEMOVE:
1035 case WM_MOUSELEAVE:
1036 if(UPDOWN_IsEnabled(infoPtr))
1037 UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1038 break;
1040 case WM_MOUSEWHEEL:
1041 UPDOWN_MouseWheel(infoPtr, wParam);
1042 break;
1044 case WM_KEYDOWN:
1045 if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
1046 return UPDOWN_KeyPressed(infoPtr, (int)wParam);
1047 break;
1049 case WM_PRINTCLIENT:
1050 case WM_PAINT:
1051 return UPDOWN_Paint (infoPtr, (HDC)wParam);
1053 case UDM_GETACCEL:
1054 if (wParam==0 && lParam==0) return infoPtr->AccelCount;
1055 if (wParam && lParam) {
1056 int temp = min(infoPtr->AccelCount, wParam);
1057 memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL));
1058 return temp;
1060 return 0;
1062 case UDM_SETACCEL:
1064 TRACE("UDM_SETACCEL\n");
1066 if(infoPtr->AccelVect) {
1067 Free (infoPtr->AccelVect);
1068 infoPtr->AccelCount = 0;
1069 infoPtr->AccelVect = 0;
1071 if(wParam==0) return TRUE;
1072 infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL));
1073 if(infoPtr->AccelVect == 0) return FALSE;
1074 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
1075 infoPtr->AccelCount = wParam;
1077 if (TRACE_ON(updown))
1079 UINT i;
1081 for (i = 0; i < wParam; i++)
1082 TRACE("%u: nSec %u nInc %u\n", i,
1083 infoPtr->AccelVect[i].nSec, infoPtr->AccelVect[i].nInc);
1086 return TRUE;
1088 case UDM_GETBASE:
1089 return infoPtr->Base;
1091 case UDM_SETBASE:
1092 TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd);
1093 if (wParam==10 || wParam==16) {
1094 WPARAM old_base = infoPtr->Base;
1095 infoPtr->Base = wParam;
1097 if (old_base != infoPtr->Base)
1098 UPDOWN_SetBuddyInt(infoPtr);
1100 return old_base;
1102 break;
1104 case UDM_GETBUDDY:
1105 return (LRESULT)infoPtr->Buddy;
1107 case UDM_SETBUDDY:
1108 return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
1110 case UDM_GETPOS:
1112 BOOL err;
1113 int pos;
1115 pos = UPDOWN_GetPos(infoPtr, &err);
1116 return MAKELONG(pos, err);
1118 case UDM_SETPOS:
1120 return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam));
1122 case UDM_GETRANGE:
1123 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
1125 case UDM_SETRANGE:
1126 /* we must have:
1127 UD_MINVAL <= Max <= UD_MAXVAL
1128 UD_MINVAL <= Min <= UD_MAXVAL
1129 |Max-Min| <= UD_MAXVAL */
1130 UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
1131 break;
1133 case UDM_GETRANGE32:
1134 if (wParam) *(LPINT)wParam = infoPtr->MinVal;
1135 if (lParam) *(LPINT)lParam = infoPtr->MaxVal;
1136 break;
1138 case UDM_SETRANGE32:
1139 UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
1140 break;
1142 case UDM_GETPOS32:
1144 return UPDOWN_GetPos(infoPtr, (BOOL*)lParam);
1146 case UDM_SETPOS32:
1148 return UPDOWN_SetPos(infoPtr, (int)lParam);
1150 case UDM_GETUNICODEFORMAT:
1151 /* we lie a bit here, we're always using Unicode internally */
1152 return infoPtr->UnicodeFormat;
1154 case UDM_SETUNICODEFORMAT:
1156 /* do we really need to honour this flag? */
1157 int temp = infoPtr->UnicodeFormat;
1158 infoPtr->UnicodeFormat = (BOOL)wParam;
1159 return temp;
1161 default:
1162 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
1163 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam);
1164 return DefWindowProcW (hwnd, message, wParam, lParam);
1167 return 0;
1170 /***********************************************************************
1171 * UPDOWN_Register [Internal]
1173 * Registers the updown window class.
1175 void UPDOWN_Register(void)
1177 WNDCLASSW wndClass;
1179 ZeroMemory( &wndClass, sizeof( WNDCLASSW ) );
1180 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1181 wndClass.lpfnWndProc = UpDownWindowProc;
1182 wndClass.cbClsExtra = 0;
1183 wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
1184 wndClass.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
1185 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1186 wndClass.lpszClassName = UPDOWN_CLASSW;
1188 RegisterClassW( &wndClass );
1192 /***********************************************************************
1193 * UPDOWN_Unregister [Internal]
1195 * Unregisters the updown window class.
1197 void UPDOWN_Unregister (void)
1199 UnregisterClassW (UPDOWN_CLASSW, NULL);