user32: Ensure that WM_INITDIALOG passes the first tabstop control handle to the dialog procedure.

This commit is contained in:
Andrew Nguyen 2010-02-23 01:16:18 -06:00 committed by Alexandre Julliard
parent 30f6dc9510
commit 0b23012867
2 changed files with 24 additions and 3 deletions

View File

@ -690,11 +690,14 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
if (dlgProc)
{
if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ) &&
HWND focus = GetNextDlgTabItem( hwnd, 0, FALSE );
if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)focus, param ) &&
((~template.style & DS_CONTROL) || (template.style & WS_VISIBLE)))
{
/* By returning TRUE, app has requested a default focus assignment */
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
/* By returning TRUE, app has requested a default focus assignment.
* WM_INITDIALOG may have changed the tab order, so find the first
* tabstop control again. */
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
if( dlgInfo->hwndFocus )
SetFocus( dlgInfo->hwndFocus );
}

View File

@ -926,6 +926,21 @@ static INT_PTR CALLBACK DestroyOnCloseDlgWinProc (HWND hDlg, UINT uiMsg,
return FALSE;
}
static INT_PTR CALLBACK TestInitDialogHandleProc (HWND hDlg, UINT uiMsg,
WPARAM wParam, LPARAM lParam)
{
if (uiMsg == WM_INITDIALOG)
{
HWND expected = GetNextDlgTabItem(hDlg, NULL, FALSE);
ok(expected == (HWND)wParam,
"Expected wParam to be the handle to the first tabstop control (%p), got %p\n",
expected, (HWND)wParam);
EndDialog(hDlg, LOWORD(SendMessage(hDlg, DM_GETDEFID, 0, 0)));
return TRUE;
}
return FALSE;
}
static INT_PTR CALLBACK TestDefButtonDlgProc (HWND hDlg, UINT uiMsg,
WPARAM wParam, LPARAM lParam)
@ -978,6 +993,9 @@ static void test_DialogBoxParamA(void)
broken(GetLastError() == 0xdeadbeef),
"got %d, expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
ret = DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestInitDialogHandleProc, 0);
ok(ret == IDOK, "Expected IDOK\n");
ret = DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestDefButtonDlgProc, 0);
ok(ret == IDOK, "Expected IDOK\n");
}