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

This commit is contained in:
Louis Lenders 2007-02-14 20:32:35 +00:00 committed by Alexandre Julliard
parent ee3ac7a8fb
commit ba7207cbc0
3 changed files with 30 additions and 6 deletions

View File

@ -800,11 +800,11 @@ INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
HRSRC hrsrc;
LPCDLGTEMPLATEA ptr;
if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return 0;
if (!(ptr = (LPCDLGTEMPLATEA)LoadResource(hInst, hrsrc))) return 0;
if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return -1;
if (!(ptr = (LPCDLGTEMPLATEA)LoadResource(hInst, hrsrc))) return -1;
hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, TRUE );
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
return -1;
return 0;
}
@ -818,11 +818,11 @@ INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
HRSRC hrsrc;
LPCDLGTEMPLATEW ptr;
if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return 0;
if (!(ptr = (LPCDLGTEMPLATEW)LoadResource(hInst, hrsrc))) return 0;
if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return -1;
if (!(ptr = (LPCDLGTEMPLATEW)LoadResource(hInst, hrsrc))) return -1;
hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, TRUE );
if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
return -1;
return 0;
}

View File

@ -861,6 +861,20 @@ 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;
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)
{
@ -873,4 +887,5 @@ START_TEST(dialog)
WM_NEXTDLGCTLTest();
InitialFocusTest();
test_GetDlgItemText();
test_DialogBoxParamA();
}

View File

@ -80,6 +80,15 @@ FONT 8, "MS Shell Dlg"
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 */
100 BITMAP test_mono.bmp
/* {