Nikolay Sivov : comctl32/ipaddress: Select field contents on IPM_SETFOCUS.

Alexandre Julliard julliard at winehq.org
Thu Oct 8 15:20:06 CDT 2020


Module: wine
Branch: master
Commit: 6f8957156e4207cbce33be76eef7291c70075810
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6f8957156e4207cbce33be76eef7291c70075810

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Oct  8 17:03:25 2020 +0300

comctl32/ipaddress: Select field contents on IPM_SETFOCUS.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 c75a108565..d415a96fb7 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 cc79b7bf11..5a5aafe7aa 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);
 }




More information about the wine-cvs mailing list