1c2c66affSColin Finck /* Unit tests for the up-down control
2c2c66affSColin Finck  *
3c2c66affSColin Finck  * Copyright 2005 C. Scott Ananian
4c2c66affSColin Finck  * Copyright (C) 2007 James Hawkins
5c2c66affSColin Finck  * Copyright (C) 2007 Leslie Choong
6c2c66affSColin Finck  *
7c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
8c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
9c2c66affSColin Finck  * License as published by the Free Software Foundation; either
10c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
11c2c66affSColin Finck  *
12c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
13c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15c2c66affSColin Finck  * Lesser General Public License for more details.
16c2c66affSColin Finck  *
17c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
18c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
19c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20c2c66affSColin Finck  */
21c2c66affSColin Finck 
22c2c66affSColin Finck /* TO TEST:
23c2c66affSColin Finck  *   - send click messages to the up-down control, check the current position
24c2c66affSColin Finck  *   - up-down control automatically positions itself next to its buddy window
25c2c66affSColin Finck  *   - up-down control sets the caption of the buddy window
26c2c66affSColin Finck  *   - test CreateUpDownControl API
27c2c66affSColin Finck  *   - check UDS_AUTOBUDDY style, up-down control selects previous window in z-order
28c2c66affSColin Finck  *   - check UDM_SETBUDDY message
29c2c66affSColin Finck  *   - check UDM_GETBUDDY message
30c2c66affSColin Finck  *   - up-down control and buddy control must have the same parent
31c2c66affSColin Finck  *   - check UDS_ALIGN[LEFT,RIGHT]...check that width of buddy window is decreased
32c2c66affSColin Finck  *   - check that UDS_SETBUDDYINT sets the caption of the buddy window when it is changed
33c2c66affSColin Finck  *   - check that the thousands operator is set for large numbers
34c2c66affSColin Finck  *   - check that the thousands operator is not set with UDS_NOTHOUSANDS
35c2c66affSColin Finck  *   - check UDS_ARROWKEYS, control subclasses the buddy window so that it processes the keys when it has focus
36c2c66affSColin Finck  *   - check UDS_HORZ
37c2c66affSColin Finck  *   - check changing past min/max values
38c2c66affSColin Finck  *   - check UDS_WRAP wraps values past min/max, incrementing past upper value wraps position to lower value
39c2c66affSColin Finck  *   - can change control's position, min/max pos, radix
40c2c66affSColin Finck  *   - check UDM_GETPOS, for up-down control with a buddy window, position is the caption of the buddy window, so change the
41c2c66affSColin Finck  *     caption of the buddy window then call UDM_GETPOS
42c2c66affSColin Finck  *   - check UDM_SETRANGE, max can be less than min, so clicking the up arrow decreases the current position
43c2c66affSColin Finck  *   - more stuff to test
44c2c66affSColin Finck  */
45c2c66affSColin Finck 
46f37104daSAmine Khaldi #include <windows.h>
47f37104daSAmine Khaldi #include <commctrl.h>
48f37104daSAmine Khaldi #include <stdio.h>
49f37104daSAmine Khaldi 
50f37104daSAmine Khaldi #include "wine/test.h"
51f37104daSAmine Khaldi #include "msg.h"
52c2c66affSColin Finck 
53c2c66affSColin Finck #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
54c2c66affSColin Finck 
55c2c66affSColin Finck #define NUM_MSG_SEQUENCES   3
56c2c66affSColin Finck #define PARENT_SEQ_INDEX    0
57c2c66affSColin Finck #define EDIT_SEQ_INDEX      1
58c2c66affSColin Finck #define UPDOWN_SEQ_INDEX    2
59c2c66affSColin Finck 
60c2c66affSColin Finck #define UPDOWN_ID           0
61c2c66affSColin Finck #define BUDDY_ID            1
62c2c66affSColin Finck 
63c2c66affSColin Finck static HWND parent_wnd, g_edit;
64c2c66affSColin Finck 
65f37104daSAmine Khaldi static HWND (WINAPI *pCreateUpDownControl)(DWORD, INT, INT, INT, INT,
66f37104daSAmine Khaldi     HWND, INT, HINSTANCE, HWND, INT, INT, INT);
67c2c66affSColin Finck static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
68c2c66affSColin Finck 
69c2c66affSColin Finck static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
70c2c66affSColin Finck 
71c2c66affSColin Finck static const struct message add_updown_with_edit_seq[] = {
72c2c66affSColin Finck     { WM_WINDOWPOSCHANGING, sent },
73c2c66affSColin Finck     { WM_NCCALCSIZE, sent|wparam, TRUE },
74c2c66affSColin Finck     { WM_WINDOWPOSCHANGED, sent },
75c2c66affSColin Finck     { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED /*, MAKELONG(91, 75) exact size depends on font */ },
76c2c66affSColin Finck     { 0 }
77c2c66affSColin Finck };
78c2c66affSColin Finck 
79c2c66affSColin Finck static const struct message add_updown_to_parent_seq[] = {
80c2c66affSColin Finck     { WM_NOTIFYFORMAT, sent|lparam, 0, NF_QUERY },
81c2c66affSColin Finck     { WM_QUERYUISTATE, sent|optional },
82c2c66affSColin Finck     { WM_PARENTNOTIFY, sent|wparam, MAKELONG(WM_CREATE, WM_CREATE) },
83c2c66affSColin Finck     { 0 }
84c2c66affSColin Finck };
85c2c66affSColin Finck 
86c2c66affSColin Finck static const struct message get_edit_text_seq[] = {
87c2c66affSColin Finck     { WM_GETTEXT, sent },
88c2c66affSColin Finck     { 0 }
89c2c66affSColin Finck };
90c2c66affSColin Finck 
91c2c66affSColin Finck static const struct message test_updown_pos_seq[] = {
92c2c66affSColin Finck     { UDM_SETRANGE, sent|lparam, 0, MAKELONG(100,0) },
93c2c66affSColin Finck     { UDM_GETRANGE, sent},
94c2c66affSColin Finck     { UDM_SETPOS, sent|lparam, 0, 5},
95c2c66affSColin Finck     { UDM_GETPOS, sent},
96c2c66affSColin Finck     { UDM_SETPOS, sent|lparam, 0, 0},
97c2c66affSColin Finck     { UDM_GETPOS, sent},
98c2c66affSColin Finck     { UDM_SETPOS, sent|lparam, 0, MAKELONG(-1,0)},
99c2c66affSColin Finck     { UDM_GETPOS, sent},
100c2c66affSColin Finck     { UDM_SETPOS, sent|lparam, 0, 100},
101c2c66affSColin Finck     { UDM_GETPOS, sent},
102c2c66affSColin Finck     { UDM_SETPOS, sent|lparam, 0, 101},
103c2c66affSColin Finck     { UDM_GETPOS, sent},
104c2c66affSColin Finck     { 0 }
105c2c66affSColin Finck };
106c2c66affSColin Finck 
107c2c66affSColin Finck static const struct message test_updown_pos32_seq[] = {
108c2c66affSColin Finck     { UDM_SETRANGE32, sent|lparam, 0, 1000 },
109c2c66affSColin Finck     { UDM_GETRANGE32, sent}, /* Cannot check wparam and lparam as they are ptrs */
110c2c66affSColin Finck     { UDM_SETPOS32, sent|lparam, 0, 500 },
111c2c66affSColin Finck     { UDM_GETPOS32, sent},
112c2c66affSColin Finck     { UDM_SETPOS32, sent|lparam, 0, 0 },
113c2c66affSColin Finck     { UDM_GETPOS32, sent},
114c2c66affSColin Finck     { UDM_SETPOS32, sent|lparam, 0, -1 },
115c2c66affSColin Finck     { UDM_GETPOS32, sent},
116c2c66affSColin Finck     { UDM_SETPOS32, sent|lparam, 0, 1000 },
117c2c66affSColin Finck     { UDM_GETPOS32, sent},
118c2c66affSColin Finck     { UDM_SETPOS32, sent|lparam, 0, 1001 },
119c2c66affSColin Finck     { UDM_GETPOS32, sent},
120c2c66affSColin Finck     { 0 }
121c2c66affSColin Finck };
122c2c66affSColin Finck 
123c2c66affSColin Finck static const struct message test_updown_buddy_seq[] = {
124c2c66affSColin Finck     { UDM_GETBUDDY, sent },
125c2c66affSColin Finck     { UDM_SETBUDDY, sent },
126c2c66affSColin Finck     { WM_STYLECHANGING, sent|defwinproc },
127c2c66affSColin Finck     { WM_STYLECHANGED, sent|defwinproc },
128c2c66affSColin Finck     { WM_STYLECHANGING, sent|defwinproc },
129c2c66affSColin Finck     { WM_STYLECHANGED, sent|defwinproc },
130c2c66affSColin Finck     { WM_WINDOWPOSCHANGING, sent|defwinproc },
131c2c66affSColin Finck     { WM_NCCALCSIZE, sent|wparam|optional|defwinproc, 1 },
132c2c66affSColin Finck     { WM_WINDOWPOSCHANGED, sent|defwinproc },
133c2c66affSColin Finck     { WM_MOVE, sent|defwinproc },
134c2c66affSColin Finck     { UDM_GETBUDDY, sent },
135c2c66affSColin Finck     { 0 }
136c2c66affSColin Finck };
137c2c66affSColin Finck 
138c2c66affSColin Finck static const struct message test_updown_base_seq[] = {
139c2c66affSColin Finck     { UDM_SETBASE, sent|wparam, 10 },
140c2c66affSColin Finck     { UDM_GETBASE, sent },
141c2c66affSColin Finck     { UDM_SETBASE, sent|wparam, 80 },
142c2c66affSColin Finck     { UDM_GETBASE, sent },
143c2c66affSColin Finck     { UDM_SETBASE, sent|wparam, 16 },
144c2c66affSColin Finck     { UDM_GETBASE, sent },
145c2c66affSColin Finck     { UDM_SETBASE, sent|wparam, 80 },
146c2c66affSColin Finck     { UDM_GETBASE, sent },
147c2c66affSColin Finck     { UDM_SETBASE, sent|wparam, 10 },
148c2c66affSColin Finck     { UDM_GETBASE, sent },
149c2c66affSColin Finck     { 0 }
150c2c66affSColin Finck };
151c2c66affSColin Finck 
152c2c66affSColin Finck static const struct message test_updown_unicode_seq[] = {
153c2c66affSColin Finck     { UDM_SETUNICODEFORMAT, sent|wparam, 0 },
154c2c66affSColin Finck     { UDM_GETUNICODEFORMAT, sent },
155c2c66affSColin Finck     { UDM_SETUNICODEFORMAT, sent|wparam, 1 },
156c2c66affSColin Finck     { UDM_GETUNICODEFORMAT, sent },
157c2c66affSColin Finck     { UDM_SETUNICODEFORMAT, sent|wparam, 0 },
158c2c66affSColin Finck     { UDM_GETUNICODEFORMAT, sent },
159c2c66affSColin Finck     { 0 }
160c2c66affSColin Finck };
161c2c66affSColin Finck 
162c2c66affSColin Finck static const struct message test_updown_pos_nochange_seq[] = {
163c2c66affSColin Finck     { WM_GETTEXT, sent|id, 0, 0, BUDDY_ID },
164c2c66affSColin Finck     { 0 }
165c2c66affSColin Finck };
166c2c66affSColin Finck 
1678addeea4SAmine Khaldi static const struct message test_updown_pos_notifications_seq[] = {
1688addeea4SAmine Khaldi     { WM_CTLCOLOREDIT, sent|optional },
1698addeea4SAmine Khaldi     { WM_COMMAND, sent|wparam, MAKELONG(0, EN_SETFOCUS) },
1708addeea4SAmine Khaldi     { WM_NOTIFY, sent|id, 0, 0, UDN_DELTAPOS },
1718addeea4SAmine Khaldi     { WM_COMMAND, sent|wparam, MAKELONG(0, EN_UPDATE) },
1728addeea4SAmine Khaldi     { WM_COMMAND, sent|wparam, MAKELONG(0, EN_CHANGE) },
1738addeea4SAmine Khaldi     { WM_VSCROLL, sent|wparam, MAKELONG(SB_THUMBPOSITION, 51) },
1748addeea4SAmine Khaldi     { WM_CTLCOLOREDIT, sent|optional },
1758addeea4SAmine Khaldi     { WM_VSCROLL, sent|wparam, MAKELONG(SB_ENDSCROLL, 51) },
1768addeea4SAmine Khaldi     /* no WM_NOTIFY(NM_RELEASEDCAPTURE) message */
1778addeea4SAmine Khaldi     { 0 }
1788addeea4SAmine Khaldi };
1798addeea4SAmine Khaldi 
1808addeea4SAmine Khaldi static const struct message test_updown_pos_notifications_horz_seq[] = {
1818addeea4SAmine Khaldi     { WM_CTLCOLOREDIT, sent|optional },
1828addeea4SAmine Khaldi     { WM_COMMAND, sent|wparam, MAKELONG(0, EN_SETFOCUS) },
1838addeea4SAmine Khaldi     { WM_NOTIFY, sent|id, 0, 0, UDN_DELTAPOS },
1848addeea4SAmine Khaldi     { WM_COMMAND, sent|wparam, MAKELONG(0, EN_UPDATE) },
1858addeea4SAmine Khaldi     { WM_COMMAND, sent|wparam, MAKELONG(0, EN_CHANGE) },
1868addeea4SAmine Khaldi     { WM_HSCROLL, sent|wparam, MAKELONG(SB_THUMBPOSITION, 51) },
1878addeea4SAmine Khaldi     { WM_CTLCOLOREDIT, sent|optional },
1888addeea4SAmine Khaldi     { WM_HSCROLL, sent|wparam, MAKELONG(SB_ENDSCROLL, 51) },
1898addeea4SAmine Khaldi     /* no WM_NOTIFY(NM_RELEASEDCAPTURE) message */
1908addeea4SAmine Khaldi     { 0 }
1918addeea4SAmine Khaldi };
1928addeea4SAmine Khaldi 
parent_wnd_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)193c2c66affSColin Finck static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
194c2c66affSColin Finck {
195c2c66affSColin Finck     static LONG defwndproc_counter = 0;
196c2c66affSColin Finck     struct message msg = { 0 };
197c2c66affSColin Finck     LRESULT ret;
198c2c66affSColin Finck 
199c2c66affSColin Finck     /* log system messages, except for painting */
200c2c66affSColin Finck     if (message < WM_USER &&
201c2c66affSColin Finck         message != WM_PAINT &&
202c2c66affSColin Finck         message != WM_ERASEBKGND &&
203c2c66affSColin Finck         message != WM_NCPAINT &&
204c2c66affSColin Finck         message != WM_NCHITTEST &&
205c2c66affSColin Finck         message != WM_GETTEXT &&
206c2c66affSColin Finck         message != WM_GETICON &&
207c2c66affSColin Finck         message != WM_DEVICECHANGE)
208c2c66affSColin Finck     {
209c2c66affSColin Finck         msg.message = message;
210c2c66affSColin Finck         msg.flags = sent|wparam|lparam;
211c2c66affSColin Finck         if (defwndproc_counter) msg.flags |= defwinproc;
212c2c66affSColin Finck         msg.wParam = wParam;
213c2c66affSColin Finck         msg.lParam = lParam;
2148addeea4SAmine Khaldi         if (message == WM_NOTIFY && lParam)
2158addeea4SAmine Khaldi             msg.id = ((NMHDR*)lParam)->code;
216c2c66affSColin Finck         add_message(sequences, PARENT_SEQ_INDEX, &msg);
217c2c66affSColin Finck     }
218c2c66affSColin Finck 
219c2c66affSColin Finck     defwndproc_counter++;
220c2c66affSColin Finck     ret = DefWindowProcA(hwnd, message, wParam, lParam);
221c2c66affSColin Finck     defwndproc_counter--;
222c2c66affSColin Finck 
223c2c66affSColin Finck     return ret;
224c2c66affSColin Finck }
225c2c66affSColin Finck 
register_parent_wnd_class(void)226c2c66affSColin Finck static BOOL register_parent_wnd_class(void)
227c2c66affSColin Finck {
228c2c66affSColin Finck     WNDCLASSA cls;
229c2c66affSColin Finck 
230c2c66affSColin Finck     cls.style = 0;
231c2c66affSColin Finck     cls.lpfnWndProc = parent_wnd_proc;
232c2c66affSColin Finck     cls.cbClsExtra = 0;
233c2c66affSColin Finck     cls.cbWndExtra = 0;
234c2c66affSColin Finck     cls.hInstance = GetModuleHandleA(NULL);
235c2c66affSColin Finck     cls.hIcon = 0;
236c2c66affSColin Finck     cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
237c2c66affSColin Finck     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
238c2c66affSColin Finck     cls.lpszMenuName = NULL;
239c2c66affSColin Finck     cls.lpszClassName = "Up-Down test parent class";
240c2c66affSColin Finck     return RegisterClassA(&cls);
241c2c66affSColin Finck }
242c2c66affSColin Finck 
create_parent_window(void)243c2c66affSColin Finck static HWND create_parent_window(void)
244c2c66affSColin Finck {
245c2c66affSColin Finck     if (!register_parent_wnd_class())
246c2c66affSColin Finck         return NULL;
247c2c66affSColin Finck 
248c2c66affSColin Finck     return CreateWindowExA(0, "Up-Down test parent class",
249c2c66affSColin Finck                           "Up-Down test parent window",
250c2c66affSColin Finck                           WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
251c2c66affSColin Finck                           WS_MAXIMIZEBOX | WS_VISIBLE,
252c2c66affSColin Finck                           0, 0, 100, 100,
253c2c66affSColin Finck                           GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
254c2c66affSColin Finck }
255c2c66affSColin Finck 
edit_subclass_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)256c2c66affSColin Finck static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
257c2c66affSColin Finck {
258c2c66affSColin Finck     WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
259c2c66affSColin Finck     static LONG defwndproc_counter = 0;
260c2c66affSColin Finck     struct message msg = { 0 };
261c2c66affSColin Finck     LRESULT ret;
262c2c66affSColin Finck 
263c2c66affSColin Finck     msg.message = message;
264c2c66affSColin Finck     msg.flags = sent|wparam|lparam;
265c2c66affSColin Finck     if (defwndproc_counter) msg.flags |= defwinproc;
266c2c66affSColin Finck     msg.wParam = wParam;
267c2c66affSColin Finck     msg.lParam = lParam;
268c2c66affSColin Finck     msg.id     = BUDDY_ID;
269c2c66affSColin Finck     add_message(sequences, EDIT_SEQ_INDEX, &msg);
270c2c66affSColin Finck 
271c2c66affSColin Finck     defwndproc_counter++;
272c2c66affSColin Finck     ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
273c2c66affSColin Finck     defwndproc_counter--;
274c2c66affSColin Finck     return ret;
275c2c66affSColin Finck }
276c2c66affSColin Finck 
create_edit_control(void)277c2c66affSColin Finck static HWND create_edit_control(void)
278c2c66affSColin Finck {
279c2c66affSColin Finck     WNDPROC oldproc;
280c2c66affSColin Finck     HWND hwnd;
281c2c66affSColin Finck     RECT rect;
282c2c66affSColin Finck 
283c2c66affSColin Finck     GetClientRect(parent_wnd, &rect);
284c2c66affSColin Finck     hwnd = CreateWindowExA(0, WC_EDITA, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE,
285c2c66affSColin Finck                            0, 0, rect.right, rect.bottom,
286c2c66affSColin Finck                            parent_wnd, NULL, GetModuleHandleA(NULL), NULL);
287c2c66affSColin Finck     if (!hwnd) return NULL;
288c2c66affSColin Finck 
289c2c66affSColin Finck     oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
290c2c66affSColin Finck                                          (LONG_PTR)edit_subclass_proc);
291c2c66affSColin Finck     SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
292c2c66affSColin Finck 
293c2c66affSColin Finck     return hwnd;
294c2c66affSColin Finck }
295c2c66affSColin Finck 
updown_subclass_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)296c2c66affSColin Finck static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
297c2c66affSColin Finck {
298c2c66affSColin Finck     WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
299c2c66affSColin Finck     static LONG defwndproc_counter = 0;
300c2c66affSColin Finck     struct message msg = { 0 };
301c2c66affSColin Finck     LRESULT ret;
302c2c66affSColin Finck 
303c2c66affSColin Finck     msg.message = message;
304c2c66affSColin Finck     msg.flags = sent|wparam|lparam;
305c2c66affSColin Finck     if (defwndproc_counter) msg.flags |= defwinproc;
306c2c66affSColin Finck     msg.wParam = wParam;
307c2c66affSColin Finck     msg.lParam = lParam;
308c2c66affSColin Finck     msg.id     = UPDOWN_ID;
309c2c66affSColin Finck     add_message(sequences, UPDOWN_SEQ_INDEX, &msg);
310c2c66affSColin Finck 
311c2c66affSColin Finck     defwndproc_counter++;
312c2c66affSColin Finck     ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
313c2c66affSColin Finck     defwndproc_counter--;
314c2c66affSColin Finck 
315c2c66affSColin Finck     return ret;
316c2c66affSColin Finck }
317c2c66affSColin Finck 
create_updown_control(DWORD style,HWND buddy)318c2c66affSColin Finck static HWND create_updown_control(DWORD style, HWND buddy)
319c2c66affSColin Finck {
320c2c66affSColin Finck     WNDPROC oldproc;
321c2c66affSColin Finck     HWND updown;
322c2c66affSColin Finck     RECT rect;
323c2c66affSColin Finck 
324c2c66affSColin Finck     GetClientRect(parent_wnd, &rect);
3250d320bc2SAmine Khaldi     updown = CreateWindowExA(0, UPDOWN_CLASSA, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | style,
3260d320bc2SAmine Khaldi                            0, 0, rect.right, rect.bottom,
3270d320bc2SAmine Khaldi                            parent_wnd, (HMENU)1, GetModuleHandleA(NULL), NULL);
3280d320bc2SAmine Khaldi     ok(updown != NULL, "Failed to create UpDown control.\n");
329c2c66affSColin Finck     if (!updown) return NULL;
330c2c66affSColin Finck 
3310d320bc2SAmine Khaldi     SendMessageA(updown, UDM_SETBUDDY, (WPARAM)buddy, 0);
3320d320bc2SAmine Khaldi     SendMessageA(updown, UDM_SETRANGE, 0, MAKELONG(100, 0));
3330d320bc2SAmine Khaldi     SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(50, 0));
3340d320bc2SAmine Khaldi 
335c2c66affSColin Finck     oldproc = (WNDPROC)SetWindowLongPtrA(updown, GWLP_WNDPROC,
336c2c66affSColin Finck                                          (LONG_PTR)updown_subclass_proc);
337c2c66affSColin Finck     SetWindowLongPtrA(updown, GWLP_USERDATA, (LONG_PTR)oldproc);
338c2c66affSColin Finck 
339c2c66affSColin Finck     return updown;
340c2c66affSColin Finck }
341c2c66affSColin Finck 
test_updown_pos(void)342c2c66affSColin Finck static void test_updown_pos(void)
343c2c66affSColin Finck {
344c2c66affSColin Finck     HWND updown;
345c2c66affSColin Finck     int r;
346c2c66affSColin Finck 
347c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
348c2c66affSColin Finck 
349c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
350c2c66affSColin Finck 
351c2c66affSColin Finck     /* Set Range from 0 to 100 */
352c2c66affSColin Finck     SendMessageA(updown, UDM_SETRANGE, 0 , MAKELONG(100,0) );
353c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETRANGE, 0,0);
354c2c66affSColin Finck     expect(100,LOWORD(r));
355c2c66affSColin Finck     expect(0,HIWORD(r));
356c2c66affSColin Finck 
357c2c66affSColin Finck     /* Set the position to 5, return is not checked as it was set before func call */
358c2c66affSColin Finck     SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(5,0) );
359c2c66affSColin Finck     /* Since UDM_SETBUDDYINT was not set at creation HIWORD(r) will always be 1 as a return from UDM_GETPOS */
360c2c66affSColin Finck     /* Get the position, which should be 5 */
361c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
362c2c66affSColin Finck     expect(5,LOWORD(r));
363c2c66affSColin Finck     expect(1,HIWORD(r));
364c2c66affSColin Finck 
365c2c66affSColin Finck     /* Set the position to 0, return should be 5 */
366c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(0,0) );
367c2c66affSColin Finck     expect(5,r);
368c2c66affSColin Finck     /* Get the position, which should be 0 */
369c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
370c2c66affSColin Finck     expect(0,LOWORD(r));
371c2c66affSColin Finck     expect(1,HIWORD(r));
372c2c66affSColin Finck 
373c2c66affSColin Finck     /* Set the position to -1, return should be 0 */
374c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(-1,0) );
375c2c66affSColin Finck     expect(0,r);
376c2c66affSColin Finck     /* Get the position, which should be 0 */
377c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
378c2c66affSColin Finck     expect(0,LOWORD(r));
379c2c66affSColin Finck     expect(1,HIWORD(r));
380c2c66affSColin Finck 
381c2c66affSColin Finck     /* Set the position to 100, return should be 0 */
382c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(100,0) );
383c2c66affSColin Finck     expect(0,r);
384c2c66affSColin Finck     /* Get the position, which should be 100 */
385c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
386c2c66affSColin Finck     expect(100,LOWORD(r));
387c2c66affSColin Finck     expect(1,HIWORD(r));
388c2c66affSColin Finck 
389c2c66affSColin Finck     /* Set the position to 101, return should be 100 */
390c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(101,0) );
391c2c66affSColin Finck     expect(100,r);
392c2c66affSColin Finck     /* Get the position, which should be 100 */
393c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
394c2c66affSColin Finck     expect(100,LOWORD(r));
395c2c66affSColin Finck     expect(1,HIWORD(r));
396c2c66affSColin Finck 
397c2c66affSColin Finck     ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos_seq , "test updown pos", FALSE);
398c2c66affSColin Finck 
399c2c66affSColin Finck     DestroyWindow(updown);
400c2c66affSColin Finck 
401c2c66affSColin Finck     /* there's no attempt to update buddy Edit if text didn't change */
402c2c66affSColin Finck     SetWindowTextA(g_edit, "50");
403c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_ARROWKEYS, g_edit);
404c2c66affSColin Finck 
405c2c66affSColin Finck     /* test sequence only on 5.8x versions */
406c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS32, 0, 0);
407c2c66affSColin Finck     if (r)
408c2c66affSColin Finck     {
409c2c66affSColin Finck         UDACCEL accel;
410c2c66affSColin Finck 
411c2c66affSColin Finck         flush_sequences(sequences, NUM_MSG_SEQUENCES);
412c2c66affSColin Finck 
413c2c66affSColin Finck         r = SendMessageA(updown, UDM_SETPOS, 0, 50);
414c2c66affSColin Finck         expect(50,r);
415c2c66affSColin Finck 
416c2c66affSColin Finck         ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
417c2c66affSColin Finck                     "test updown pos, no change", FALSE);
418c2c66affSColin Finck 
419c2c66affSColin Finck         SendMessageA(updown, UDM_SETRANGE, 0, MAKELONG(1, 40));
420c2c66affSColin Finck         r = SendMessageA(updown, UDM_GETRANGE, 0, 0);
421c2c66affSColin Finck         expect(1, LOWORD(r));
422c2c66affSColin Finck         expect(40, HIWORD(r));
423c2c66affSColin Finck 
424c2c66affSColin Finck         accel.nSec = 0;
425c2c66affSColin Finck         accel.nInc = 5;
426c2c66affSColin Finck         r = SendMessageA(updown, UDM_SETACCEL, 1, (LPARAM)&accel);
427c2c66affSColin Finck         expect(TRUE, r);
428c2c66affSColin Finck 
429c2c66affSColin Finck         r = SendMessageA(updown, UDM_GETPOS, 0, 0);
430c2c66affSColin Finck         expect(40, LOWORD(r));
431c2c66affSColin Finck         expect(1, HIWORD(r));
432c2c66affSColin Finck 
433c2c66affSColin Finck         r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(0, 0));
434c2c66affSColin Finck         expect(40, LOWORD(r));
435c2c66affSColin Finck         expect(0, HIWORD(r));
436c2c66affSColin Finck 
437c2c66affSColin Finck         r = SendMessageA(updown, UDM_GETPOS, 0, 0);
438c2c66affSColin Finck         expect(1, LOWORD(r));
439c2c66affSColin Finck         expect(0, HIWORD(r));
440c2c66affSColin Finck 
441c2c66affSColin Finck         r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(2, 0));
442c2c66affSColin Finck         expect(1, LOWORD(r));
443c2c66affSColin Finck         expect(0, HIWORD(r));
444c2c66affSColin Finck 
445c2c66affSColin Finck         r = SendMessageA(g_edit, WM_KEYDOWN, VK_UP, 0);
446c2c66affSColin Finck         expect(0, r);
447c2c66affSColin Finck         r = SendMessageA(updown, UDM_GETPOS, 0, 0);
448c2c66affSColin Finck         expect(1, LOWORD(r));
449c2c66affSColin Finck         expect(0, HIWORD(r));
450c2c66affSColin Finck 
451c2c66affSColin Finck         r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(50, 0));
452c2c66affSColin Finck         expect(1, LOWORD(r));
453c2c66affSColin Finck         expect(0, HIWORD(r));
454c2c66affSColin Finck 
455c2c66affSColin Finck         r = SendMessageA(updown, UDM_GETPOS, 0, 0);
456c2c66affSColin Finck         expect(40, LOWORD(r));
457c2c66affSColin Finck         expect(0, HIWORD(r));
458c2c66affSColin Finck     }
459c2c66affSColin Finck 
460c2c66affSColin Finck     DestroyWindow(updown);
461c2c66affSColin Finck }
462c2c66affSColin Finck 
test_updown_pos32(void)463c2c66affSColin Finck static void test_updown_pos32(void)
464c2c66affSColin Finck {
465c2c66affSColin Finck     HWND updown;
466c2c66affSColin Finck     int r;
467c2c66affSColin Finck     int low, high;
468c2c66affSColin Finck 
469c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
470c2c66affSColin Finck 
471c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
472c2c66affSColin Finck 
473c2c66affSColin Finck     /* Set the position to 0 to 1000 */
474c2c66affSColin Finck     SendMessageA(updown, UDM_SETRANGE32, 0 , 1000 );
475c2c66affSColin Finck 
476c2c66affSColin Finck     low = high = -1;
477c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETRANGE32, (WPARAM) &low , (LPARAM) &high );
478c2c66affSColin Finck     expect(0,r);
479c2c66affSColin Finck     if (low == -1)
480c2c66affSColin Finck     {
481c2c66affSColin Finck         win_skip("UDM_SETRANGE32/UDM_GETRANGE32 not available\n");
482c2c66affSColin Finck         DestroyWindow(updown);
483c2c66affSColin Finck         return;
484c2c66affSColin Finck     }
485c2c66affSColin Finck 
486c2c66affSColin Finck     expect(0,low);
487c2c66affSColin Finck     expect(1000,high);
488c2c66affSColin Finck 
489c2c66affSColin Finck     /* Set position to 500 */
490c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS32, 0 , 500 );
491c2c66affSColin Finck     if (!r)
492c2c66affSColin Finck     {
493c2c66affSColin Finck         win_skip("UDM_SETPOS32 and UDM_GETPOS32 need 5.80\n");
494c2c66affSColin Finck         DestroyWindow(updown);
495c2c66affSColin Finck         return;
496c2c66affSColin Finck     }
497c2c66affSColin Finck     expect(50,r);
498c2c66affSColin Finck 
499c2c66affSColin Finck     /* Since UDM_SETBUDDYINT was not set at creation bRet will always be true as a return from UDM_GETPOS32 */
500c2c66affSColin Finck 
501c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
502c2c66affSColin Finck     expect(500,r);
503c2c66affSColin Finck     expect(1,high);
504c2c66affSColin Finck 
505c2c66affSColin Finck     /* Set position to 0, return should be 500 */
506c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS32, 0 , 0 );
507c2c66affSColin Finck     expect(500,r);
508c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
509c2c66affSColin Finck     expect(0,r);
510c2c66affSColin Finck     expect(1,high);
511c2c66affSColin Finck 
512c2c66affSColin Finck     /* Set position to -1 which should become 0, return should be 0 */
513c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS32, 0 , -1 );
514c2c66affSColin Finck     expect(0,r);
515c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
516c2c66affSColin Finck     expect(0,r);
517c2c66affSColin Finck     expect(1,high);
518c2c66affSColin Finck 
519c2c66affSColin Finck     /* Set position to 1000, return should be 0 */
520c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS32, 0 , 1000 );
521c2c66affSColin Finck     expect(0,r);
522c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
523c2c66affSColin Finck     expect(1000,r);
524c2c66affSColin Finck     expect(1,high);
525c2c66affSColin Finck 
526c2c66affSColin Finck     /* Set position to 1001 which should become 1000, return should be 1000 */
527c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS32, 0 , 1001 );
528c2c66affSColin Finck     expect(1000,r);
529c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
530c2c66affSColin Finck     expect(1000,r);
531c2c66affSColin Finck     expect(1,high);
532c2c66affSColin Finck 
533c2c66affSColin Finck     ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos32_seq, "test updown pos32", FALSE);
534c2c66affSColin Finck 
535c2c66affSColin Finck     DestroyWindow(updown);
536c2c66affSColin Finck 
537c2c66affSColin Finck     /* there's no attempt to update buddy Edit if text didn't change */
538c2c66affSColin Finck     SetWindowTextA(g_edit, "50");
539c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT, g_edit);
540c2c66affSColin Finck 
541c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
542c2c66affSColin Finck 
543c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS32, 0, 50);
544c2c66affSColin Finck     expect(50,r);
545c2c66affSColin Finck     ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
546c2c66affSColin Finck                 "test updown pos, no change", FALSE);
547c2c66affSColin Finck 
548c2c66affSColin Finck     DestroyWindow(updown);
549c2c66affSColin Finck }
550c2c66affSColin Finck 
test_updown_buddy(void)551c2c66affSColin Finck static void test_updown_buddy(void)
552c2c66affSColin Finck {
553c2c66affSColin Finck     HWND updown, buddyReturn, buddy;
5540d320bc2SAmine Khaldi     RECT rect, rect2;
555c2c66affSColin Finck     WNDPROC proc;
556c2c66affSColin Finck     DWORD style;
557c2c66affSColin Finck 
558c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
559c2c66affSColin Finck 
560c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
561c2c66affSColin Finck 
562c2c66affSColin Finck     buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0 , 0 );
563c2c66affSColin Finck     ok(buddyReturn == g_edit, "Expected edit handle\n");
564c2c66affSColin Finck 
565c2c66affSColin Finck     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, (WPARAM) g_edit, 0);
566c2c66affSColin Finck     ok(buddyReturn == g_edit, "Expected edit handle\n");
567c2c66affSColin Finck 
568c2c66affSColin Finck     buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0 , 0 );
569c2c66affSColin Finck     ok(buddyReturn == g_edit, "Expected edit handle\n");
570c2c66affSColin Finck 
571c2c66affSColin Finck     ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_buddy_seq, "test updown buddy", TRUE);
572c2c66affSColin Finck     ok_sequence(sequences, EDIT_SEQ_INDEX, add_updown_with_edit_seq, "test updown buddy_edit", FALSE);
573c2c66affSColin Finck 
574c2c66affSColin Finck     DestroyWindow(updown);
575c2c66affSColin Finck 
576c2c66affSColin Finck     buddy = create_edit_control();
577c2c66affSColin Finck     proc  = (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC);
578c2c66affSColin Finck 
579c2c66affSColin Finck     updown= create_updown_control(UDS_ALIGNRIGHT, buddy);
580c2c66affSColin Finck     ok(proc == (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC), "No subclassing expected\n");
581c2c66affSColin Finck 
582c2c66affSColin Finck     style = GetWindowLongA(updown, GWL_STYLE);
583c2c66affSColin Finck     SetWindowLongA(updown, GWL_STYLE, style | UDS_ARROWKEYS);
584c2c66affSColin Finck     style = GetWindowLongA(updown, GWL_STYLE);
585c2c66affSColin Finck     ok(style & UDS_ARROWKEYS, "Expected UDS_ARROWKEYS\n");
586c2c66affSColin Finck     /* no subclass if UDS_ARROWKEYS set after creation */
587c2c66affSColin Finck     ok(proc == (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC), "No subclassing expected\n");
588c2c66affSColin Finck 
589c2c66affSColin Finck     DestroyWindow(updown);
590c2c66affSColin Finck 
591c2c66affSColin Finck     updown= create_updown_control(UDS_ALIGNRIGHT | UDS_ARROWKEYS, buddy);
592c2c66affSColin Finck     ok(proc != (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC), "Subclassing expected\n");
593c2c66affSColin Finck 
594c2c66affSColin Finck     if (pSetWindowSubclass)
595c2c66affSColin Finck     {
596c2c66affSColin Finck         /* updown uses subclass helpers for buddy on >5.8x systems */
597c2c66affSColin Finck         ok(GetPropA(buddy, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
598c2c66affSColin Finck     }
599c2c66affSColin Finck 
600c2c66affSColin Finck     DestroyWindow(updown);
601c2c66affSColin Finck     DestroyWindow(buddy);
6020d320bc2SAmine Khaldi 
6030d320bc2SAmine Khaldi     /* Create with buddy and UDS_HORZ, reset buddy. */
6040d320bc2SAmine Khaldi     updown = create_updown_control(UDS_HORZ, g_edit);
6050d320bc2SAmine Khaldi 
6060d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0, 0);
6070d320bc2SAmine Khaldi     ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
6080d320bc2SAmine Khaldi 
6090d320bc2SAmine Khaldi     GetClientRect(updown, &rect);
6100d320bc2SAmine Khaldi 
6110d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
6120d320bc2SAmine Khaldi     ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
6130d320bc2SAmine Khaldi 
6140d320bc2SAmine Khaldi     GetClientRect(updown, &rect2);
6150d320bc2SAmine Khaldi     ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
6160d320bc2SAmine Khaldi 
6170d320bc2SAmine Khaldi     /* Remove UDS_HORZ, reset buddy again. */
6180d320bc2SAmine Khaldi     style = GetWindowLongA(updown, GWL_STYLE);
6190d320bc2SAmine Khaldi     SetWindowLongA(updown, GWL_STYLE, style & ~UDS_HORZ);
6200d320bc2SAmine Khaldi     style = GetWindowLongA(updown, GWL_STYLE);
6210d320bc2SAmine Khaldi     ok(!(style & UDS_HORZ), "Unexpected style.\n");
6220d320bc2SAmine Khaldi 
6230d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
6240d320bc2SAmine Khaldi     ok(buddyReturn == NULL, "Unexpected buddy window.\n");
6250d320bc2SAmine Khaldi 
6260d320bc2SAmine Khaldi     GetClientRect(updown, &rect2);
6270d320bc2SAmine Khaldi     ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
6280d320bc2SAmine Khaldi 
6290d320bc2SAmine Khaldi     DestroyWindow(updown);
6300d320bc2SAmine Khaldi 
6310d320bc2SAmine Khaldi     /* Without UDS_HORZ. */
6320d320bc2SAmine Khaldi     updown = create_updown_control(0, g_edit);
6330d320bc2SAmine Khaldi 
6340d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0, 0);
6350d320bc2SAmine Khaldi     ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
6360d320bc2SAmine Khaldi 
6370d320bc2SAmine Khaldi     GetClientRect(updown, &rect);
6380d320bc2SAmine Khaldi 
6390d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
6400d320bc2SAmine Khaldi     ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
6410d320bc2SAmine Khaldi 
6420d320bc2SAmine Khaldi     GetClientRect(updown, &rect2);
6430d320bc2SAmine Khaldi     ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
6440d320bc2SAmine Khaldi 
6450d320bc2SAmine Khaldi     DestroyWindow(updown);
6460d320bc2SAmine Khaldi 
6470d320bc2SAmine Khaldi     /* Create without buddy. */
6480d320bc2SAmine Khaldi     GetClientRect(parent_wnd, &rect);
6490d320bc2SAmine Khaldi     updown = CreateWindowExA(0, UPDOWN_CLASSA, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_HORZ,
6500d320bc2SAmine Khaldi         0, 0, rect.right, rect.bottom, parent_wnd, (HMENU)1, GetModuleHandleA(NULL), NULL);
6510d320bc2SAmine Khaldi     ok(updown != NULL, "Failed to create UpDown control.\n");
6520d320bc2SAmine Khaldi 
6530d320bc2SAmine Khaldi     GetClientRect(updown, &rect);
6540d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
6550d320bc2SAmine Khaldi     ok(buddyReturn == NULL, "Unexpected buddy window.\n");
6560d320bc2SAmine Khaldi     GetClientRect(updown, &rect2);
6570d320bc2SAmine Khaldi 
6580d320bc2SAmine Khaldi     ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
6590d320bc2SAmine Khaldi 
6600d320bc2SAmine Khaldi     style = GetWindowLongA(updown, GWL_STYLE);
6610d320bc2SAmine Khaldi     SetWindowLongA(updown, GWL_STYLE, style & ~UDS_HORZ);
6620d320bc2SAmine Khaldi 
6630d320bc2SAmine Khaldi     GetClientRect(updown, &rect2);
6640d320bc2SAmine Khaldi     ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
6650d320bc2SAmine Khaldi 
6660d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, (WPARAM)g_edit, 0);
6670d320bc2SAmine Khaldi     ok(buddyReturn == NULL, "Unexpected buddy window.\n");
6680d320bc2SAmine Khaldi     GetClientRect(updown, &rect);
6690d320bc2SAmine Khaldi 
6700d320bc2SAmine Khaldi     buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
6710d320bc2SAmine Khaldi     ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
6720d320bc2SAmine Khaldi     GetClientRect(updown, &rect2);
6730d320bc2SAmine Khaldi todo_wine
6740d320bc2SAmine Khaldi     ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
6750d320bc2SAmine Khaldi 
6760d320bc2SAmine Khaldi     DestroyWindow(updown);
677c2c66affSColin Finck }
678c2c66affSColin Finck 
test_updown_base(void)679c2c66affSColin Finck static void test_updown_base(void)
680c2c66affSColin Finck {
681c2c66affSColin Finck     HWND updown;
682c2c66affSColin Finck     int r;
683c2c66affSColin Finck     CHAR text[10];
684c2c66affSColin Finck 
685c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
686c2c66affSColin Finck 
687c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
688c2c66affSColin Finck 
689c2c66affSColin Finck     SendMessageA(updown, UDM_SETBASE, 10 , 0);
690c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
691c2c66affSColin Finck     expect(10,r);
692c2c66affSColin Finck 
693c2c66affSColin Finck     /* Set base to an invalid value, should return 0 and stay at 10 */
694c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETBASE, 80 , 0);
695c2c66affSColin Finck     expect(0,r);
696c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
697c2c66affSColin Finck     expect(10,r);
698c2c66affSColin Finck 
699c2c66affSColin Finck     /* Set base to 16 now, should get 16 as the return */
700c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETBASE, 16 , 0);
701c2c66affSColin Finck     expect(10,r);
702c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
703c2c66affSColin Finck     expect(16,r);
704c2c66affSColin Finck 
705c2c66affSColin Finck     /* Set base to an invalid value, should return 0 and stay at 16 */
706c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETBASE, 80 , 0);
707c2c66affSColin Finck     expect(0,r);
708c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
709c2c66affSColin Finck     expect(16,r);
710c2c66affSColin Finck 
711c2c66affSColin Finck     /* Set base back to 10, return should be 16 */
712c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETBASE, 10 , 0);
713c2c66affSColin Finck     expect(16,r);
714c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
715c2c66affSColin Finck     expect(10,r);
716c2c66affSColin Finck 
717c2c66affSColin Finck     ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_base_seq, "test updown base", FALSE);
718c2c66affSColin Finck 
719c2c66affSColin Finck     DestroyWindow(updown);
720c2c66affSColin Finck 
721c2c66affSColin Finck     /* switch base with buddy attached */
722c2c66affSColin Finck     updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);
723c2c66affSColin Finck 
724c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETPOS, 0, 10);
725c2c66affSColin Finck     expect(50, r);
726c2c66affSColin Finck 
7275f7243b5SAmine Khaldi     GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
728c2c66affSColin Finck     ok(lstrcmpA(text, "10") == 0, "Expected '10', got '%s'\n", text);
729c2c66affSColin Finck 
730c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETBASE, 16, 0);
731c2c66affSColin Finck     expect(10, r);
732c2c66affSColin Finck 
7335f7243b5SAmine Khaldi     GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
734c2c66affSColin Finck     /* FIXME: currently hex output isn't properly formatted, but for this
735c2c66affSColin Finck        test only change from initial text matters */
736c2c66affSColin Finck     ok(lstrcmpA(text, "10") != 0, "Expected '0x000A', got '%s'\n", text);
737c2c66affSColin Finck 
738c2c66affSColin Finck     DestroyWindow(updown);
739c2c66affSColin Finck }
740c2c66affSColin Finck 
test_updown_unicode(void)741c2c66affSColin Finck static void test_updown_unicode(void)
742c2c66affSColin Finck {
743c2c66affSColin Finck     HWND updown;
744c2c66affSColin Finck     int r;
745c2c66affSColin Finck 
746c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
747c2c66affSColin Finck 
748c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
749c2c66affSColin Finck 
750c2c66affSColin Finck     /* Set it to ANSI, don't check return as we don't know previous state */
751c2c66affSColin Finck     SendMessageA(updown, UDM_SETUNICODEFORMAT, 0 , 0);
752c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETUNICODEFORMAT, 0 , 0);
753c2c66affSColin Finck     expect(0,r);
754c2c66affSColin Finck 
755c2c66affSColin Finck     /* Now set it to Unicode format */
756c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETUNICODEFORMAT, 1 , 0);
757c2c66affSColin Finck     expect(0,r);
758c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETUNICODEFORMAT, 0 , 0);
759c2c66affSColin Finck     if (!r)
760c2c66affSColin Finck     {
761c2c66affSColin Finck         win_skip("UDM_SETUNICODEFORMAT not available\n");
762c2c66affSColin Finck         DestroyWindow(updown);
763c2c66affSColin Finck         return;
764c2c66affSColin Finck     }
765c2c66affSColin Finck     expect(1,r);
766c2c66affSColin Finck 
767c2c66affSColin Finck     /* And now set it back to ANSI */
768c2c66affSColin Finck     r = SendMessageA(updown, UDM_SETUNICODEFORMAT, 0 , 0);
769c2c66affSColin Finck     expect(1,r);
770c2c66affSColin Finck     r = SendMessageA(updown, UDM_GETUNICODEFORMAT, 0 , 0);
771c2c66affSColin Finck     expect(0,r);
772c2c66affSColin Finck 
773c2c66affSColin Finck     ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_unicode_seq, "test updown unicode", FALSE);
774c2c66affSColin Finck 
775c2c66affSColin Finck     DestroyWindow(updown);
776c2c66affSColin Finck }
777c2c66affSColin Finck 
test_updown_create(void)778c2c66affSColin Finck static void test_updown_create(void)
779c2c66affSColin Finck {
780c2c66affSColin Finck     CHAR text[MAX_PATH];
781c2c66affSColin Finck     HWND updown;
782c2c66affSColin Finck     RECT r;
783c2c66affSColin Finck 
784c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
785c2c66affSColin Finck 
786c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
787c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
788c2c66affSColin Finck     ok_sequence(sequences, PARENT_SEQ_INDEX, add_updown_to_parent_seq, "add updown control to parent", TRUE);
789c2c66affSColin Finck     ok_sequence(sequences, EDIT_SEQ_INDEX, add_updown_with_edit_seq, "add updown control with edit", FALSE);
790c2c66affSColin Finck 
791c2c66affSColin Finck     flush_sequences(sequences, NUM_MSG_SEQUENCES);
792c2c66affSColin Finck 
793c2c66affSColin Finck     GetWindowTextA(g_edit, text, MAX_PATH);
794*0707475fSJustin Miller     ok(!*text, "Expected empty string\n");
795c2c66affSColin Finck     ok_sequence(sequences, EDIT_SEQ_INDEX, get_edit_text_seq, "get edit text", FALSE);
796c2c66affSColin Finck 
797c2c66affSColin Finck     DestroyWindow(updown);
798c2c66affSColin Finck 
799c2c66affSColin Finck     /* create with zero width */
800c2c66affSColin Finck     updown = CreateWindowA (UPDOWN_CLASSA, 0, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 0,
801c2c66affSColin Finck                    parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
802c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
803c2c66affSColin Finck     r.right = 0;
804c2c66affSColin Finck     GetClientRect(updown, &r);
805c2c66affSColin Finck     ok(r.right > 0, "Expected default width, got %d\n", r.right);
806c2c66affSColin Finck     DestroyWindow(updown);
807c2c66affSColin Finck     /* create with really small width */
808c2c66affSColin Finck     updown = CreateWindowA (UPDOWN_CLASSA, 0, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 2, 0,
809c2c66affSColin Finck                    parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
810c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
811c2c66affSColin Finck     r.right = 0;
812c2c66affSColin Finck     GetClientRect(updown, &r);
813c2c66affSColin Finck     ok(r.right != 2 && r.right > 0, "Expected default width, got %d\n", r.right);
814c2c66affSColin Finck     DestroyWindow(updown);
815c2c66affSColin Finck     /* create with width greater than default */
816c2c66affSColin Finck     updown = CreateWindowA (UPDOWN_CLASSA, 0, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 100, 0,
817c2c66affSColin Finck                    parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
818c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
819c2c66affSColin Finck     r.right = 0;
820c2c66affSColin Finck     GetClientRect(updown, &r);
821c2c66affSColin Finck     ok(r.right < 100 && r.right > 0, "Expected default width, got %d\n", r.right);
822c2c66affSColin Finck     DestroyWindow(updown);
823c2c66affSColin Finck     /* create with zero height, UDS_HORZ */
824c2c66affSColin Finck     updown = CreateWindowA (UPDOWN_CLASSA, 0, UDS_HORZ | WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 0,
825c2c66affSColin Finck                    parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
826c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
827c2c66affSColin Finck     r.bottom = 0;
828c2c66affSColin Finck     GetClientRect(updown, &r);
829c2c66affSColin Finck     ok(r.bottom == 0, "Expected zero height, got %d\n", r.bottom);
830c2c66affSColin Finck     DestroyWindow(updown);
831c2c66affSColin Finck     /* create with really small height, UDS_HORZ */
832c2c66affSColin Finck     updown = CreateWindowA (UPDOWN_CLASSA, 0, UDS_HORZ | WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 2,
833c2c66affSColin Finck                    parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
834c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
835c2c66affSColin Finck     r.bottom = 0;
836c2c66affSColin Finck     GetClientRect(updown, &r);
837c2c66affSColin Finck     ok(r.bottom == 0, "Expected zero height, got %d\n", r.bottom);
838c2c66affSColin Finck     DestroyWindow(updown);
839c2c66affSColin Finck     /* create with height greater than default, UDS_HORZ */
840c2c66affSColin Finck     updown = CreateWindowA (UPDOWN_CLASSA, 0, UDS_HORZ | WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 100,
841c2c66affSColin Finck                    parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
842c2c66affSColin Finck     ok(updown != NULL, "Failed to create updown control\n");
843c2c66affSColin Finck     r.bottom = 0;
844c2c66affSColin Finck     GetClientRect(updown, &r);
845c2c66affSColin Finck     ok(r.bottom < 100 && r.bottom > 0, "Expected default height, got %d\n", r.bottom);
846c2c66affSColin Finck     DestroyWindow(updown);
847c2c66affSColin Finck }
848c2c66affSColin Finck 
test_UDS_SETBUDDYINT(void)849c2c66affSColin Finck static void test_UDS_SETBUDDYINT(void)
850c2c66affSColin Finck {
851c2c66affSColin Finck     HWND updown;
852c2c66affSColin Finck     DWORD style, ret;
853c2c66affSColin Finck     CHAR text[10];
854c2c66affSColin Finck 
855c2c66affSColin Finck     /* cleanup buddy */
856c2c66affSColin Finck     text[0] = '\0';
857c2c66affSColin Finck     SetWindowTextA(g_edit, text);
858c2c66affSColin Finck 
859c2c66affSColin Finck     /* creating without UDS_SETBUDDYINT */
860c2c66affSColin Finck     updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
861c2c66affSColin Finck     /* try to set UDS_SETBUDDYINT after creation */
862c2c66affSColin Finck     style = GetWindowLongA(updown, GWL_STYLE);
863c2c66affSColin Finck     SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
864c2c66affSColin Finck     style = GetWindowLongA(updown, GWL_STYLE);
865c2c66affSColin Finck     ok(style & UDS_SETBUDDYINT, "Expected UDS_SETBUDDY to be set\n");
866c2c66affSColin Finck     SendMessageA(updown, UDM_SETPOS, 0, 20);
8675f7243b5SAmine Khaldi     GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
868*0707475fSJustin Miller     ok(!*text, "Expected empty string\n");
869c2c66affSColin Finck     DestroyWindow(updown);
870c2c66affSColin Finck 
871c2c66affSColin Finck     /* creating with UDS_SETBUDDYINT */
872c2c66affSColin Finck     updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);
8735f7243b5SAmine Khaldi     GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
874c2c66affSColin Finck     /* 50 is initial value here */
875c2c66affSColin Finck     ok(lstrcmpA(text, "50") == 0, "Expected '50', got '%s'\n", text);
876c2c66affSColin Finck     /* now remove style flag */
877c2c66affSColin Finck     style = GetWindowLongA(updown, GWL_STYLE);
878c2c66affSColin Finck     SetWindowLongA(updown, GWL_STYLE, style & ~UDS_SETBUDDYINT);
879c2c66affSColin Finck     SendMessageA(updown, UDM_SETPOS, 0, 20);
8805f7243b5SAmine Khaldi     GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
881c2c66affSColin Finck     ok(lstrcmpA(text, "20") == 0, "Expected '20', got '%s'\n", text);
882c2c66affSColin Finck     /* set edit text directly, check position */
883c2c66affSColin Finck     strcpy(text, "10");
884c2c66affSColin Finck     SetWindowTextA(g_edit, text);
885c2c66affSColin Finck     ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
886c2c66affSColin Finck     expect(10, ret);
887c2c66affSColin Finck     strcpy(text, "11");
888c2c66affSColin Finck     SetWindowTextA(g_edit, text);
889c2c66affSColin Finck     ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
890c2c66affSColin Finck     expect(11, LOWORD(ret));
891c2c66affSColin Finck     expect(0,  HIWORD(ret));
892c2c66affSColin Finck     /* set to invalid value */
893c2c66affSColin Finck     strcpy(text, "21st");
894c2c66affSColin Finck     SetWindowTextA(g_edit, text);
895c2c66affSColin Finck     ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
896c2c66affSColin Finck     expect(11, LOWORD(ret));
897c2c66affSColin Finck     expect(TRUE, HIWORD(ret));
898c2c66affSColin Finck     /* set style back */
899c2c66affSColin Finck     style = GetWindowLongA(updown, GWL_STYLE);
900c2c66affSColin Finck     SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
901c2c66affSColin Finck     SendMessageA(updown, UDM_SETPOS, 0, 30);
9025f7243b5SAmine Khaldi     GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
903c2c66affSColin Finck     ok(lstrcmpA(text, "30") == 0, "Expected '30', got '%s'\n", text);
904c2c66affSColin Finck     DestroyWindow(updown);
905c2c66affSColin Finck }
906c2c66affSColin Finck 
test_CreateUpDownControl(void)9070d320bc2SAmine Khaldi static void test_CreateUpDownControl(void)
9080d320bc2SAmine Khaldi {
9090d320bc2SAmine Khaldi     HWND updown, buddy;
9100d320bc2SAmine Khaldi     DWORD range, pos;
9110d320bc2SAmine Khaldi     RECT rect;
9120d320bc2SAmine Khaldi 
9130d320bc2SAmine Khaldi     GetClientRect(parent_wnd, &rect);
914f37104daSAmine Khaldi     updown = pCreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE,
9150d320bc2SAmine Khaldi         0, 0, rect.right, rect.bottom, parent_wnd, 1, GetModuleHandleA(NULL), g_edit, 100, 10, 50);
9160d320bc2SAmine Khaldi     ok(updown != NULL, "Failed to create control.\n");
9170d320bc2SAmine Khaldi 
9180d320bc2SAmine Khaldi     buddy = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0, 0);
9190d320bc2SAmine Khaldi     ok(buddy == g_edit, "Unexpected buddy window.\n");
9200d320bc2SAmine Khaldi 
9210d320bc2SAmine Khaldi     range = SendMessageA(updown, UDM_GETRANGE, 0, 0);
9220d320bc2SAmine Khaldi     ok(range == MAKELONG(100, 10), "Unexpected range.\n");
9230d320bc2SAmine Khaldi 
9240d320bc2SAmine Khaldi     pos = SendMessageA(updown, UDM_GETPOS, 0, 0);
9250d320bc2SAmine Khaldi     ok(pos == MAKELONG(50, 1), "Unexpected position.\n");
9260d320bc2SAmine Khaldi 
9270d320bc2SAmine Khaldi     DestroyWindow(updown);
9280d320bc2SAmine Khaldi }
9290d320bc2SAmine Khaldi 
test_updown_pos_notifications(void)9308addeea4SAmine Khaldi static void test_updown_pos_notifications(void)
9318addeea4SAmine Khaldi {
9328addeea4SAmine Khaldi     HWND updown;
9338addeea4SAmine Khaldi     RECT rect;
9348addeea4SAmine Khaldi     UINT x, y;
9358addeea4SAmine Khaldi     int result;
9368addeea4SAmine Khaldi 
9378addeea4SAmine Khaldi     /* test updown control notifications without UDS_HORZ style */
9388addeea4SAmine Khaldi     updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT, g_edit);
9398addeea4SAmine Khaldi     SetFocus(updown);
9408addeea4SAmine Khaldi     flush_sequences(sequences, NUM_MSG_SEQUENCES);
9418addeea4SAmine Khaldi 
9428addeea4SAmine Khaldi     /* click on the up-arrow button */
9438addeea4SAmine Khaldi     GetClientRect(updown, &rect);
9448addeea4SAmine Khaldi     x = rect.left + (rect.right - rect.left) / 2;
9458addeea4SAmine Khaldi     y = rect.top + (rect.bottom - rect.top) / 4;
9468addeea4SAmine Khaldi     result = SendMessageA(updown, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
9478addeea4SAmine Khaldi     expect(result, 0);
9488addeea4SAmine Khaldi     result = SendMessageA(updown, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
9498addeea4SAmine Khaldi     expect(result, 0);
9508addeea4SAmine Khaldi 
9518addeea4SAmine Khaldi     ok_sequence(sequences, PARENT_SEQ_INDEX, test_updown_pos_notifications_seq,
9528addeea4SAmine Khaldi                 "test updown to parent notify (vertical)", FALSE);
9538addeea4SAmine Khaldi 
9548addeea4SAmine Khaldi     DestroyWindow(updown);
9558addeea4SAmine Khaldi 
9568addeea4SAmine Khaldi     /* test updown control notifications with UDS_HORZ style */
9578addeea4SAmine Khaldi     updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_HORZ, g_edit);
9588addeea4SAmine Khaldi     SetFocus(updown);
9598addeea4SAmine Khaldi     flush_sequences(sequences, NUM_MSG_SEQUENCES);
9608addeea4SAmine Khaldi 
9618addeea4SAmine Khaldi     /* click on the right-arrow button */
9628addeea4SAmine Khaldi     GetClientRect(updown, &rect);
9638addeea4SAmine Khaldi     x = rect.left + (rect.right - rect.left) * 3 / 4;
9648addeea4SAmine Khaldi     y = rect.top + (rect.bottom - rect.top) / 2;
9658addeea4SAmine Khaldi     result = SendMessageA(updown, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
9668addeea4SAmine Khaldi     expect(result, 0);
9678addeea4SAmine Khaldi     result = SendMessageA(updown, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
9688addeea4SAmine Khaldi     expect(result, 0);
9698addeea4SAmine Khaldi 
9708addeea4SAmine Khaldi     ok_sequence(sequences, PARENT_SEQ_INDEX, test_updown_pos_notifications_horz_seq,
9718addeea4SAmine Khaldi                 "test updown to parent notify (horizontal)", FALSE);
9728addeea4SAmine Khaldi 
9738addeea4SAmine Khaldi     DestroyWindow(updown);
9748addeea4SAmine Khaldi }
9758addeea4SAmine Khaldi 
init_functions(void)976f37104daSAmine Khaldi static void init_functions(void)
977f37104daSAmine Khaldi {
978f37104daSAmine Khaldi     HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
979f37104daSAmine Khaldi 
980f37104daSAmine Khaldi #define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
981f37104daSAmine Khaldi #define X2(f, ord) p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);
982f37104daSAmine Khaldi     X(CreateUpDownControl);
983f37104daSAmine Khaldi     X2(SetWindowSubclass, 410);
984f37104daSAmine Khaldi #undef X
985f37104daSAmine Khaldi #undef X2
986f37104daSAmine Khaldi }
987f37104daSAmine Khaldi 
START_TEST(updown)988c2c66affSColin Finck START_TEST(updown)
989c2c66affSColin Finck {
990f37104daSAmine Khaldi     init_functions();
991c2c66affSColin Finck 
992c2c66affSColin Finck     init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
993c2c66affSColin Finck 
994c2c66affSColin Finck     parent_wnd = create_parent_window();
995c2c66affSColin Finck     ok(parent_wnd != NULL, "Failed to create parent window!\n");
996c2c66affSColin Finck     g_edit = create_edit_control();
997c2c66affSColin Finck     ok(g_edit != NULL, "Failed to create edit control\n");
998c2c66affSColin Finck 
999c2c66affSColin Finck     test_updown_create();
1000c2c66affSColin Finck     test_updown_pos();
1001c2c66affSColin Finck     test_updown_pos32();
1002c2c66affSColin Finck     test_updown_buddy();
1003c2c66affSColin Finck     test_updown_base();
1004c2c66affSColin Finck     test_updown_unicode();
1005c2c66affSColin Finck     test_UDS_SETBUDDYINT();
10060d320bc2SAmine Khaldi     test_CreateUpDownControl();
10078addeea4SAmine Khaldi     test_updown_pos_notifications();
1008c2c66affSColin Finck 
1009c2c66affSColin Finck     DestroyWindow(g_edit);
1010c2c66affSColin Finck     DestroyWindow(parent_wnd);
1011c2c66affSColin Finck }
1012