Commit ba7207cb authored by Louis Lenders's avatar Louis Lenders Committed by Alexandre Julliard

user32: Fix error return values in DialogBoxParam + simple test.

parent ee3ac7a8
...@@ -800,11 +800,11 @@ INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name, ...@@ -800,11 +800,11 @@ INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
HRSRC hrsrc; HRSRC hrsrc;
LPCDLGTEMPLATEA ptr; LPCDLGTEMPLATEA ptr;
if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return 0; if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return -1;
if (!(ptr = (LPCDLGTEMPLATEA)LoadResource(hInst, hrsrc))) return 0; if (!(ptr = (LPCDLGTEMPLATEA)LoadResource(hInst, hrsrc))) return -1;
hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, TRUE ); hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, TRUE );
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
return -1; return 0;
} }
...@@ -818,11 +818,11 @@ INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name, ...@@ -818,11 +818,11 @@ INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
HRSRC hrsrc; HRSRC hrsrc;
LPCDLGTEMPLATEW ptr; LPCDLGTEMPLATEW ptr;
if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return 0; if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return -1;
if (!(ptr = (LPCDLGTEMPLATEW)LoadResource(hInst, hrsrc))) return 0; if (!(ptr = (LPCDLGTEMPLATEW)LoadResource(hInst, hrsrc))) return -1;
hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, TRUE ); hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, TRUE );
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
return -1; return 0;
} }
......
...@@ -861,6 +861,20 @@ static void test_GetDlgItemText(void) ...@@ -861,6 +861,20 @@ static void test_GetDlgItemText(void)
ok(string[0] == '\0', "string retrieved using GetDlgItemText should have been NULL terminated\n"); ok(string[0] == '\0', "string retrieved using GetDlgItemText should have been NULL terminated\n");
} }
static void test_DialogBoxParamA(void)
{
int ret;
HWND hwnd_invalid = (HWND)0x4444;
SetLastError(0xdeadbeef);
ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG" , hwnd_invalid, 0 , 0);
ok(0 == ret, "DialogBoxParamA returned %d, expected 0\n", ret);
ok(ERROR_INVALID_WINDOW_HANDLE == GetLastError(),"got %d, expected ERROR_INVALID_WINDOW_HANDLE\n",GetLastError());
SetLastError(0xdeadbeef);
ret = DialogBoxParamA(GetModuleHandle(NULL), "RESOURCE_INVALID" , 0, 0, 0);
ok(-1 == ret, "DialogBoxParamA returned %d, expected -1\n", ret);
ok(ERROR_RESOURCE_NAME_NOT_FOUND == GetLastError(),"got %d, expected ERROR_RESOURCE_NAME_NOT_FOUND\n",GetLastError());
}
START_TEST(dialog) START_TEST(dialog)
{ {
...@@ -873,4 +887,5 @@ START_TEST(dialog) ...@@ -873,4 +887,5 @@ START_TEST(dialog)
WM_NEXTDLGCTLTest(); WM_NEXTDLGCTLTest();
InitialFocusTest(); InitialFocusTest();
test_GetDlgItemText(); test_GetDlgItemText();
test_DialogBoxParamA();
} }
...@@ -80,6 +80,15 @@ FONT 8, "MS Shell Dlg" ...@@ -80,6 +80,15 @@ FONT 8, "MS Shell Dlg"
EDITTEXT 200,4,4,50,14 EDITTEXT 200,4,4,50,14
} }
IDD_DIALOG DIALOG DISCARDABLE 0, 0, 186, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
END
/* BINRES test_mono.bmp */ /* BINRES test_mono.bmp */
100 BITMAP test_mono.bmp 100 BITMAP test_mono.bmp
/* { /* {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment