2007-01-10 04:27:36 +01:00
|
|
|
/* Unit tests for the up-down control
|
2005-03-16 20:52:40 +01:00
|
|
|
*
|
|
|
|
* Copyright 2005 C. Scott Ananian
|
2007-01-10 04:27:36 +01:00
|
|
|
* Copyright (C) 2007 James Hawkins
|
2007-02-11 05:37:26 +01:00
|
|
|
* Copyright (C) 2007 Leslie Choong
|
2005-03-16 20:52:40 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-03-16 20:52:40 +01:00
|
|
|
*/
|
|
|
|
|
2007-01-10 04:27:36 +01:00
|
|
|
/* TO TEST:
|
|
|
|
* - send click messages to the up-down control, check the current position
|
|
|
|
* - up-down control automatically positions itself next to its buddy window
|
|
|
|
* - up-down control sets the caption of the buddy window
|
|
|
|
* - test CreateUpDownControl API
|
|
|
|
* - check UDS_AUTOBUDDY style, up-down control selects previous window in z-order
|
|
|
|
* - check UDM_SETBUDDY message
|
|
|
|
* - check UDM_GETBUDDY message
|
|
|
|
* - up-down control and buddy control must have the same parent
|
|
|
|
* - up-down control notifies its parent window when its position changes with UDN_DELTAPOS + WM_VSCROLL or WM_HSCROLL
|
|
|
|
* - check UDS_ALIGN[LEFT,RIGHT]...check that width of buddy window is decreased
|
|
|
|
* - check that UDS_SETBUDDYINT sets the caption of the buddy window when it is changed
|
|
|
|
* - check that the thousands operator is set for large numbers
|
|
|
|
* - check that the thousands operator is not set with UDS_NOTHOUSANDS
|
|
|
|
* - check UDS_ARROWKEYS, control subclasses the buddy window so that it processes the keys when it has focus
|
|
|
|
* - check UDS_HORZ
|
|
|
|
* - check changing past min/max values
|
|
|
|
* - check UDS_WRAP wraps values past min/max, incrementing past upper value wraps position to lower value
|
|
|
|
* - can change control's position, min/max pos, radix
|
|
|
|
* - check UDM_GETPOS, for up-down control with a buddy window, position is the caption of the buddy window, so change the
|
|
|
|
* caption of the buddy window then call UDM_GETPOS
|
|
|
|
* - check UDM_SETRANGE, max can be less than min, so clicking the up arrow decreases the current position
|
|
|
|
* - more stuff to test
|
|
|
|
*/
|
|
|
|
|
2005-03-16 20:52:40 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
2007-02-18 00:27:05 +01:00
|
|
|
#include "msg.h"
|
2005-03-16 20:52:40 +01:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
#define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
|
|
|
|
|
2007-01-10 04:27:36 +01:00
|
|
|
#define NUM_MSG_SEQUENCES 3
|
|
|
|
#define PARENT_SEQ_INDEX 0
|
|
|
|
#define EDIT_SEQ_INDEX 1
|
|
|
|
#define UPDOWN_SEQ_INDEX 2
|
|
|
|
|
2009-12-22 19:58:27 +01:00
|
|
|
#define UPDOWN_ID 0
|
|
|
|
#define BUDDY_ID 1
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
static HWND parent_wnd, g_edit;
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-12-21 23:54:06 +01:00
|
|
|
static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
|
|
|
|
|
2007-01-10 04:27:36 +01:00
|
|
|
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
|
|
|
|
|
|
|
|
static const struct message add_updown_with_edit_seq[] = {
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent },
|
|
|
|
{ WM_NCCALCSIZE, sent|wparam, TRUE },
|
|
|
|
{ WM_WINDOWPOSCHANGED, sent },
|
2007-01-20 10:09:43 +01:00
|
|
|
{ WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED /*, MAKELONG(91, 75) exact size depends on font */ },
|
2007-01-10 04:27:36 +01:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message add_updown_to_parent_seq[] = {
|
|
|
|
{ WM_NOTIFYFORMAT, sent|lparam, 0, NF_QUERY },
|
2008-09-08 07:48:43 +02:00
|
|
|
{ WM_QUERYUISTATE, sent|optional },
|
2007-01-10 04:27:36 +01:00
|
|
|
{ WM_PARENTNOTIFY, sent|wparam, MAKELONG(WM_CREATE, WM_CREATE) },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message get_edit_text_seq[] = {
|
|
|
|
{ WM_GETTEXT, sent },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
static const struct message test_updown_pos_seq[] = {
|
|
|
|
{ UDM_SETRANGE, sent|lparam, 0, MAKELONG(100,0) },
|
|
|
|
{ UDM_GETRANGE, sent},
|
|
|
|
{ UDM_SETPOS, sent|lparam, 0, 5},
|
|
|
|
{ UDM_GETPOS, sent},
|
|
|
|
{ UDM_SETPOS, sent|lparam, 0, 0},
|
|
|
|
{ UDM_GETPOS, sent},
|
|
|
|
{ UDM_SETPOS, sent|lparam, 0, MAKELONG(-1,0)},
|
|
|
|
{ UDM_GETPOS, sent},
|
|
|
|
{ UDM_SETPOS, sent|lparam, 0, 100},
|
|
|
|
{ UDM_GETPOS, sent},
|
|
|
|
{ UDM_SETPOS, sent|lparam, 0, 101},
|
|
|
|
{ UDM_GETPOS, sent},
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_updown_pos32_seq[] = {
|
|
|
|
{ UDM_SETRANGE32, sent|lparam, 0, 1000 },
|
|
|
|
{ UDM_GETRANGE32, sent}, /* Cannot check wparam and lparam as they are ptrs */
|
|
|
|
{ UDM_SETPOS32, sent|lparam, 0, 500 },
|
|
|
|
{ UDM_GETPOS32, sent},
|
|
|
|
{ UDM_SETPOS32, sent|lparam, 0, 0 },
|
|
|
|
{ UDM_GETPOS32, sent},
|
|
|
|
{ UDM_SETPOS32, sent|lparam, 0, -1 },
|
|
|
|
{ UDM_GETPOS32, sent},
|
|
|
|
{ UDM_SETPOS32, sent|lparam, 0, 1000 },
|
|
|
|
{ UDM_GETPOS32, sent},
|
|
|
|
{ UDM_SETPOS32, sent|lparam, 0, 1001 },
|
|
|
|
{ UDM_GETPOS32, sent},
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_updown_buddy_seq[] = {
|
|
|
|
{ UDM_GETBUDDY, sent },
|
|
|
|
{ UDM_SETBUDDY, sent },
|
|
|
|
{ WM_STYLECHANGING, sent|defwinproc },
|
|
|
|
{ WM_STYLECHANGED, sent|defwinproc },
|
|
|
|
{ WM_STYLECHANGING, sent|defwinproc },
|
|
|
|
{ WM_STYLECHANGED, sent|defwinproc },
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|defwinproc },
|
|
|
|
{ WM_NCCALCSIZE, sent|wparam|optional|defwinproc, 1 },
|
|
|
|
{ WM_WINDOWPOSCHANGED, sent|defwinproc },
|
|
|
|
{ WM_MOVE, sent|defwinproc },
|
|
|
|
{ UDM_GETBUDDY, sent },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_updown_base_seq[] = {
|
|
|
|
{ UDM_SETBASE, sent|wparam, 10 },
|
|
|
|
{ UDM_GETBASE, sent },
|
|
|
|
{ UDM_SETBASE, sent|wparam, 80 },
|
|
|
|
{ UDM_GETBASE, sent },
|
|
|
|
{ UDM_SETBASE, sent|wparam, 16 },
|
|
|
|
{ UDM_GETBASE, sent },
|
|
|
|
{ UDM_SETBASE, sent|wparam, 80 },
|
|
|
|
{ UDM_GETBASE, sent },
|
|
|
|
{ UDM_SETBASE, sent|wparam, 10 },
|
|
|
|
{ UDM_GETBASE, sent },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message test_updown_unicode_seq[] = {
|
|
|
|
{ UDM_SETUNICODEFORMAT, sent|wparam, 0 },
|
|
|
|
{ UDM_GETUNICODEFORMAT, sent },
|
|
|
|
{ UDM_SETUNICODEFORMAT, sent|wparam, 1 },
|
|
|
|
{ UDM_GETUNICODEFORMAT, sent },
|
|
|
|
{ UDM_SETUNICODEFORMAT, sent|wparam, 0 },
|
|
|
|
{ UDM_GETUNICODEFORMAT, sent },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2009-12-22 19:58:27 +01:00
|
|
|
static const struct message test_updown_pos_nochange_seq[] = {
|
|
|
|
{ WM_GETTEXT, sent|id, 0, 0, BUDDY_ID },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2007-01-10 04:27:36 +01:00
|
|
|
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2005-03-16 20:52:40 +01:00
|
|
|
{
|
2009-04-02 12:04:50 +02:00
|
|
|
static LONG defwndproc_counter = 0;
|
2017-03-29 10:11:39 +02:00
|
|
|
struct message msg = { 0 };
|
2007-01-10 04:27:36 +01:00
|
|
|
LRESULT ret;
|
|
|
|
|
2008-10-01 03:57:27 +02:00
|
|
|
/* log system messages, except for painting */
|
|
|
|
if (message < WM_USER &&
|
|
|
|
message != WM_PAINT &&
|
2007-01-10 04:27:36 +01:00
|
|
|
message != WM_ERASEBKGND &&
|
|
|
|
message != WM_NCPAINT &&
|
|
|
|
message != WM_NCHITTEST &&
|
|
|
|
message != WM_GETTEXT &&
|
|
|
|
message != WM_GETICON &&
|
|
|
|
message != WM_DEVICECHANGE)
|
|
|
|
{
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
2007-02-18 00:27:05 +01:00
|
|
|
add_message(sequences, PARENT_SEQ_INDEX, &msg);
|
2007-01-10 04:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
defwndproc_counter++;
|
|
|
|
ret = DefWindowProcA(hwnd, message, wParam, lParam);
|
|
|
|
defwndproc_counter--;
|
2005-03-16 20:52:40 +01:00
|
|
|
|
2007-01-10 04:27:36 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL register_parent_wnd_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = parent_wnd_proc;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(NULL);
|
|
|
|
cls.hIcon = 0;
|
2013-10-19 22:33:28 +02:00
|
|
|
cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
|
2007-01-10 04:27:36 +01:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "Up-Down test parent class";
|
|
|
|
return RegisterClassA(&cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND create_parent_window(void)
|
|
|
|
{
|
|
|
|
if (!register_parent_wnd_class())
|
|
|
|
return NULL;
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
return CreateWindowExA(0, "Up-Down test parent class",
|
2007-01-10 04:27:36 +01:00
|
|
|
"Up-Down test parent window",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX | WS_VISIBLE,
|
|
|
|
0, 0, 100, 100,
|
|
|
|
GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2009-10-11 14:25:17 +02:00
|
|
|
WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
|
2009-04-02 12:04:50 +02:00
|
|
|
static LONG defwndproc_counter = 0;
|
2017-03-29 10:11:39 +02:00
|
|
|
struct message msg = { 0 };
|
2007-01-10 04:27:36 +01:00
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
2009-12-22 19:58:27 +01:00
|
|
|
msg.id = BUDDY_ID;
|
2007-02-18 00:27:05 +01:00
|
|
|
add_message(sequences, EDIT_SEQ_INDEX, &msg);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
|
|
|
defwndproc_counter++;
|
2009-10-11 14:25:17 +02:00
|
|
|
ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
|
2007-01-10 04:27:36 +01:00
|
|
|
defwndproc_counter--;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-03-10 22:00:47 +01:00
|
|
|
static HWND create_edit_control(void)
|
2007-01-10 04:27:36 +01:00
|
|
|
{
|
2009-10-11 14:25:17 +02:00
|
|
|
WNDPROC oldproc;
|
2009-12-21 22:37:41 +01:00
|
|
|
HWND hwnd;
|
2007-01-10 04:27:36 +01:00
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
GetClientRect(parent_wnd, &rect);
|
2009-12-21 22:37:41 +01:00
|
|
|
hwnd = CreateWindowExA(0, WC_EDITA, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE,
|
2007-01-10 04:27:36 +01:00
|
|
|
0, 0, rect.right, rect.bottom,
|
|
|
|
parent_wnd, NULL, GetModuleHandleA(NULL), NULL);
|
2009-12-21 22:37:41 +01:00
|
|
|
if (!hwnd) return NULL;
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
|
2009-10-11 14:25:17 +02:00
|
|
|
(LONG_PTR)edit_subclass_proc);
|
2009-12-21 22:37:41 +01:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
return hwnd;
|
2007-01-10 04:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2009-10-11 14:25:17 +02:00
|
|
|
WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
|
2009-04-02 12:04:50 +02:00
|
|
|
static LONG defwndproc_counter = 0;
|
2017-03-29 10:11:39 +02:00
|
|
|
struct message msg = { 0 };
|
2007-01-10 04:27:36 +01:00
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
2009-12-22 19:58:27 +01:00
|
|
|
msg.id = UPDOWN_ID;
|
2007-03-14 05:22:03 +01:00
|
|
|
add_message(sequences, UPDOWN_SEQ_INDEX, &msg);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
|
|
|
defwndproc_counter++;
|
2009-10-11 14:25:17 +02:00
|
|
|
ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
|
2007-01-10 04:27:36 +01:00
|
|
|
defwndproc_counter--;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
static HWND create_updown_control(DWORD style, HWND buddy)
|
2007-01-10 04:27:36 +01:00
|
|
|
{
|
2009-10-11 14:25:17 +02:00
|
|
|
WNDPROC oldproc;
|
2007-01-10 04:27:36 +01:00
|
|
|
HWND updown;
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
GetClientRect(parent_wnd, &rect);
|
2009-12-03 09:01:45 +01:00
|
|
|
updown = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | style,
|
2009-12-21 22:37:41 +01:00
|
|
|
0, 0, rect.right, rect.bottom, parent_wnd, 1, GetModuleHandleA(NULL), buddy,
|
2007-01-10 04:27:36 +01:00
|
|
|
100, 0, 50);
|
2009-10-11 14:25:17 +02:00
|
|
|
if (!updown) return NULL;
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-10-11 14:25:17 +02:00
|
|
|
oldproc = (WNDPROC)SetWindowLongPtrA(updown, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)updown_subclass_proc);
|
|
|
|
SetWindowLongPtrA(updown, GWLP_USERDATA, (LONG_PTR)oldproc);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
|
|
|
return updown;
|
|
|
|
}
|
|
|
|
|
2007-02-11 05:37:26 +01:00
|
|
|
static void test_updown_pos(void)
|
|
|
|
{
|
2009-09-19 23:26:10 +02:00
|
|
|
HWND updown;
|
2007-02-11 05:37:26 +01:00
|
|
|
int r;
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Set Range from 0 to 100 */
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETRANGE, 0 , MAKELONG(100,0) );
|
|
|
|
r = SendMessageA(updown, UDM_GETRANGE, 0,0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(100,LOWORD(r));
|
|
|
|
expect(0,HIWORD(r));
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set the position to 5, return is not checked as it was set before func call */
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(5,0) );
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Since UDM_SETBUDDYINT was not set at creation HIWORD(r) will always be 1 as a return from UDM_GETPOS */
|
|
|
|
/* Get the position, which should be 5 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(5,LOWORD(r));
|
|
|
|
expect(1,HIWORD(r));
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set the position to 0, return should be 5 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(0,0) );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(5,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Get the position, which should be 0 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,LOWORD(r));
|
|
|
|
expect(1,HIWORD(r));
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set the position to -1, return should be 0 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(-1,0) );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Get the position, which should be 0 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,LOWORD(r));
|
|
|
|
expect(1,HIWORD(r));
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set the position to 100, return should be 0 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(100,0) );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Get the position, which should be 100 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(100,LOWORD(r));
|
|
|
|
expect(1,HIWORD(r));
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set the position to 101, return should be 100 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0 , MAKELONG(101,0) );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(100,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Get the position, which should be 100 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0 , 0 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(100,LOWORD(r));
|
|
|
|
expect(1,HIWORD(r));
|
2007-03-14 05:22:03 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos_seq , "test updown pos", FALSE);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2009-12-22 19:58:27 +01:00
|
|
|
|
|
|
|
/* there's no attempt to update buddy Edit if text didn't change */
|
|
|
|
SetWindowTextA(g_edit, "50");
|
2013-10-16 16:35:01 +02:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_ARROWKEYS, g_edit);
|
2009-12-22 19:58:27 +01:00
|
|
|
|
2009-12-25 13:03:32 +01:00
|
|
|
/* test sequence only on 5.8x versions */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS32, 0, 0);
|
2009-12-25 13:03:32 +01:00
|
|
|
if (r)
|
|
|
|
{
|
2013-10-16 16:35:01 +02:00
|
|
|
UDACCEL accel;
|
|
|
|
|
2009-12-25 13:03:32 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2009-12-22 19:58:27 +01:00
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0, 50);
|
2009-12-25 13:03:32 +01:00
|
|
|
expect(50,r);
|
|
|
|
|
|
|
|
ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
|
|
|
|
"test updown pos, no change", FALSE);
|
2013-10-16 16:35:01 +02:00
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETRANGE, 0, MAKELONG(1, 40));
|
|
|
|
r = SendMessageA(updown, UDM_GETRANGE, 0, 0);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(1, LOWORD(r));
|
|
|
|
expect(40, HIWORD(r));
|
|
|
|
|
|
|
|
accel.nSec = 0;
|
|
|
|
accel.nInc = 5;
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETACCEL, 1, (LPARAM)&accel);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(TRUE, r);
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(40, LOWORD(r));
|
|
|
|
expect(1, HIWORD(r));
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(0, 0));
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(40, LOWORD(r));
|
|
|
|
expect(0, HIWORD(r));
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(1, LOWORD(r));
|
|
|
|
expect(0, HIWORD(r));
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(2, 0));
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(1, LOWORD(r));
|
|
|
|
expect(0, HIWORD(r));
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(g_edit, WM_KEYDOWN, VK_UP, 0);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(0, r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(1, LOWORD(r));
|
|
|
|
expect(0, HIWORD(r));
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0, MAKELONG(50, 0));
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(1, LOWORD(r));
|
|
|
|
expect(0, HIWORD(r));
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
2013-10-16 16:35:01 +02:00
|
|
|
expect(40, LOWORD(r));
|
|
|
|
expect(0, HIWORD(r));
|
2009-12-25 13:03:32 +01:00
|
|
|
}
|
2009-12-22 19:58:27 +01:00
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2007-02-11 05:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_updown_pos32(void)
|
|
|
|
{
|
2009-09-19 23:26:10 +02:00
|
|
|
HWND updown;
|
2007-02-11 05:37:26 +01:00
|
|
|
int r;
|
|
|
|
int low, high;
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Set the position to 0 to 1000 */
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETRANGE32, 0 , 1000 );
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2009-09-28 23:56:37 +02:00
|
|
|
low = high = -1;
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETRANGE32, (WPARAM) &low , (LPARAM) &high );
|
2011-02-17 03:21:29 +01:00
|
|
|
expect(0,r);
|
2009-09-28 23:56:37 +02:00
|
|
|
if (low == -1)
|
|
|
|
{
|
|
|
|
win_skip("UDM_SETRANGE32/UDM_GETRANGE32 not available\n");
|
|
|
|
DestroyWindow(updown);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,low);
|
|
|
|
expect(1000,high);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2009-06-25 11:49:14 +02:00
|
|
|
/* Set position to 500 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS32, 0 , 500 );
|
2009-06-25 11:49:14 +02:00
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
win_skip("UDM_SETPOS32 and UDM_GETPOS32 need 5.80\n");
|
2009-09-28 23:56:37 +02:00
|
|
|
DestroyWindow(updown);
|
2009-06-25 11:49:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2009-09-19 23:26:10 +02:00
|
|
|
expect(50,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Since UDM_SETBUDDYINT was not set at creation bRet will always be true as a return from UDM_GETPOS32 */
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(500,r);
|
|
|
|
expect(1,high);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set position to 0, return should be 500 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS32, 0 , 0 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(500,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
|
|
|
expect(1,high);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
/* Set position to -1 which should become 0, return should be 0 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS32, 0 , -1 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
|
|
|
expect(1,high);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set position to 1000, return should be 0 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS32, 0 , 1000 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(1000,r);
|
|
|
|
expect(1,high);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
/* Set position to 1001 which should become 1000, return should be 1000 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS32, 0 , 1001 );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(1000,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETPOS32, 0 , (LPARAM) &high );
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(1000,r);
|
|
|
|
expect(1,high);
|
2007-03-14 05:22:03 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_pos32_seq, "test updown pos32", FALSE);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2009-12-22 19:58:27 +01:00
|
|
|
|
|
|
|
/* there's no attempt to update buddy Edit if text didn't change */
|
|
|
|
SetWindowTextA(g_edit, "50");
|
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT | UDS_SETBUDDYINT, g_edit);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS32, 0, 50);
|
2009-12-22 19:58:27 +01:00
|
|
|
expect(50,r);
|
|
|
|
ok_sequence(sequences, EDIT_SEQ_INDEX, test_updown_pos_nochange_seq,
|
|
|
|
"test updown pos, no change", FALSE);
|
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2007-02-11 05:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_updown_buddy(void)
|
|
|
|
{
|
2009-12-21 23:54:06 +01:00
|
|
|
HWND updown, buddyReturn, buddy;
|
|
|
|
WNDPROC proc;
|
|
|
|
DWORD style;
|
2009-09-19 23:26:10 +02:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0 , 0 );
|
2009-12-21 22:37:41 +01:00
|
|
|
ok(buddyReturn == g_edit, "Expected edit handle\n");
|
2007-03-14 05:22:03 +01:00
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, (WPARAM) g_edit, 0);
|
2009-12-21 22:37:41 +01:00
|
|
|
ok(buddyReturn == g_edit, "Expected edit handle\n");
|
2007-03-14 05:22:03 +01:00
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0 , 0 );
|
2009-12-21 22:37:41 +01:00
|
|
|
ok(buddyReturn == g_edit, "Expected edit handle\n");
|
2007-03-14 05:22:03 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_buddy_seq, "test updown buddy", TRUE);
|
|
|
|
ok_sequence(sequences, EDIT_SEQ_INDEX, add_updown_with_edit_seq, "test updown buddy_edit", FALSE);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2009-12-21 23:54:06 +01:00
|
|
|
|
|
|
|
buddy = create_edit_control();
|
|
|
|
proc = (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC);
|
|
|
|
|
|
|
|
updown= create_updown_control(UDS_ALIGNRIGHT, buddy);
|
|
|
|
ok(proc == (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC), "No subclassing expected\n");
|
|
|
|
|
|
|
|
style = GetWindowLongA(updown, GWL_STYLE);
|
|
|
|
SetWindowLongA(updown, GWL_STYLE, style | UDS_ARROWKEYS);
|
|
|
|
style = GetWindowLongA(updown, GWL_STYLE);
|
|
|
|
ok(style & UDS_ARROWKEYS, "Expected UDS_ARROWKEYS\n");
|
|
|
|
/* no subclass if UDS_ARROWKEYS set after creation */
|
|
|
|
ok(proc == (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC), "No subclassing expected\n");
|
|
|
|
|
|
|
|
DestroyWindow(updown);
|
|
|
|
|
|
|
|
updown= create_updown_control(UDS_ALIGNRIGHT | UDS_ARROWKEYS, buddy);
|
|
|
|
ok(proc != (WNDPROC)GetWindowLongPtrA(buddy, GWLP_WNDPROC), "Subclassing expected\n");
|
|
|
|
|
|
|
|
if (pSetWindowSubclass)
|
|
|
|
{
|
|
|
|
/* updown uses subclass helpers for buddy on >5.8x systems */
|
2009-12-22 00:42:31 +01:00
|
|
|
ok(GetPropA(buddy, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
|
2009-12-21 23:54:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(updown);
|
|
|
|
|
|
|
|
DestroyWindow(buddy);
|
2007-02-11 05:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_updown_base(void)
|
|
|
|
{
|
2009-09-19 23:26:10 +02:00
|
|
|
HWND updown;
|
2007-02-11 05:37:26 +01:00
|
|
|
int r;
|
2009-09-20 11:58:12 +02:00
|
|
|
CHAR text[10];
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETBASE, 10 , 0);
|
|
|
|
r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(10,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set base to an invalid value, should return 0 and stay at 10 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETBASE, 80 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(10,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set base to 16 now, should get 16 as the return */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETBASE, 16 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(10,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(16,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set base to an invalid value, should return 0 and stay at 16 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETBASE, 80 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(16,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Set base back to 10, return should be 16 */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETBASE, 10 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(16,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETBASE, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(10,r);
|
2007-03-14 05:22:03 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_base_seq, "test updown base", FALSE);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2009-09-20 11:58:12 +02:00
|
|
|
|
|
|
|
/* switch base with buddy attached */
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);
|
2009-09-20 11:58:12 +02:00
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETPOS, 0, 10);
|
2009-09-20 11:58:12 +02:00
|
|
|
expect(50, r);
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
|
2009-09-20 11:58:12 +02:00
|
|
|
ok(lstrcmpA(text, "10") == 0, "Expected '10', got '%s'\n", text);
|
|
|
|
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETBASE, 16, 0);
|
2009-09-20 11:58:12 +02:00
|
|
|
expect(10, r);
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
|
2009-09-20 11:58:12 +02:00
|
|
|
/* FIXME: currently hex output isn't properly formatted, but for this
|
|
|
|
test only change from initial text matters */
|
2009-09-20 12:05:18 +02:00
|
|
|
ok(lstrcmpA(text, "10") != 0, "Expected '0x000A', got '%s'\n", text);
|
2009-09-20 11:58:12 +02:00
|
|
|
|
|
|
|
DestroyWindow(updown);
|
2007-02-11 05:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_updown_unicode(void)
|
|
|
|
{
|
2009-09-19 23:26:10 +02:00
|
|
|
HWND updown;
|
2007-02-11 05:37:26 +01:00
|
|
|
int r;
|
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2009-09-19 23:26:10 +02:00
|
|
|
|
2007-03-14 05:22:03 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2007-02-11 05:37:26 +01:00
|
|
|
/* Set it to ANSI, don't check return as we don't know previous state */
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETUNICODEFORMAT, 0 , 0);
|
|
|
|
r = SendMessageA(updown, UDM_GETUNICODEFORMAT, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* Now set it to Unicode format */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETUNICODEFORMAT, 1 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETUNICODEFORMAT, 0 , 0);
|
2009-09-28 23:56:37 +02:00
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
win_skip("UDM_SETUNICODEFORMAT not available\n");
|
|
|
|
DestroyWindow(updown);
|
|
|
|
return;
|
|
|
|
}
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(1,r);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
|
|
|
/* And now set it back to ANSI */
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_SETUNICODEFORMAT, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(1,r);
|
2013-10-19 22:33:28 +02:00
|
|
|
r = SendMessageA(updown, UDM_GETUNICODEFORMAT, 0 , 0);
|
2007-03-14 05:22:03 +01:00
|
|
|
expect(0,r);
|
2007-03-14 05:22:03 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, UPDOWN_SEQ_INDEX, test_updown_unicode_seq, "test updown unicode", FALSE);
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2009-09-19 23:26:10 +02:00
|
|
|
DestroyWindow(updown);
|
|
|
|
}
|
2007-02-11 05:37:26 +01:00
|
|
|
|
2009-09-19 23:26:10 +02:00
|
|
|
static void test_updown_create(void)
|
2007-01-10 04:27:36 +01:00
|
|
|
{
|
|
|
|
CHAR text[MAX_PATH];
|
2009-09-19 23:26:10 +02:00
|
|
|
HWND updown;
|
2009-12-03 11:38:27 +01:00
|
|
|
RECT r;
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2007-02-18 00:27:05 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2007-01-10 04:27:36 +01:00
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
2007-02-18 00:27:05 +01:00
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, add_updown_to_parent_seq, "add updown control to parent", TRUE);
|
|
|
|
ok_sequence(sequences, EDIT_SEQ_INDEX, add_updown_with_edit_seq, "add updown control with edit", FALSE);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2007-02-18 00:27:05 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
GetWindowTextA(g_edit, text, MAX_PATH);
|
2007-01-10 04:27:36 +01:00
|
|
|
ok(lstrlenA(text) == 0, "Expected empty string\n");
|
2007-02-18 00:27:05 +01:00
|
|
|
ok_sequence(sequences, EDIT_SEQ_INDEX, get_edit_text_seq, "get edit text", FALSE);
|
2007-01-10 04:27:36 +01:00
|
|
|
|
2009-09-19 23:26:10 +02:00
|
|
|
DestroyWindow(updown);
|
2009-12-03 11:38:27 +01:00
|
|
|
|
|
|
|
/* create with zero width */
|
|
|
|
updown = CreateWindowA (UPDOWN_CLASSA, 0, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 0,
|
|
|
|
parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
|
|
|
r.right = 0;
|
|
|
|
GetClientRect(updown, &r);
|
|
|
|
ok(r.right > 0, "Expected default width, got %d\n", r.right);
|
|
|
|
DestroyWindow(updown);
|
|
|
|
/* create with really small width */
|
|
|
|
updown = CreateWindowA (UPDOWN_CLASSA, 0, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 2, 0,
|
|
|
|
parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
|
|
|
r.right = 0;
|
|
|
|
GetClientRect(updown, &r);
|
|
|
|
ok(r.right != 2 && r.right > 0, "Expected default width, got %d\n", r.right);
|
|
|
|
DestroyWindow(updown);
|
|
|
|
/* create with width greater than default */
|
|
|
|
updown = CreateWindowA (UPDOWN_CLASSA, 0, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 100, 0,
|
|
|
|
parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
|
|
|
r.right = 0;
|
|
|
|
GetClientRect(updown, &r);
|
|
|
|
ok(r.right < 100 && r.right > 0, "Expected default width, got %d\n", r.right);
|
|
|
|
DestroyWindow(updown);
|
|
|
|
/* create with zero height, UDS_HORZ */
|
|
|
|
updown = CreateWindowA (UPDOWN_CLASSA, 0, UDS_HORZ | WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 0,
|
|
|
|
parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
|
|
|
r.bottom = 0;
|
|
|
|
GetClientRect(updown, &r);
|
|
|
|
ok(r.bottom == 0, "Expected zero height, got %d\n", r.bottom);
|
|
|
|
DestroyWindow(updown);
|
|
|
|
/* create with really small height, UDS_HORZ */
|
|
|
|
updown = CreateWindowA (UPDOWN_CLASSA, 0, UDS_HORZ | WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 2,
|
|
|
|
parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
|
|
|
r.bottom = 0;
|
|
|
|
GetClientRect(updown, &r);
|
|
|
|
ok(r.bottom == 0, "Expected zero height, got %d\n", r.bottom);
|
|
|
|
DestroyWindow(updown);
|
|
|
|
/* create with height greater than default, UDS_HORZ */
|
|
|
|
updown = CreateWindowA (UPDOWN_CLASSA, 0, UDS_HORZ | WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 0, 100,
|
|
|
|
parent_wnd, (HMENU)(DWORD_PTR)1, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(updown != NULL, "Failed to create updown control\n");
|
|
|
|
r.bottom = 0;
|
|
|
|
GetClientRect(updown, &r);
|
|
|
|
ok(r.bottom < 100 && r.bottom > 0, "Expected default height, got %d\n", r.bottom);
|
|
|
|
DestroyWindow(updown);
|
2007-01-10 04:27:36 +01:00
|
|
|
}
|
|
|
|
|
2009-09-20 00:52:39 +02:00
|
|
|
static void test_UDS_SETBUDDYINT(void)
|
|
|
|
{
|
|
|
|
HWND updown;
|
|
|
|
DWORD style, ret;
|
|
|
|
CHAR text[10];
|
|
|
|
|
2009-09-20 11:58:12 +02:00
|
|
|
/* cleanup buddy */
|
|
|
|
text[0] = '\0';
|
2009-12-21 22:37:41 +01:00
|
|
|
SetWindowTextA(g_edit, text);
|
2009-09-20 11:58:12 +02:00
|
|
|
|
2009-09-20 00:52:39 +02:00
|
|
|
/* creating without UDS_SETBUDDYINT */
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
|
2009-09-20 00:52:39 +02:00
|
|
|
/* try to set UDS_SETBUDDYINT after creation */
|
|
|
|
style = GetWindowLongA(updown, GWL_STYLE);
|
|
|
|
SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
|
|
|
|
style = GetWindowLongA(updown, GWL_STYLE);
|
|
|
|
ok(style & UDS_SETBUDDYINT, "Expected UDS_SETBUDDY to be set\n");
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETPOS, 0, 20);
|
2009-12-21 22:37:41 +01:00
|
|
|
GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
|
2009-09-20 01:57:09 +02:00
|
|
|
ok(lstrlenA(text) == 0, "Expected empty string\n");
|
2009-09-20 00:52:39 +02:00
|
|
|
DestroyWindow(updown);
|
|
|
|
|
|
|
|
/* creating with UDS_SETBUDDYINT */
|
2009-12-21 22:37:41 +01:00
|
|
|
updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);
|
|
|
|
GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
|
2009-09-20 01:57:09 +02:00
|
|
|
/* 50 is initial value here */
|
2009-09-20 00:52:39 +02:00
|
|
|
ok(lstrcmpA(text, "50") == 0, "Expected '50', got '%s'\n", text);
|
|
|
|
/* now remove style flag */
|
|
|
|
style = GetWindowLongA(updown, GWL_STYLE);
|
|
|
|
SetWindowLongA(updown, GWL_STYLE, style & ~UDS_SETBUDDYINT);
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETPOS, 0, 20);
|
2009-12-21 22:37:41 +01:00
|
|
|
GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
|
2009-09-20 01:57:09 +02:00
|
|
|
ok(lstrcmpA(text, "20") == 0, "Expected '20', got '%s'\n", text);
|
2009-09-20 00:52:39 +02:00
|
|
|
/* set edit text directly, check position */
|
|
|
|
strcpy(text, "10");
|
2009-12-21 22:37:41 +01:00
|
|
|
SetWindowTextA(g_edit, text);
|
2009-09-25 15:13:55 +02:00
|
|
|
ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
2009-09-20 01:57:09 +02:00
|
|
|
expect(10, ret);
|
|
|
|
strcpy(text, "11");
|
2009-12-21 22:37:41 +01:00
|
|
|
SetWindowTextA(g_edit, text);
|
2009-09-20 01:57:09 +02:00
|
|
|
ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
|
|
|
expect(11, LOWORD(ret));
|
|
|
|
expect(0, HIWORD(ret));
|
|
|
|
/* set to invalid value */
|
|
|
|
strcpy(text, "21st");
|
2009-12-21 22:37:41 +01:00
|
|
|
SetWindowTextA(g_edit, text);
|
2009-09-25 15:13:55 +02:00
|
|
|
ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
|
|
|
|
expect(11, LOWORD(ret));
|
|
|
|
expect(TRUE, HIWORD(ret));
|
2009-09-20 00:52:39 +02:00
|
|
|
/* set style back */
|
|
|
|
style = GetWindowLongA(updown, GWL_STYLE);
|
|
|
|
SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
|
2013-10-19 22:33:28 +02:00
|
|
|
SendMessageA(updown, UDM_SETPOS, 0, 30);
|
2009-12-21 22:37:41 +01:00
|
|
|
GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
|
2009-09-20 00:52:39 +02:00
|
|
|
ok(lstrcmpA(text, "30") == 0, "Expected '30', got '%s'\n", text);
|
|
|
|
DestroyWindow(updown);
|
|
|
|
}
|
|
|
|
|
2007-01-10 04:27:36 +01:00
|
|
|
START_TEST(updown)
|
|
|
|
{
|
2009-12-21 23:54:06 +01:00
|
|
|
HMODULE mod = GetModuleHandleA("comctl32.dll");
|
|
|
|
|
|
|
|
pSetWindowSubclass = (void*)GetProcAddress(mod, (LPSTR)410);
|
|
|
|
|
2005-03-16 20:52:40 +01:00
|
|
|
InitCommonControls();
|
2007-02-18 00:27:05 +01:00
|
|
|
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
|
2005-03-16 20:52:40 +01:00
|
|
|
|
2009-09-19 23:26:10 +02:00
|
|
|
parent_wnd = create_parent_window();
|
|
|
|
ok(parent_wnd != NULL, "Failed to create parent window!\n");
|
2009-12-21 22:37:41 +01:00
|
|
|
g_edit = create_edit_control();
|
|
|
|
ok(g_edit != NULL, "Failed to create edit control\n");
|
2009-09-19 23:26:10 +02:00
|
|
|
|
|
|
|
test_updown_create();
|
|
|
|
test_updown_pos();
|
|
|
|
test_updown_pos32();
|
|
|
|
test_updown_buddy();
|
|
|
|
test_updown_base();
|
|
|
|
test_updown_unicode();
|
2009-09-20 00:52:39 +02:00
|
|
|
test_UDS_SETBUDDYINT();
|
2009-09-19 23:26:10 +02:00
|
|
|
|
2009-12-21 22:37:41 +01:00
|
|
|
DestroyWindow(g_edit);
|
2009-09-19 23:26:10 +02:00
|
|
|
DestroyWindow(parent_wnd);
|
2005-03-16 20:52:40 +01:00
|
|
|
}
|