wordpad: Add a dropdown menu to the bullet button.
[wine.git] / dlls / comctl32 / updown.c
blobd18840859cffb9a28dd5b69663b0335e8b807940
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 ret;
627 TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
629 ret = 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 ret;
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 {
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);
702 return ret;
705 /***********************************************************************
706 * UPDOWN_DoAction
708 * This function increments/decrements the CurVal by the
709 * 'delta' amount according to the 'action' flag which can be a
710 * combination of FLAG_INCR and FLAG_DECR
711 * It notifies the parent as required.
712 * It handles wrapping and non-wrapping correctly.
713 * It is assumed that delta>0
715 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action)
717 NM_UPDOWN ni;
719 TRACE("%d by %d\n", action, delta);
721 /* check if we can do the modification first */
722 delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
723 if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
725 TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
727 /* We must notify parent now to obtain permission */
728 ni.iPos = infoPtr->CurVal;
729 ni.iDelta = delta;
730 ni.hdr.hwndFrom = infoPtr->Self;
731 ni.hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
732 ni.hdr.code = UDN_DELTAPOS;
733 if (!SendMessageW(infoPtr->Notify, WM_NOTIFY, ni.hdr.idFrom, (LPARAM)&ni)) {
734 /* Parent said: OK to adjust */
736 /* Now adjust value with (maybe new) delta */
737 if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
738 TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
740 /* Now take care about our buddy */
741 UPDOWN_SetBuddyInt (infoPtr);
745 /* Also, notify it. This message is sent in any case. */
746 SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
747 MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self);
750 /***********************************************************************
751 * UPDOWN_IsEnabled
753 * Returns TRUE if it is enabled as well as its buddy (if any)
754 * FALSE otherwise
756 static BOOL UPDOWN_IsEnabled (const UPDOWN_INFO *infoPtr)
758 if (!IsWindowEnabled(infoPtr->Self))
759 return FALSE;
760 if(infoPtr->Buddy)
761 return IsWindowEnabled(infoPtr->Buddy);
762 return TRUE;
765 /***********************************************************************
766 * UPDOWN_CancelMode
768 * Deletes any timers, releases the mouse and does redraw if necessary.
769 * If the control is not in "capture" mode, it does nothing.
770 * If the control was not in cancel mode, it returns FALSE.
771 * If the control was in cancel mode, it returns TRUE.
773 static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr)
775 if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
777 KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
778 KillTimer (infoPtr->Self, TIMER_ACCEL);
779 KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
781 if (GetCapture() == infoPtr->Self) {
782 NMHDR hdr;
783 hdr.hwndFrom = infoPtr->Self;
784 hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
785 hdr.code = NM_RELEASEDCAPTURE;
786 SendMessageW(infoPtr->Notify, WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);
787 ReleaseCapture();
790 infoPtr->Flags &= ~FLAG_PRESSED;
791 InvalidateRect (infoPtr->Self, NULL, FALSE);
793 return TRUE;
796 /***********************************************************************
797 * UPDOWN_HandleMouseEvent
799 * Handle a mouse event for the updown.
800 * 'pt' is the location of the mouse event in client or
801 * windows coordinates.
803 static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
805 POINT pt = { x, y };
806 RECT rect;
807 int temp, arrow;
808 TRACKMOUSEEVENT tme;
810 TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
812 switch(msg)
814 case WM_LBUTTONDOWN: /* Initialise mouse tracking */
816 /* If the buddy is an edit, will set focus to it */
817 if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
819 /* Now see which one is the 'active' arrow */
820 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
822 /* Update the flags if we are in/out */
823 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
824 if (arrow)
825 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
826 else
827 if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
829 if (infoPtr->Flags & FLAG_ARROW) {
831 /* Update the CurVal if necessary */
832 UPDOWN_GetBuddyInt (infoPtr);
834 /* Set up the correct flags */
835 infoPtr->Flags |= FLAG_PRESSED;
837 /* repaint the control */
838 InvalidateRect (infoPtr->Self, NULL, FALSE);
840 /* process the click */
841 temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
842 UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
844 /* now capture all mouse messages */
845 SetCapture (infoPtr->Self);
847 /* and startup the first timer */
848 SetTimer(infoPtr->Self, TIMER_AUTOREPEAT, INITIAL_DELAY, 0);
850 break;
852 case WM_MOUSEMOVE:
853 /* save the flags to see if any got modified */
854 temp = infoPtr->Flags;
856 /* Now see which one is the 'active' arrow */
857 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
859 /* Update the flags if we are in/out */
860 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
861 if(arrow) {
862 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
863 } else {
864 if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
867 /* If state changed, redraw the control */
868 if(temp != infoPtr->Flags)
869 InvalidateRect (infoPtr->Self, NULL, FALSE);
871 /* Set up tracking so the mousein flags can be reset when the
872 * mouse leaves the control */
873 tme.cbSize = sizeof( tme );
874 tme.dwFlags = TME_LEAVE;
875 tme.hwndTrack = infoPtr->Self;
876 TrackMouseEvent (&tme);
878 break;
879 case WM_MOUSELEAVE:
880 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
881 InvalidateRect (infoPtr->Self, NULL, FALSE);
882 break;
884 default:
885 ERR("Impossible case (msg=%x)!\n", msg);
890 /***********************************************************************
891 * UpDownWndProc
893 static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
895 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
896 static const WCHAR themeClass[] = {'S','p','i','n',0};
897 HTHEME theme;
899 TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam);
901 if (!infoPtr && (message != WM_CREATE))
902 return DefWindowProcW (hwnd, message, wParam, lParam);
904 switch(message)
906 case WM_CREATE:
908 CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam;
910 infoPtr = Alloc (sizeof(UPDOWN_INFO));
911 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
913 /* initialize the info struct */
914 infoPtr->Self = hwnd;
915 infoPtr->Notify = pcs->hwndParent;
916 infoPtr->dwStyle = pcs->style;
917 infoPtr->AccelCount = 0;
918 infoPtr->AccelVect = 0;
919 infoPtr->AccelIndex = -1;
920 infoPtr->CurVal = 0;
921 infoPtr->MinVal = 100;
922 infoPtr->MaxVal = 0;
923 infoPtr->Base = 10; /* Default to base 10 */
924 infoPtr->Buddy = 0; /* No buddy window yet */
925 infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
927 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
928 if (!(infoPtr->dwStyle & UDS_HORZ))
929 SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy,
930 SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
932 /* Do we pick the buddy win ourselves? */
933 if (infoPtr->dwStyle & UDS_AUTOBUDDY)
934 UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV));
936 OpenThemeData (hwnd, themeClass);
938 TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
940 break;
942 case WM_DESTROY:
943 Free (infoPtr->AccelVect);
945 if (infoPtr->Buddy)
946 RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
947 BUDDY_SUBCLASSID);
948 Free (infoPtr);
949 SetWindowLongPtrW (hwnd, 0, 0);
950 theme = GetWindowTheme (hwnd);
951 CloseThemeData (theme);
952 TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
953 break;
955 case WM_ENABLE:
956 if (wParam) {
957 infoPtr->dwStyle &= ~WS_DISABLED;
958 } else {
959 infoPtr->dwStyle |= WS_DISABLED;
960 UPDOWN_CancelMode (infoPtr);
962 InvalidateRect (infoPtr->Self, NULL, FALSE);
963 break;
965 case WM_STYLECHANGED:
966 if (wParam == GWL_STYLE) {
967 infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
968 InvalidateRect (infoPtr->Self, NULL, FALSE);
970 break;
972 case WM_THEMECHANGED:
973 theme = GetWindowTheme (hwnd);
974 CloseThemeData (theme);
975 OpenThemeData (hwnd, themeClass);
976 InvalidateRect (hwnd, NULL, FALSE);
977 break;
979 case WM_TIMER:
980 /* is this the auto-press timer? */
981 if(wParam == TIMER_AUTOPRESS) {
982 KillTimer(hwnd, TIMER_AUTOPRESS);
983 infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW);
984 InvalidateRect(infoPtr->Self, NULL, FALSE);
987 /* if initial timer, kill it and start the repeat timer */
988 if(wParam == TIMER_AUTOREPEAT) {
989 INT delay;
991 KillTimer(hwnd, TIMER_AUTOREPEAT);
992 /* if no accel info given, used default timer */
993 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) {
994 infoPtr->AccelIndex = -1;
995 delay = REPEAT_DELAY;
996 } else {
997 infoPtr->AccelIndex = 0; /* otherwise, use it */
998 delay = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1000 SetTimer(hwnd, TIMER_ACCEL, delay, 0);
1003 /* now, if the mouse is above us, do the thing...*/
1004 if(infoPtr->Flags & FLAG_MOUSEIN) {
1005 int temp;
1007 temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
1008 UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
1010 if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
1011 KillTimer(hwnd, TIMER_ACCEL);
1012 infoPtr->AccelIndex++; /* move to the next accel info */
1013 temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1014 /* make sure we have at least 1ms intervals */
1015 SetTimer(hwnd, TIMER_ACCEL, temp, 0);
1018 break;
1020 case WM_CANCELMODE:
1021 return UPDOWN_CancelMode (infoPtr);
1023 case WM_LBUTTONUP:
1024 if (GetCapture() != infoPtr->Self) break;
1026 if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
1027 (infoPtr->Flags & FLAG_ARROW) ) {
1029 SendMessageW( infoPtr->Notify,
1030 (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
1031 MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
1032 (LPARAM)hwnd);
1033 if (UPDOWN_IsBuddyEdit(infoPtr))
1034 SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
1036 UPDOWN_CancelMode(infoPtr);
1037 break;
1039 case WM_LBUTTONDOWN:
1040 case WM_MOUSEMOVE:
1041 case WM_MOUSELEAVE:
1042 if(UPDOWN_IsEnabled(infoPtr))
1043 UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
1044 break;
1046 case WM_MOUSEWHEEL:
1047 UPDOWN_MouseWheel(infoPtr, wParam);
1048 break;
1050 case WM_KEYDOWN:
1051 if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
1052 return UPDOWN_KeyPressed(infoPtr, (int)wParam);
1053 break;
1055 case WM_PRINTCLIENT:
1056 case WM_PAINT:
1057 return UPDOWN_Paint (infoPtr, (HDC)wParam);
1059 case UDM_GETACCEL:
1060 if (wParam==0 && lParam==0) return infoPtr->AccelCount;
1061 if (wParam && lParam) {
1062 int temp = min(infoPtr->AccelCount, wParam);
1063 memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL));
1064 return temp;
1066 return 0;
1068 case UDM_SETACCEL:
1070 TRACE("UDM_SETACCEL\n");
1072 if(infoPtr->AccelVect) {
1073 Free (infoPtr->AccelVect);
1074 infoPtr->AccelCount = 0;
1075 infoPtr->AccelVect = 0;
1077 if(wParam==0) return TRUE;
1078 infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL));
1079 if(infoPtr->AccelVect == 0) return FALSE;
1080 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
1081 infoPtr->AccelCount = wParam;
1083 if (TRACE_ON(updown))
1085 UINT i;
1087 for (i = 0; i < wParam; i++)
1088 TRACE("%u: nSec %u nInc %u\n", i,
1089 infoPtr->AccelVect[i].nSec, infoPtr->AccelVect[i].nInc);
1092 return TRUE;
1094 case UDM_GETBASE:
1095 return infoPtr->Base;
1097 case UDM_SETBASE:
1098 TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd);
1099 if (wParam==10 || wParam==16) {
1100 WPARAM old_base = infoPtr->Base;
1101 infoPtr->Base = wParam;
1103 if (old_base != infoPtr->Base)
1104 UPDOWN_SetBuddyInt(infoPtr);
1106 return old_base;
1108 break;
1110 case UDM_GETBUDDY:
1111 return (LRESULT)infoPtr->Buddy;
1113 case UDM_SETBUDDY:
1114 return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
1116 case UDM_GETPOS:
1118 BOOL err;
1119 int pos;
1121 pos = UPDOWN_GetPos(infoPtr, &err);
1122 return MAKELONG(pos, err);
1124 case UDM_SETPOS:
1126 return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam));
1128 case UDM_GETRANGE:
1129 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
1131 case UDM_SETRANGE:
1132 /* we must have:
1133 UD_MINVAL <= Max <= UD_MAXVAL
1134 UD_MINVAL <= Min <= UD_MAXVAL
1135 |Max-Min| <= UD_MAXVAL */
1136 UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
1137 break;
1139 case UDM_GETRANGE32:
1140 if (wParam) *(LPINT)wParam = infoPtr->MinVal;
1141 if (lParam) *(LPINT)lParam = infoPtr->MaxVal;
1142 break;
1144 case UDM_SETRANGE32:
1145 UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
1146 break;
1148 case UDM_GETPOS32:
1150 return UPDOWN_GetPos(infoPtr, (BOOL*)lParam);
1152 case UDM_SETPOS32:
1154 return UPDOWN_SetPos(infoPtr, (int)lParam);
1156 case UDM_GETUNICODEFORMAT:
1157 /* we lie a bit here, we're always using Unicode internally */
1158 return infoPtr->UnicodeFormat;
1160 case UDM_SETUNICODEFORMAT:
1162 /* do we really need to honour this flag? */
1163 int temp = infoPtr->UnicodeFormat;
1164 infoPtr->UnicodeFormat = (BOOL)wParam;
1165 return temp;
1167 default:
1168 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
1169 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam);
1170 return DefWindowProcW (hwnd, message, wParam, lParam);
1173 return 0;
1176 /***********************************************************************
1177 * UPDOWN_Register [Internal]
1179 * Registers the updown window class.
1181 void UPDOWN_Register(void)
1183 WNDCLASSW wndClass;
1185 ZeroMemory( &wndClass, sizeof( WNDCLASSW ) );
1186 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1187 wndClass.lpfnWndProc = UpDownWindowProc;
1188 wndClass.cbClsExtra = 0;
1189 wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
1190 wndClass.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
1191 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1192 wndClass.lpszClassName = UPDOWN_CLASSW;
1194 RegisterClassW( &wndClass );
1198 /***********************************************************************
1199 * UPDOWN_Unregister [Internal]
1201 * Unregisters the updown window class.
1203 void UPDOWN_Unregister (void)
1205 UnregisterClassW (UPDOWN_CLASSW, NULL);