user32: fix return value in DialogBoxParamA if no resource can be
found + simple test
Louis. Lenders
xerox_xerox2000 at yahoo.co.uk
Sat Dec 23 15:04:54 CST 2006
Skipped content of type multipart/alternative-------------- next part --------------
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 7d64790..10f3c32 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -800,7 +800,12 @@ INT_PTR WINAPI DialogBoxParamA( HINSTANC
HRSRC hrsrc;
LPCDLGTEMPLATEA ptr;
- if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return 0;
+ if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG )))
+ {
+ SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND);
+ ERR("FindResource %s failed, returning -1\n",debugstr_a(name));
+ return -1;
+ }
if (!(ptr = (LPCDLGTEMPLATEA)LoadResource(hInst, hrsrc))) return 0;
hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, TRUE );
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index eeea474..b322d7c 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -861,6 +861,14 @@ static void test_GetDlgItemText(void)
ok(string[0] == '\0', "string retrieved using GetDlgItemText should have been NULL terminated\n");
}
+static void test_DialogBoxParamA(void)
+{
+ int ret;
+ SetLastError(0xdeadbeef);
+ ret = DialogBoxParamA(GetModuleHandle(NULL), "NAME_DOES_NOT_EXSIST" , NULL, NULL, 0);
+ ok(-1 == ret, "DialogBoxParamA returned %d, expected -1\n", ret);
+ ok(ERROR_RESOURCE_NAME_NOT_FOUND == GetLastError(),"GetLastError returned %d instead of 1814\n",GetLastError());
+}
START_TEST(dialog)
{
@@ -873,4 +881,5 @@ START_TEST(dialog)
WM_NEXTDLGCTLTest();
InitialFocusTest();
test_GetDlgItemText();
+ test_DialogBoxParamA();
}
More information about the wine-patches
mailing list