user32: Return 0 from DefDlgProc and dialog loop for invalid dialog handles.

oldstable
Dmitry Timoshkov 2009-08-12 11:59:38 +09:00 committed by Alexandre Julliard
parent 95d3a722ab
commit 96e44ddb78
3 changed files with 18 additions and 9 deletions

View File

@ -345,7 +345,10 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create )
wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return NULL;
}
dlgInfo = wndPtr->dlgInfo;
@ -382,7 +385,7 @@ LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
BOOL result = FALSE;
/* Perform DIALOGINFO initialization if not done */
if(!(dlgInfo = DIALOG_get_info(hwnd32, TRUE))) return -1;
if(!(dlgInfo = DIALOG_get_info(hwnd32, TRUE))) return 0;
SetWindowLongPtrW( hwnd32, DWLP_MSGRESULT, 0 );
@ -433,7 +436,7 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
BOOL result = FALSE;
/* Perform DIALOGINFO initialization if not done */
if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return -1;
if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
@ -484,7 +487,7 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
DLGPROC dlgproc;
/* Perform DIALOGINFO initialization if not done */
if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return -1;
if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );

View File

@ -809,7 +809,7 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
if (!GetMessageW( &msg, 0, 0, 0 )) break;
}
if (!IsWindow( hwnd )) return -1;
if (!IsWindow( hwnd )) return 0;
if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
{
TranslateMessage( &msg );

View File

@ -932,12 +932,12 @@ static INT_PTR CALLBACK DestroyOnCloseDlgWinProc (HWND hDlg, UINT uiMsg,
static void test_DialogBoxParamA(void)
{
int ret;
INT_PTR ret;
HWND hwnd_invalid = (HWND)0x4444;
SetLastError(0xdeadbeef);
ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG" , hwnd_invalid, 0 , 0);
ok(0 == ret || broken(ret == -1), "DialogBoxParamA returned %d, expected 0\n", ret);
ok(0 == ret || broken(ret == -1), "DialogBoxParamA returned %ld, expected 0\n", ret);
ok(ERROR_INVALID_WINDOW_HANDLE == GetLastError() ||
broken(GetLastError() == 0xdeadbeef),
"got %d, expected ERROR_INVALID_WINDOW_HANDLE\n",GetLastError());
@ -945,7 +945,7 @@ static void test_DialogBoxParamA(void)
/* Test a dialog which destroys itself on WM_INITDIALOG. */
SetLastError(0xdeadbeef);
ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG", 0, DestroyDlgWinProc, 0);
ok(-1 == ret, "DialogBoxParamA returned %d, expected -1\n", ret);
ok(-1 == ret, "DialogBoxParamA returned %ld, expected -1\n", ret);
ok(ERROR_INVALID_WINDOW_HANDLE == GetLastError() ||
GetLastError() == ERROR_SUCCESS ||
broken(GetLastError() == 0xdeadbeef),
@ -953,14 +953,20 @@ static void test_DialogBoxParamA(void)
/* Test a dialog which destroys itself on WM_CLOSE. */
ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG", 0, DestroyOnCloseDlgWinProc, 0);
todo_wine ok(0 == ret, "DialogBoxParamA returned %d, expected 0\n", ret);
ok(0 == ret, "DialogBoxParamA returned %ld, expected 0\n", ret);
SetLastError(0xdeadbeef);
ret = DialogBoxParamA(GetModuleHandle(NULL), "RESOURCE_INVALID" , 0, 0, 0);
ok(-1 == ret, "DialogBoxParamA returned %d, expected -1\n", ret);
ok(-1 == ret, "DialogBoxParamA returned %ld, expected -1\n", ret);
ok(ERROR_RESOURCE_NAME_NOT_FOUND == GetLastError() ||
broken(GetLastError() == 0xdeadbeef),
"got %d, expected ERROR_RESOURCE_NAME_NOT_FOUND\n",GetLastError());
SetLastError(0xdeadbeef);
ret = DefDlgProcA(0, WM_ERASEBKGND, 0, 0);
ok(ret == 0, "DefDlgProcA returned %ld, expected 0\n", ret);
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE,
"got %d, expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
}
static void test_DisabledDialogTest(void)