Nikolay Sivov : user32/dialog: Fix setting negative dialog item ids.

Alexandre Julliard julliard at winehq.org
Wed May 15 14:32:19 CDT 2019


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Jan 24 11:52:01 2019 +0300

user32/dialog: Fix setting negative dialog item ids.

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

---

 dlls/user32/dialog.c          |  4 ++--
 dlls/user32/tests/dialog.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 dlls/user32/tests/resource.rc |  9 +++++++++
 dlls/user32/user_private.h    |  1 +
 4 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 72e6eee..deaeb84 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -131,8 +131,8 @@ static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
 
     if (dialogEx)
     {
-        /* id is a DWORD for DIALOGEX */
-        info->id = GET_DWORD(p);
+        /* id is 4 bytes for DIALOGEX */
+        info->id = GET_LONG(p);
         p += 2;
     }
     else
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index 8c9bd21..070ddce 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -1181,9 +1181,47 @@ static void test_GetDlgItemText(void)
        "string retrieved using GetDlgItemText should have been NULL terminated\n");
 }
 
+static INT_PTR CALLBACK getdlgitem_test_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    if (msg == WM_INITDIALOG)
+    {
+        char text[64];
+        LONG_PTR val;
+        HWND hwnd;
+        BOOL ret;
+
+        hwnd = GetDlgItem(hdlg, -1);
+        ok(hwnd != NULL, "Expected dialog item.\n");
+
+        *text = 0;
+        ret = GetDlgItemTextA(hdlg, -1, text, ARRAY_SIZE(text));
+        ok(ret && !strcmp(text, "Text1"), "Unexpected item text.\n");
+
+        val = GetWindowLongA(hwnd, GWLP_ID);
+        ok(val == -1, "Unexpected id.\n");
+
+        val = GetWindowLongPtrA(hwnd, GWLP_ID);
+        ok(val == -1, "Unexpected id %ld.\n", val);
+
+        hwnd = GetDlgItem(hdlg, -2);
+        ok(hwnd != NULL, "Expected dialog item.\n");
+
+        val = GetWindowLongA(hwnd, GWLP_ID);
+        ok(val == -2, "Unexpected id.\n");
+
+        val = GetWindowLongPtrA(hwnd, GWLP_ID);
+        ok(val == -2, "Unexpected id %ld.\n", val);
+
+        EndDialog(hdlg, 0xdead);
+    }
+
+    return FALSE;
+}
+
 static void test_GetDlgItem(void)
 {
     HWND hwnd, child1, child2, hwnd2;
+    INT_PTR retval;
     BOOL ret;
 
     hwnd = CreateWindowA("button", "parent", WS_VISIBLE, 0, 0, 100, 100, NULL, 0, g_hinst, NULL);
@@ -1230,6 +1268,9 @@ static void test_GetDlgItem(void)
     DestroyWindow(child1);
     DestroyWindow(child2);
     DestroyWindow(hwnd);
+
+    retval = DialogBoxParamA(g_hinst, "GETDLGITEM_TEST_DIALOG", NULL, getdlgitem_test_dialog_proc, 0);
+    ok(retval == 0xdead, "Unexpected return value.\n");
 }
 
 static INT_PTR CALLBACK DestroyDlgWinProc (HWND hDlg, UINT uiMsg,
diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc
index 3823ed3..4301af6 100644
--- a/dlls/user32/tests/resource.rc
+++ b/dlls/user32/tests/resource.rc
@@ -237,6 +237,15 @@ FONT 8, "MS Sans Serif"
     CONTROL "oddlengthtext", -1, "TESTCONTROL", WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP, 10,60,100,50 { 1,2,3,4,5 }
 }
 
+GETDLGITEM_TEST_DIALOG DIALOGEX 6, 15, 207, 111
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Test Dialog"
+FONT 8, "MS Shell Dlg"
+{
+    LTEXT "Text1",-1,10,10,100,50
+    LTEXT "Text2",-2,10,10,100,50
+}
+
 /* @makedep: test_mono.bmp */
 100 BITMAP test_mono.bmp
 
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index bf02ee5..514cf67 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -33,6 +33,7 @@
 
 #define GET_WORD(ptr)  (*(const WORD *)(ptr))
 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
+#define GET_LONG(ptr) (*(const LONG *)(ptr))
 
 #define WM_SYSTIMER	    0x0118
 #define WM_POPUPSYSTEMMENU  0x0313




More information about the wine-cvs mailing list