Commit eaee84f4 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/updown: Set width to default value on creation.

parent b2d89f48
......@@ -559,6 +559,7 @@ static void test_updown_create(void)
{
CHAR text[MAX_PATH];
HWND updown;
RECT r;
flush_sequences(sequences, NUM_MSG_SEQUENCES);
......@@ -574,6 +575,55 @@ static void test_updown_create(void)
ok_sequence(sequences, EDIT_SEQ_INDEX, get_edit_text_seq, "get edit text", FALSE);
DestroyWindow(updown);
/* 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);
}
static void test_UDS_SETBUDDYINT(void)
......
......@@ -71,7 +71,7 @@ typedef struct
#define AUTOPRESS_DELAY 250 /* time to keep arrow pressed on KEY_DOWN */
#define REPEAT_DELAY 50 /* delay between auto-increments */
#define DEFAULT_WIDTH 14 /* default width of the ctrl */
#define DEFAULT_WIDTH 16 /* default width of the ctrl */
#define DEFAULT_XSEP 0 /* default separation between buddy and ctrl */
#define DEFAULT_ADDTOP 0 /* amount to extend above the buddy window */
#define DEFAULT_ADDBOT 0 /* amount to extend below the buddy window */
......@@ -200,7 +200,7 @@ static void UPDOWN_GetArrowRect (const UPDOWN_INFO* infoPtr, RECT *rect, int arr
/* now figure out if we need a space away from the buddy */
if (IsWindow(infoPtr->Buddy) ) {
if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= spacer;
else rect->left += spacer;
else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) rect->left += spacer;
}
/*
......@@ -854,13 +854,16 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
switch(message)
{
case WM_CREATE:
{
CREATESTRUCTW *pcs = (CREATESTRUCTW*)lParam;
infoPtr = Alloc (sizeof(UPDOWN_INFO));
SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
/* initialize the info struct */
infoPtr->Self = hwnd;
infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent;
infoPtr->dwStyle = ((LPCREATESTRUCTW)lParam)->style;
infoPtr->Notify = pcs->hwndParent;
infoPtr->dwStyle = pcs->style;
infoPtr->AccelCount = 0;
infoPtr->AccelVect = 0;
infoPtr->AccelIndex = -1;
......@@ -872,6 +875,9 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER);
if (!(infoPtr->dwStyle & UDS_HORZ))
SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy,
SWP_NOOWNERZORDER | SWP_NOMOVE);
/* Do we pick the buddy win ourselves? */
if (infoPtr->dwStyle & UDS_AUTOBUDDY)
......@@ -880,6 +886,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L
OpenThemeData (hwnd, themeClass);
TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
}
break;
case WM_DESTROY:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment