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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 47a44e6d9c)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Nikolay Sivov 2019-01-24 11:52:01 +03:00 committed by Michael Stefaniuc
parent b357d44e9e
commit ed80f1c4e7
4 changed files with 53 additions and 2 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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