Hirofumi Katayama : comctl32/ipaddress: Focus first field on WM_SETFOCUS.

Alexandre Julliard julliard at winehq.org
Tue Mar 23 15:07:42 CDT 2021


Module: wine
Branch: oldstable
Commit: a16032898d25dc0869eac748a2bf4a3249d01a58
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a16032898d25dc0869eac748a2bf4a3249d01a58

Author: Hirofumi Katayama <katayama.hirofumi.mz at gmail.com>
Date:   Thu Oct  8 17:03:27 2020 +0300

comctl32/ipaddress: Focus first field on WM_SETFOCUS.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49924
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 3c291085235b57bb1f2ef92ccde4ca8035928a1b)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 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 7c69d4ec01f..e8632d2dae3 100644
--- a/dlls/comctl32/ipaddress.c
+++ b/dlls/comctl32/ipaddress.c
@@ -638,6 +638,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 5a5aafe7aa8..6e6512514d9 100644
--- a/dlls/comctl32/tests/ipaddress.c
+++ b/dlls/comctl32/tests/ipaddress.c
@@ -114,6 +114,37 @@ todo_wine
     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;
@@ -121,12 +152,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);
 }




More information about the wine-cvs mailing list