Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/ipaddress.c | 1 + dlls/comctl32/tests/ipaddress.c | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
diff --git a/dlls/comctl32/ipaddress.c b/dlls/comctl32/ipaddress.c index c75a1085650..d415a96fb74 100644 --- a/dlls/comctl32/ipaddress.c +++ b/dlls/comctl32/ipaddress.c @@ -393,6 +393,7 @@ static void IPADDRESS_SetFocusToField (const IPADDRESS_INFO *infoPtr, INT index)
if (index > 3 || index < 0) index=0;
+ SendMessageW (infoPtr->Part[index].EditHwnd, EM_SETSEL, 0, -1); SetFocus (infoPtr->Part[index].EditHwnd); }
diff --git a/dlls/comctl32/tests/ipaddress.c b/dlls/comctl32/tests/ipaddress.c index cc79b7bf11b..c1be745f258 100644 --- a/dlls/comctl32/tests/ipaddress.c +++ b/dlls/comctl32/tests/ipaddress.c @@ -62,17 +62,71 @@ static void test_get_set_text(void) DestroyWindow(hwnd); }
+struct child_enum +{ + HWND fields[4]; + unsigned int count; +}; + +static BOOL CALLBACK test_child_enum_proc(HWND hwnd, LPARAM param) +{ + struct child_enum *child_enum = (struct child_enum *)param; + char buff[16] = { 0 }; + unsigned int index; + + GetWindowTextA(hwnd, buff, ARRAY_SIZE(buff)); + index = atoi(buff); + ok(index < 4, "Unexpected index.\n"); + if (index < 4) + child_enum->fields[index] = hwnd; + + return ++child_enum->count < 4; +} + +static void test_IPM_SETFOCUS(void) +{ + struct child_enum child_enum = { 0 }; + unsigned int ret, from, to, i; + HWND hwnd; + + hwnd = create_ipaddress_control(); + ok(!!hwnd, "Failed to create control.\n"); + + ret = SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(0, 1, 2, 3)); + ok(ret, "Unexpected return value %u.\n", ret); + + EnumChildWindows(hwnd, test_child_enum_proc, (LPARAM)&child_enum); + ok(child_enum.count == 4, "Unexpected child count %u.\n", child_enum.count); + + for (i = 0; i < 3; ++i) + SendMessageA(child_enum.fields[i], EM_SETSEL, -1, 0); + + SendMessageA(child_enum.fields[0], EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + ok(from == 0 && to == 0, "Unexpected selection %u x %u.\n", from, to); + + ret = SendMessageA(hwnd, IPM_SETFOCUS, 0, 0); +todo_wine + ok(ret, "Unexpected return value %u.\n", ret); + + SendMessageA(child_enum.fields[0], EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + ok(from == 0 && to == 1, "Unexpected selection %u x %u.\n", from, to); + + DestroyWindow(hwnd); +} + START_TEST(ipaddress) { ULONG_PTR cookie; HANDLE ctxt;
test_get_set_text(); + test_IPM_SETFOCUS();
if (!load_v6_module(&cookie, &ctxt)) return;
test_get_set_text(); + test_IPM_SETFOCUS();
unload_v6_module(cookie, ctxt); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/ipaddress.c | 11 ++++++----- dlls/comctl32/tests/ipaddress.c | 1 - 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/comctl32/ipaddress.c b/dlls/comctl32/ipaddress.c index d415a96fb74..d08a2be3fd9 100644 --- a/dlls/comctl32/ipaddress.c +++ b/dlls/comctl32/ipaddress.c @@ -387,14 +387,16 @@ static LRESULT IPADDRESS_SetAddress (const IPADDRESS_INFO *infoPtr, DWORD ip_add }
-static void IPADDRESS_SetFocusToField (const IPADDRESS_INFO *infoPtr, INT index) +static LRESULT IPADDRESS_SetFocusToField (const IPADDRESS_INFO *infoPtr, INT index) { - TRACE("(index=%d)\n", index); + TRACE("%d\n", index);
if (index > 3 || index < 0) index=0;
SendMessageW (infoPtr->Part[index].EditHwnd, EM_SETSEL, 0, -1); SetFocus (infoPtr->Part[index].EditHwnd); + + return 1; }
@@ -624,9 +626,8 @@ IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case IPM_SETRANGE: return IPADDRESS_SetRange (infoPtr, (int)wParam, (WORD)lParam);
- case IPM_SETFOCUS: - IPADDRESS_SetFocusToField (infoPtr, (int)wParam); - break; + case IPM_SETFOCUS: + return IPADDRESS_SetFocusToField (infoPtr, (int)wParam);
case IPM_ISBLANK: return IPADDRESS_IsBlank (infoPtr); diff --git a/dlls/comctl32/tests/ipaddress.c b/dlls/comctl32/tests/ipaddress.c index c1be745f258..e46dab88b7a 100644 --- a/dlls/comctl32/tests/ipaddress.c +++ b/dlls/comctl32/tests/ipaddress.c @@ -105,7 +105,6 @@ static void test_IPM_SETFOCUS(void) ok(from == 0 && to == 0, "Unexpected selection %u x %u.\n", from, to);
ret = SendMessageA(hwnd, IPM_SETFOCUS, 0, 0); -todo_wine ok(ret, "Unexpected return value %u.\n", ret);
SendMessageA(child_enum.fields[0], EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
From: Hirofumi Katayama katayama.hirofumi.mz@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49924 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/ipaddress.c | 4 ++++ dlls/comctl32/tests/ipaddress.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
diff --git a/dlls/comctl32/ipaddress.c b/dlls/comctl32/ipaddress.c index d08a2be3fd9..32816561e3d 100644 --- a/dlls/comctl32/ipaddress.c +++ b/dlls/comctl32/ipaddress.c @@ -632,6 +632,10 @@ IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case IPM_ISBLANK: return IPADDRESS_IsBlank (infoPtr);
+ case WM_SETFOCUS: + IPADDRESS_SetFocusToField (infoPtr, 0); + break; + default: if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg)) ERR("unknown msg %04x wp=%08lx lp=%08lx\n", uMsg, wParam, lParam); diff --git a/dlls/comctl32/tests/ipaddress.c b/dlls/comctl32/tests/ipaddress.c index e46dab88b7a..20e818b86ce 100644 --- a/dlls/comctl32/tests/ipaddress.c +++ b/dlls/comctl32/tests/ipaddress.c @@ -113,6 +113,37 @@ static void test_IPM_SETFOCUS(void) DestroyWindow(hwnd); }
+static void test_WM_SETFOCUS(void) +{ + struct child_enum child_enum = { 0 }; + unsigned int ret, from, to, i; + HWND hwnd; + + hwnd = create_ipaddress_control(); + ok(!!hwnd, "Failed to create control.\n"); + + ret = SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(0, 1, 2, 3)); + ok(ret, "Unexpected return value %u.\n", ret); + + EnumChildWindows(hwnd, test_child_enum_proc, (LPARAM)&child_enum); + ok(child_enum.count == 4, "Unexpected child count %u.\n", child_enum.count); + + SetFocus(child_enum.fields[3]); + + for (i = 0; i < 3; ++i) + SendMessageA(child_enum.fields[i], EM_SETSEL, -1, 0); + + SendMessageA(child_enum.fields[0], EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + ok(from == 0 && to == 0, "Unexpected selection %u x %u.\n", from, to); + + SetFocus(hwnd); + + SendMessageA(child_enum.fields[0], EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + ok(from == 0 && to == 1, "Unexpected selection %u x %u.\n", from, to); + + DestroyWindow(hwnd); +} + START_TEST(ipaddress) { ULONG_PTR cookie; @@ -120,12 +151,14 @@ START_TEST(ipaddress)
test_get_set_text(); test_IPM_SETFOCUS(); + test_WM_SETFOCUS();
if (!load_v6_module(&cookie, &ctxt)) return;
test_get_set_text(); test_IPM_SETFOCUS(); + test_WM_SETFOCUS();
unload_v6_module(cookie, ctxt); }