[PATCH] user32/dialog: Fix setting negative dialog item ids.
Nikolay Sivov
nsivov at codeweavers.com
Thu Jan 24 02:52:01 CST 2019
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46494
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 72e6eee02f..deaeb84556 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 8c9bd21482..070ddcebb7 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 3823ed39e4..4301af6d68 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 bf02ee5b0b..514cf6753f 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
--
2.20.1
More information about the wine-devel
mailing list