1 /*
2 * Updown control
3 *
4 * Copyright 1997, 2002 Dimitrie O. Paun
5 *
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.
10 *
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.
15 *
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
19 *
20 * NOTE
21 *
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.
24 *
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.
28 *
29 */
30
31 #include <stdlib.h>
32 #include <string.h>
33 #include <stdarg.h>
34 #include <stdio.h>
35
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 "tmschema.h"
45 #include "wine/unicode.h"
46 #include "wine/debug.h"
47
48 WINE_DEFAULT_DEBUG_CHANNEL(updown);
49
50 typedef struct
51 {
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;
67
68 /* Control configuration constants */
69
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 */
73
74 #define DEFAULT_WIDTH 14 /* 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 */
82
83 /* Work constants */
84
85 #define FLAG_INCR 0x01
86 #define FLAG_DECR 0x02
87 #define FLAG_MOUSEIN 0x04
88 #define FLAG_PRESSED 0x08
89 #define FLAG_ARROW (FLAG_INCR | FLAG_DECR)
90
91 #define BUDDY_TYPE_UNKNOWN 0
92 #define BUDDY_TYPE_LISTBOX 1
93 #define BUDDY_TYPE_EDIT 2
94
95 #define TIMER_AUTOREPEAT 1
96 #define TIMER_ACCEL 2
97 #define TIMER_AUTOPRESS 3
98
99 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))
100 #define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
101
102 static const WCHAR BUDDY_UPDOWN_HWND[] = { 'b', 'u', 'd', 'd', 'y', 'U', 'p', 'D', 'o', 'w', 'n', 'H', 'W', 'N', 'D', 0 };
103 static const WCHAR BUDDY_SUPERCLASS_WNDPROC[] = { 'b', 'u', 'd', 'd', 'y', 'S', 'u', 'p', 'p', 'e', 'r',
104 'C', 'l', 'a', 's', 's', 'W', 'n', 'd', 'P', 'r', 'o', 'c', 0 };
105 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action);
106
107 /***********************************************************************
108 * UPDOWN_IsBuddyEdit
109 * Tests if our buddy is an edit control.
110 */
111 static inline BOOL UPDOWN_IsBuddyEdit(const UPDOWN_INFO *infoPtr)
112 {
113 return infoPtr->BuddyType == BUDDY_TYPE_EDIT;
114 }
115
116 /***********************************************************************
117 * UPDOWN_IsBuddyListbox
118 * Tests if our buddy is a listbox control.
119 */
120 static inline BOOL UPDOWN_IsBuddyListbox(const UPDOWN_INFO *infoPtr)
121 {
122 return infoPtr->BuddyType == BUDDY_TYPE_LISTBOX;
123 }
124
125 /***********************************************************************
126 * UPDOWN_InBounds
127 * Tests if a given value 'val' is between the Min&Max limits
128 */
129 static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
130 {
131 if(infoPtr->MaxVal > infoPtr->MinVal)
132 return (infoPtr->MinVal <= val) && (val <= infoPtr->MaxVal);
133 else
134 return (infoPtr->MaxVal <= val) && (val <= infoPtr->MinVal);
135 }
136
137 /***********************************************************************
138 * UPDOWN_OffsetVal
139 * Change the current value by delta.
140 * It returns TRUE is the value was changed successfully, or FALSE
141 * if the value was not changed, as it would go out of bounds.
142 */
143 static BOOL UPDOWN_OffsetVal(UPDOWN_INFO *infoPtr, int delta)
144 {
145 /* check if we can do the modification first */
146 if(!UPDOWN_InBounds (infoPtr, infoPtr->CurVal+delta)) {
147 if (infoPtr->dwStyle & UDS_WRAP) {
148 delta += (delta < 0 ? -1 : 1) *
149 (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) *
150 (infoPtr->MinVal - infoPtr->MaxVal) +
151 (delta < 0 ? 1 : -1);
152 } else return FALSE;
153 }
154
155 infoPtr->CurVal += delta;
156 return TRUE;
157 }
158
159 /***********************************************************************
160 * UPDOWN_HasBuddyBorder
161 *
162 * When we have a buddy set and that we are aligned on our buddy, we
163 * want to draw a sunken edge to make like we are part of that control.
164 */
165 static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr)
166 {
167 return ( ((infoPtr->dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) &&
168 UPDOWN_IsBuddyEdit(infoPtr) );
169 }
170
171 /***********************************************************************
172 * UPDOWN_GetArrowRect
173 * wndPtr - pointer to the up-down wnd
174 * rect - will hold the rectangle
175 * arrow - FLAG_INCR to get the "increment" rect (up or right)
176 * FLAG_DECR to get the "decrement" rect (down or left)
177 * If both flags are present, the envelope is returned.
178 */
179 static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, int arrow)
180 {
181 HTHEME theme = GetWindowTheme (infoPtr->Self);
182 const int border = theme ? DEFAULT_BUDDYBORDER_THEMED : DEFAULT_BUDDYBORDER;
183 const int spacer = theme ? DEFAULT_BUDDYSPACER_THEMED : DEFAULT_BUDDYSPACER;
184 GetClientRect (infoPtr->Self, rect);
185
186 /*
187 * Make sure we calculate the rectangle to fit even if we draw the
188 * border.
189 */
190 if (UPDOWN_HasBuddyBorder(infoPtr)) {
191 if (infoPtr->dwStyle & UDS_ALIGNLEFT)
192 rect->left += border;
193 else
194 rect->right -= border;
195
196 InflateRect(rect, 0, -border);
197 }
198
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 rect->left += spacer;
203 }
204
205 /*
206 * We're calculating the midpoint to figure-out where the
207 * separation between the buttons will lay. We make sure that we
208 * round the uneven numbers by adding 1.
209 */
210 if (infoPtr->dwStyle & UDS_HORZ) {
211 int len = rect->right - rect->left + 1; /* compute the width */
212 if (arrow & FLAG_INCR)
213 rect->left = rect->left + len/2;
214 if (arrow & FLAG_DECR)
215 rect->right = rect->left + len/2 - (theme ? 0 : 1);
216 } else {
217 int len = rect->bottom - rect->top + 1; /* compute the height */
218 if (arrow & FLAG_INCR)
219 rect->bottom = rect->top + len/2 - (theme ? 0 : 1);
220 if (arrow & FLAG_DECR)
221 rect->top = rect->top + len/2;
222 }
223 }
224
225 /***********************************************************************
226 * UPDOWN_GetArrowFromPoint
227 * Returns the rectagle (for the up or down arrow) that contains pt.
228 * If it returns the up rect, it returns FLAG_INCR.
229 * If it returns the down rect, it returns FLAG_DECR.
230 */
231 static INT UPDOWN_GetArrowFromPoint (const UPDOWN_INFO *infoPtr, RECT *rect, POINT pt)
232 {
233 UPDOWN_GetArrowRect (infoPtr, rect, FLAG_INCR);
234 if(PtInRect(rect, pt)) return FLAG_INCR;
235
236 UPDOWN_GetArrowRect (infoPtr, rect, FLAG_DECR);
237 if(PtInRect(rect, pt)) return FLAG_DECR;
238
239 return 0;
240 }
241
242
243 /***********************************************************************
244 * UPDOWN_GetThousandSep
245 * Returns the thousand sep. If an error occurs, it returns ','.
246 */
247 static WCHAR UPDOWN_GetThousandSep(void)
248 {
249 WCHAR sep[2];
250
251 if(GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, sep, 2) != 1)
252 sep[0] = ',';
253
254 return sep[0];
255 }
256
257 /***********************************************************************
258 * UPDOWN_GetBuddyInt
259 * Tries to read the pos from the buddy window and if it succeeds,
260 * it stores it in the control's CurVal
261 * returns:
262 * TRUE - if it read the integer from the buddy successfully
263 * FALSE - if an error occurred
264 */
265 static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
266 {
267 WCHAR txt[20], sep, *src, *dst;
268 int newVal;
269
270 if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy)))
271 return FALSE;
272
273 /*if the buddy is a list window, we must set curr index */
274 if (UPDOWN_IsBuddyListbox(infoPtr)) {
275 newVal = SendMessageW(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);
276 if(newVal < 0) return FALSE;
277 } else {
278 /* we have a regular window, so will get the text */
279 /* note that a zero-length string is a legitimate value for 'txt',
280 * and ought to result in a successful conversion to ''. */
281 if (GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt)) < 0)
282 return FALSE;
283
284 sep = UPDOWN_GetThousandSep();
285
286 /* now get rid of the separators */
287 for(src = dst = txt; *src; src++)
288 if(*src != sep) *dst++ = *src;
289 *dst = 0;
290
291 /* try to convert the number and validate it */
292 newVal = strtolW(txt, &src, infoPtr->Base);
293 if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
294 }
295
296 TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
297 infoPtr->CurVal = newVal;
298 return TRUE;
299 }
300
301
302 /***********************************************************************
303 * UPDOWN_SetBuddyInt
304 * Tries to set the pos to the buddy window based on current pos
305 * returns:
306 * TRUE - if it set the caption of the buddy successfully
307 * FALSE - if an error occurred
308 */
309 static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
310 {
311 WCHAR fmt[3] = { '%', 'd', '\0' };
312 WCHAR txt[20];
313 int len;
314
315 if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy)))
316 return FALSE;
317
318 TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal);
319
320 /*if the buddy is a list window, we must set curr index */
321 if (UPDOWN_IsBuddyListbox(infoPtr)) {
322 return SendMessageW(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0) != LB_ERR;
323 }
324
325 /* Regular window, so set caption to the number */
326 if (infoPtr->Base == 16) fmt[1] = 'X';
327 len = wsprintfW(txt, fmt, infoPtr->CurVal);
328
329
330 /* Do thousands separation if necessary */
331 if (!(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) {
332 WCHAR tmp[COUNT_OF(txt)], *src = tmp, *dst = txt;
333 WCHAR sep = UPDOWN_GetThousandSep();
334 int start = len % 3;
335
336 memcpy(tmp, txt, sizeof(txt));
337 if (start == 0) start = 3;
338 dst += start;
339 src += start;
340 for (len=0; *src; len++) {
341 if (len % 3 == 0) *dst++ = sep;
342 *dst++ = *src++;
343 }
344 *dst = 0;
345 }
346
347 return SetWindowTextW(infoPtr->Buddy, txt);
348 }
349
350 /***********************************************************************
351 * UPDOWN_DrawBuddyBackground
352 *
353 * Draw buddy background for visual integration.
354 */
355 static BOOL UPDOWN_DrawBuddyBackground (const UPDOWN_INFO *infoPtr, HDC hdc)
356 {
357 RECT br;
358 HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy);
359 if (!buddyTheme) return FALSE;
360
361 GetClientRect (infoPtr->Buddy, &br);
362 MapWindowPoints (infoPtr->Buddy, infoPtr->Self, (POINT*)&br, 2);
363 /* FIXME: take disabled etc. into account */
364 DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL);
365 return TRUE;
366 }
367
368 /***********************************************************************
369 * UPDOWN_Draw
370 *
371 * Draw the arrows. The background need not be erased.
372 */
373 static LRESULT UPDOWN_Draw (const UPDOWN_INFO *infoPtr, HDC hdc)
374 {
375 BOOL uPressed, uHot, dPressed, dHot;
376 RECT rect;
377 HTHEME theme = GetWindowTheme (infoPtr->Self);
378 int uPart = 0, uState = 0, dPart = 0, dState = 0;
379 BOOL needBuddyBg = FALSE;
380
381 uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR);
382 uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
383 dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR);
384 dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
385 if (theme) {
386 uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP;
387 uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
388 : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL));
389 dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN;
390 dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
391 : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL));
392 needBuddyBg = IsWindow (infoPtr->Buddy)
393 && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState)
394 || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState));
395 }
396
397 /* Draw the common border between ourselves and our buddy */
398 if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) {
399 if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) {
400 GetClientRect(infoPtr->Self, &rect);
401 DrawEdge(hdc, &rect, EDGE_SUNKEN,
402 BF_BOTTOM | BF_TOP |
403 (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT));
404 }
405 }
406
407 /* Draw the incr button */
408 UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR);
409 if (theme) {
410 DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL);
411 } else {
412 DrawFrameControl(hdc, &rect, DFC_SCROLL,
413 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) |
414 ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) |
415 (uPressed ? DFCS_PUSHED : 0) |
416 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
417 }
418
419 /* Draw the decr button */
420 UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR);
421 if (theme) {
422 DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL);
423 } else {
424 DrawFrameControl(hdc, &rect, DFC_SCROLL,
425 (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) |
426 ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) |
427 (dPressed ? DFCS_PUSHED : 0) |
428 (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
429 }
430
431 return 0;
432 }
433
434 /***********************************************************************
435 * UPDOWN_Paint
436 *
437 * Asynchronous drawing (must ONLY be used in WM_PAINT).
438 * Calls UPDOWN_Draw.
439 */
440 static LRESULT UPDOWN_Paint (const UPDOWN_INFO *infoPtr, HDC hdc)
441 {
442 PAINTSTRUCT ps;
443 if (hdc) return UPDOWN_Draw (infoPtr, hdc);
444 hdc = BeginPaint (infoPtr->Self, &ps);
445 UPDOWN_Draw (infoPtr, hdc);
446 EndPaint (infoPtr->Self, &ps);
447 return 0;
448 }
449
450 /***********************************************************************
451 * UPDOWN_KeyPressed
452 *
453 * Handle key presses (up & down) when we have to do so
454 */
455 static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
456 {
457 int arrow;
458
459 if (key == VK_UP) arrow = FLAG_INCR;
460 else if (key == VK_DOWN) arrow = FLAG_DECR;
461 else return 1;
462
463 UPDOWN_GetBuddyInt (infoPtr);
464 infoPtr->Flags &= ~FLAG_ARROW;
465 infoPtr->Flags |= FLAG_PRESSED | arrow;
466 InvalidateRect (infoPtr->Self, NULL, FALSE);
467 SetTimer(infoPtr->Self, TIMER_AUTOPRESS, AUTOPRESS_DELAY, 0);
468 UPDOWN_DoAction (infoPtr, 1, arrow);
469 return 0;
470 }
471
472 /***********************************************************************
473 * UPDOWN_SetRange
474 *
475 * Handle UDM_SETRANGE, UDM_SETRANGE32
476 *
477 * FIXME: handle Max == Min properly:
478 * - arrows should be disabled (without WS_DISABLED set),
479 * visually they can't be pressed and don't respond;
480 * - all input messages should still pass in.
481 */
482 static LRESULT UPDOWN_SetRange(UPDOWN_INFO *infoPtr, INT Max, INT Min)
483 {
484 infoPtr->MaxVal = Max;
485 infoPtr->MinVal = Min;
486
487 TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
488 infoPtr->MinVal, infoPtr->MaxVal, infoPtr->Self);
489
490 return 0;
491 }
492
493 /***********************************************************************
494 * UPDOWN_MouseWheel
495 *
496 * Handle mouse wheel scrolling
497 */
498 static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
499 {
500 int iWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
501
502 if (wParam & (MK_SHIFT | MK_CONTROL))
503 return 0;
504
505 if (iWheelDelta != 0)
506 {
507 UPDOWN_GetBuddyInt(infoPtr);
508 UPDOWN_DoAction(infoPtr, abs(iWheelDelta), iWheelDelta > 0 ? FLAG_INCR : FLAG_DECR);
509 }
510
511 return 1;
512 }
513
514
515 /***********************************************************************
516 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
517 * control.
518 */
519 static LRESULT CALLBACK
520 UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
521 {
522 WNDPROC superClassWndProc = (WNDPROC)GetPropW(hwnd, BUDDY_SUPERCLASS_WNDPROC);
523
524 TRACE("hwnd=%p, wndProc=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
525 hwnd, superClassWndProc, uMsg, wParam, lParam);
526
527 if (uMsg == WM_KEYDOWN) {
528 HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND);
529
530 UPDOWN_KeyPressed(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam);
531 if ((wParam == VK_UP) || (wParam == VK_DOWN)) return 0;
532 }
533 else if (uMsg == WM_MOUSEWHEEL) {
534 HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND);
535
536 UPDOWN_MouseWheel(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam);
537 }
538
539 return CallWindowProcW( superClassWndProc, hwnd, uMsg, wParam, lParam);
540 }
541
542 /***********************************************************************
543 * UPDOWN_SetBuddy
544 *
545 * Sets bud as a new Buddy.
546 * Then, it should subclass the buddy
547 * If window has the UDS_ARROWKEYS, it subcalsses the buddy window to
548 * process the UP/DOWN arrow keys.
549 * If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style
550 * the size/pos of the buddy and the control are adjusted accordingly.
551 */
552 static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
553 {
554 static const WCHAR editW[] = { 'E', 'd', 'i', 't', 0 };
555 static const WCHAR listboxW[] = { 'L', 'i', 's', 't', 'b', 'o', 'x', 0 };
556 RECT budRect; /* new coord for the buddy */
557 int x, width; /* new x position and width for the up-down */
558 WNDPROC baseWndProc;
559 WCHAR buddyClass[40];
560 HWND ret;
561
562 TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
563
564 ret = infoPtr->Buddy;
565
566 /* there is already a body assigned */
567 if (infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
568
569 if(!IsWindow(bud))
570 bud = 0;
571
572 /* Store buddy window handle */
573 infoPtr->Buddy = bud;
574
575 if(bud) {
576
577 /* keep upDown ctrl hwnd in a buddy property */
578 SetPropW( bud, BUDDY_UPDOWN_HWND, infoPtr->Self);
579
580 /* Store buddy window class type */
581 infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
582 if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) {
583 if (lstrcmpiW(buddyClass, editW) == 0)
584 infoPtr->BuddyType = BUDDY_TYPE_EDIT;
585 else if (lstrcmpiW(buddyClass, listboxW) == 0)
586 infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
587 }
588
589 if(infoPtr->dwStyle & UDS_ARROWKEYS){
590 /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
591 when we reset the upDown ctrl buddy to another buddy because it is not
592 good to break the window proc chain. */
593 if (!GetPropW(bud, BUDDY_SUPERCLASS_WNDPROC)) {
594 baseWndProc = (WNDPROC)SetWindowLongPtrW(bud, GWLP_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc);
595 SetPropW(bud, BUDDY_SUPERCLASS_WNDPROC, baseWndProc);
596 }
597 }
598
599 /* Get the rect of the buddy relative to its parent */
600 GetWindowRect(infoPtr->Buddy, &budRect);
601 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2);
602
603 /* now do the positioning */
604 if (infoPtr->dwStyle & UDS_ALIGNLEFT) {
605 x = budRect.left;
606 budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP;
607 } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) {
608 budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
609 x = budRect.right+DEFAULT_XSEP;
610 } else {
611 /* nothing to do */
612 return ret;
613 }
614
615 /* first adjust the buddy to accommodate the up/down */
616 SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
617 budRect.right - budRect.left, budRect.bottom - budRect.top,
618 SWP_NOACTIVATE|SWP_NOZORDER);
619
620 /* now position the up/down */
621 /* Since the UDS_ALIGN* flags were used, */
622 /* we will pick the position and size of the window. */
623 width = DEFAULT_WIDTH;
624
625 /*
626 * If the updown has a buddy border, it has to overlap with the buddy
627 * to look as if it is integrated with the buddy control.
628 * We nudge the control or change its size to overlap.
629 */
630 if (UPDOWN_HasBuddyBorder(infoPtr)) {
631 if(infoPtr->dwStyle & UDS_ALIGNLEFT)
632 width += DEFAULT_BUDDYBORDER;
633 else
634 x -= DEFAULT_BUDDYBORDER;
635 }
636
637 SetWindowPos(infoPtr->Self, 0, x,
638 budRect.top - DEFAULT_ADDTOP, width,
639 budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
640 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
641 } else {
642 RECT rect;
643 GetWindowRect(infoPtr->Self, &rect);
644 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
645 SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
646 SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
647 }
648 return ret;
649 }
650
651 /***********************************************************************
652 * UPDOWN_DoAction
653 *
654 * This function increments/decrements the CurVal by the
655 * 'delta' amount according to the 'action' flag which can be a
656 * combination of FLAG_INCR and FLAG_DECR
657 * It notifies the parent as required.
658 * It handles wraping and non-wraping correctly.
659 * It is assumed that delta>0
660 */
661 static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action)
662 {
663 NM_UPDOWN ni;
664
665 TRACE("%d by %d\n", action, delta);
666
667 /* check if we can do the modification first */
668 delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
669 if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
670
671 TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
672
673 /* We must notify parent now to obtain permission */
674 ni.iPos = infoPtr->CurVal;
675 ni.iDelta = delta;
676 ni.hdr.hwndFrom = infoPtr->Self;
677 ni.hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
678 ni.hdr.code = UDN_DELTAPOS;
679 if (!SendMessageW(infoPtr->Notify, WM_NOTIFY, ni.hdr.idFrom, (LPARAM)&ni)) {
680 /* Parent said: OK to adjust */
681
682 /* Now adjust value with (maybe new) delta */
683 if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
684 TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
685
686 /* Now take care about our buddy */
687 UPDOWN_SetBuddyInt (infoPtr);
688 }
689 }
690
691 /* Also, notify it. This message is sent in any case. */
692 SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
693 MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self);
694 }
695
696 /***********************************************************************
697 * UPDOWN_IsEnabled
698 *
699 * Returns TRUE if it is enabled as well as its buddy (if any)
700 * FALSE otherwise
701 */
702 static BOOL UPDOWN_IsEnabled (const UPDOWN_INFO *infoPtr)
703 {
704 if (!IsWindowEnabled(infoPtr->Self))
705 return FALSE;
706 if(infoPtr->Buddy)
707 return IsWindowEnabled(infoPtr->Buddy);
708 return TRUE;
709 }
710
711 /***********************************************************************
712 * UPDOWN_CancelMode
713 *
714 * Deletes any timers, releases the mouse and does redraw if necessary.
715 * If the control is not in "capture" mode, it does nothing.
716 * If the control was not in cancel mode, it returns FALSE.
717 * If the control was in cancel mode, it returns TRUE.
718 */
719 static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr)
720 {
721 if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
722
723 KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
724 KillTimer (infoPtr->Self, TIMER_ACCEL);
725 KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
726
727 if (GetCapture() == infoPtr->Self) {
728 NMHDR hdr;
729 hdr.hwndFrom = infoPtr->Self;
730 hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
731 hdr.code = NM_RELEASEDCAPTURE;
732 SendMessageW(infoPtr->Notify, WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);
733 ReleaseCapture();
734 }
735
736 infoPtr->Flags &= ~FLAG_PRESSED;
737 InvalidateRect (infoPtr->Self, NULL, FALSE);
738
739 return TRUE;
740 }
741
742 /***********************************************************************
743 * UPDOWN_HandleMouseEvent
744 *
745 * Handle a mouse event for the updown.
746 * 'pt' is the location of the mouse event in client or
747 * windows coordinates.
748 */
749 static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
750 {
751 POINT pt = { x, y };
752 RECT rect;
753 int temp, arrow;
754 TRACKMOUSEEVENT tme;
755
756 TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
757
758 switch(msg)
759 {
760 case WM_LBUTTONDOWN: /* Initialise mouse tracking */
761
762 /* If the buddy is an edit, will set focus to it */
763 if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
764
765 /* Now see which one is the 'active' arrow */
766 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
767
768 /* Update the flags if we are in/out */
769 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
770 if (arrow)
771 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
772 else
773 if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
774
775 if (infoPtr->Flags & FLAG_ARROW) {
776
777 /* Update the CurVal if necessary */
778 UPDOWN_GetBuddyInt (infoPtr);
779
780 /* Set up the correct flags */
781 infoPtr->Flags |= FLAG_PRESSED;
782
783 /* repaint the control */
784 InvalidateRect (infoPtr->Self, NULL, FALSE);
785
786 /* process the click */
787 temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
788 UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
789
790 /* now capture all mouse messages */
791 SetCapture (infoPtr->Self);
792
793 /* and startup the first timer */
794 SetTimer(infoPtr->Self, TIMER_AUTOREPEAT, INITIAL_DELAY, 0);
795 }
796 break;
797
798 case WM_MOUSEMOVE:
799 /* save the flags to see if any got modified */
800 temp = infoPtr->Flags;
801
802 /* Now see which one is the 'active' arrow */
803 arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
804
805 /* Update the flags if we are in/out */
806 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
807 if(arrow) {
808 infoPtr->Flags |= FLAG_MOUSEIN | arrow;
809 } else {
810 if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
811 }
812
813 /* If state changed, redraw the control */
814 if(temp != infoPtr->Flags)
815 InvalidateRect (infoPtr->Self, NULL, FALSE);
816
817 /* Set up tracking so the mousein flags can be reset when the
818 * mouse leaves the control */
819 tme.cbSize = sizeof( tme );
820 tme.dwFlags = TME_LEAVE;
821 tme.hwndTrack = infoPtr->Self;
822 TrackMouseEvent (&tme);
823
824 break;
825 case WM_MOUSELEAVE:
826 infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
827 InvalidateRect (infoPtr->Self, NULL, FALSE);
828 break;
829
830 default:
831 ERR("Impossible case (msg=%x)!\n", msg);
832 }
833
834 }
835
836 /***********************************************************************
837 * UpDownWndProc
838 */
839 static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
840 {
841 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
842 static const WCHAR themeClass[] = {'S','p','i','n',0};
843 HTHEME theme;
844
845 TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam);
846
847 if (!infoPtr && (message != WM_CREATE))
848 return DefWindowProcW (hwnd, message, wParam, lParam);
849
850 switch(message)
851 {
852 case WM_CREATE:
853 infoPtr = Alloc (sizeof(UPDOWN_INFO));
854 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
855
856 /* initialize the info struct */
857 infoPtr->Self = hwnd;
858 infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent;
859 infoPtr->dwStyle = ((LPCREATESTRUCTW)lParam)->style;
860 infoPtr->AccelCount = 0;
861 infoPtr->AccelVect = 0;
862 infoPtr->AccelIndex = -1;
863 infoPtr->CurVal = 0;
864 infoPtr->MinVal = 100;
865 infoPtr->MaxVal = 0;
866 infoPtr->Base = 10; /* Default to base 10 */
867 infoPtr->Buddy = 0; /* No buddy window yet */
868 infoPtr->Flags = 0; /* And no flags */
869
870 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
871
872 /* Do we pick the buddy win ourselves? */
873 if (infoPtr->dwStyle & UDS_AUTOBUDDY)
874 UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV));
875
876 OpenThemeData (hwnd, themeClass);
877
878 TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
879 break;
880
881 case WM_DESTROY:
882 Free (infoPtr->AccelVect);
883
884 if(infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
885
886 Free (infoPtr);
887 SetWindowLongPtrW (hwnd, 0, 0);
888 theme = GetWindowTheme (hwnd);
889 CloseThemeData (theme);
890 TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
891 break;
892
893 case WM_ENABLE:
894 if (wParam) {
895 infoPtr->dwStyle &= ~WS_DISABLED;
896 } else {
897 infoPtr->dwStyle |= WS_DISABLED;
898 UPDOWN_CancelMode (infoPtr);
899 }
900 InvalidateRect (infoPtr->Self, NULL, FALSE);
901 break;
902
903 case WM_STYLECHANGED:
904 if (wParam == GWL_STYLE) {
905 infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
906 InvalidateRect (infoPtr->Self, NULL, FALSE);
907 }
908 break;
909
910 case WM_THEMECHANGED:
911 theme = GetWindowTheme (hwnd);
912 CloseThemeData (theme);
913 OpenThemeData (hwnd, themeClass);
914 InvalidateRect (hwnd, NULL, FALSE);
915 break;
916
917 case WM_TIMER:
918 /* is this the auto-press timer? */
919 if(wParam == TIMER_AUTOPRESS) {
920 KillTimer(hwnd, TIMER_AUTOPRESS);
921 infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW);
922 InvalidateRect(infoPtr->Self, NULL, FALSE);
923 }
924
925 /* if initial timer, kill it and start the repeat timer */
926 if(wParam == TIMER_AUTOREPEAT) {
927 int temp;
928
929 KillTimer(hwnd, TIMER_AUTOREPEAT);
930 /* if no accel info given, used default timer */
931 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) {
932 infoPtr->AccelIndex = -1;
933 temp = REPEAT_DELAY;
934 } else {
935 infoPtr->AccelIndex = 0; /* otherwise, use it */
936 temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
937 }
938 SetTimer(hwnd, TIMER_ACCEL, temp, 0);
939 }
940
941 /* now, if the mouse is above us, do the thing...*/
942 if(infoPtr->Flags & FLAG_MOUSEIN) {
943 int temp;
944
945 temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
946 UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
947
948 if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
949 KillTimer(hwnd, TIMER_ACCEL);
950 infoPtr->AccelIndex++; /* move to the next accel info */
951 temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
952 /* make sure we have at least 1ms intervals */
953 SetTimer(hwnd, TIMER_ACCEL, temp, 0);
954 }
955 }
956 break;
957
958 case WM_CANCELMODE:
959 return UPDOWN_CancelMode (infoPtr);
960
961 case WM_LBUTTONUP:
962 if (GetCapture() != infoPtr->Self) break;
963
964 if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
965 (infoPtr->Flags & FLAG_ARROW) ) {
966
967 SendMessageW( infoPtr->Notify,
968 (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
969 MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
970 (LPARAM)hwnd);
971 if (UPDOWN_IsBuddyEdit(infoPtr))
972 SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
973 }
974 UPDOWN_CancelMode(infoPtr);
975 break;
976
977 case WM_LBUTTONDOWN:
978 case WM_MOUSEMOVE:
979 case WM_MOUSELEAVE:
980 if(UPDOWN_IsEnabled(infoPtr))
981 UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
982 break;
983
984 case WM_MOUSEWHEEL:
985 UPDOWN_MouseWheel(infoPtr, wParam);
986 break;
987
988 case WM_KEYDOWN:
989 if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
990 return UPDOWN_KeyPressed(infoPtr, (int)wParam);
991 break;
992
993 case WM_PRINTCLIENT:
994 case WM_PAINT:
995 return UPDOWN_Paint (infoPtr, (HDC)wParam);
996
997 case UDM_GETACCEL:
998 if (wParam==0 && lParam==0) return infoPtr->AccelCount;
999 if (wParam && lParam) {
1000 int temp = min(infoPtr->AccelCount, wParam);
1001 memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL));
1002 return temp;
1003 }
1004 return 0;
1005
1006 case UDM_SETACCEL:
1007 {
1008 unsigned temp;
1009
1010 TRACE("UDM_SETACCEL\n");
1011
1012 if(infoPtr->AccelVect) {
1013 Free (infoPtr->AccelVect);
1014 infoPtr->AccelCount = 0;
1015 infoPtr->AccelVect = 0;
1016 }
1017 if(wParam==0) return TRUE;
1018 infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL));
1019 if(infoPtr->AccelVect == 0) return FALSE;
1020 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
1021 infoPtr->AccelCount = wParam;
1022
1023 for (temp = 0; temp < wParam; temp++)
1024 TRACE("%d: nSec %u nInc %u\n", temp, infoPtr->AccelVect[temp].nSec, infoPtr->AccelVect[temp].nInc);
1025
1026 return TRUE;
1027 }
1028 case UDM_GETBASE:
1029 return infoPtr->Base;
1030
1031 case UDM_SETBASE:
1032 TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd);
1033 if (wParam==10 || wParam==16) {
1034 WPARAM temp = infoPtr->Base;
1035 infoPtr->Base = wParam;
1036 return temp;
1037 }
1038 break;
1039
1040 case UDM_GETBUDDY:
1041 return (LRESULT)infoPtr->Buddy;
1042
1043 case UDM_SETBUDDY:
1044 return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
1045
1046 case UDM_GETPOS:
1047 {
1048 int temp = UPDOWN_GetBuddyInt (infoPtr);
1049 return MAKELONG(infoPtr->CurVal, temp ? 0 : 1);
1050 }
1051 case UDM_SETPOS:
1052 {
1053 int temp = (short)LOWORD(lParam);
1054
1055 TRACE("UpDown Ctrl new value(%d), hwnd=%p\n", temp, hwnd);
1056 if(!UPDOWN_InBounds(infoPtr, temp)) {
1057 if(temp < infoPtr->MinVal) temp = infoPtr->MinVal;
1058 if(temp > infoPtr->MaxVal) temp = infoPtr->MaxVal;
1059 }
1060 wParam = infoPtr->CurVal;
1061 infoPtr->CurVal = temp;
1062 UPDOWN_SetBuddyInt (infoPtr);
1063 return wParam; /* return prev value */
1064 }
1065 case UDM_GETRANGE:
1066 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
1067
1068 case UDM_SETRANGE:
1069 /* we must have:
1070 UD_MINVAL <= Max <= UD_MAXVAL
1071 UD_MINVAL <= Min <= UD_MAXVAL
1072 |Max-Min| <= UD_MAXVAL */
1073 UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
1074 break;
1075
1076 case UDM_GETRANGE32:
1077 if (wParam) *(LPINT)wParam = infoPtr->MinVal;
1078 if (lParam) *(LPINT)lParam = infoPtr->MaxVal;
1079 break;
1080
1081 case UDM_SETRANGE32:
1082 UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
1083 break;
1084
1085 case UDM_GETPOS32:
1086 if ((LPBOOL)lParam != NULL) *((LPBOOL)lParam) = TRUE;
1087 return infoPtr->CurVal;
1088
1089 case UDM_SETPOS32:
1090 {
1091 int temp;
1092
1093 if(!UPDOWN_InBounds(infoPtr, (int)lParam)) {
1094 if((int)lParam < infoPtr->MinVal) lParam = infoPtr->MinVal;
1095 if((int)lParam > infoPtr->MaxVal) lParam = infoPtr->MaxVal;
1096 }
1097 temp = infoPtr->CurVal; /* save prev value */
1098 infoPtr->CurVal = (int)lParam; /* set the new value */
1099 UPDOWN_SetBuddyInt (infoPtr);
1100 return temp; /* return prev value */
1101 }
1102 case UDM_GETUNICODEFORMAT:
1103 /* we lie a bit here, we're always using Unicode internally */
1104 return infoPtr->UnicodeFormat;
1105
1106 case UDM_SETUNICODEFORMAT:
1107 {
1108 /* do we really need to honour this flag? */
1109 int temp = infoPtr->UnicodeFormat;
1110 infoPtr->UnicodeFormat = (BOOL)wParam;
1111 return temp;
1112 }
1113 default:
1114 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
1115 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam);
1116 return DefWindowProcW (hwnd, message, wParam, lParam);
1117 }
1118
1119 return 0;
1120 }
1121
1122 /***********************************************************************
1123 * UPDOWN_Register [Internal]
1124 *
1125 * Registers the updown window class.
1126 */
1127 void UPDOWN_Register(void)
1128 {
1129 WNDCLASSW wndClass;
1130
1131 ZeroMemory( &wndClass, sizeof( WNDCLASSW ) );
1132 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1133 wndClass.lpfnWndProc = UpDownWindowProc;
1134 wndClass.cbClsExtra = 0;
1135 wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
1136 wndClass.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
1137 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1138 wndClass.lpszClassName = UPDOWN_CLASSW;
1139
1140 RegisterClassW( &wndClass );
1141 }
1142
1143
1144 /***********************************************************************
1145 * UPDOWN_Unregister [Internal]
1146 *
1147 * Unregisters the updown window class.
1148 */
1149 void UPDOWN_Unregister (void)
1150 {
1151 UnregisterClassW (UPDOWN_CLASSW, NULL);
1152 }
1153
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.