Commit 0b230128 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

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

parent 30f6dc95
...@@ -690,11 +690,14 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, ...@@ -690,11 +690,14 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
if (dlgProc) 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))) ((~template.style & DS_CONTROL) || (template.style & WS_VISIBLE)))
{ {
/* By returning TRUE, app has requested a default focus assignment */ /* By returning TRUE, app has requested a default focus assignment.
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE); * WM_INITDIALOG may have changed the tab order, so find the first
* tabstop control again. */
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
if( dlgInfo->hwndFocus ) if( dlgInfo->hwndFocus )
SetFocus( dlgInfo->hwndFocus ); SetFocus( dlgInfo->hwndFocus );
} }
......
...@@ -926,6 +926,21 @@ static INT_PTR CALLBACK DestroyOnCloseDlgWinProc (HWND hDlg, UINT uiMsg, ...@@ -926,6 +926,21 @@ static INT_PTR CALLBACK DestroyOnCloseDlgWinProc (HWND hDlg, UINT uiMsg,
return FALSE; 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, static INT_PTR CALLBACK TestDefButtonDlgProc (HWND hDlg, UINT uiMsg,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
...@@ -978,6 +993,9 @@ static void test_DialogBoxParamA(void) ...@@ -978,6 +993,9 @@ static void test_DialogBoxParamA(void)
broken(GetLastError() == 0xdeadbeef), broken(GetLastError() == 0xdeadbeef),
"got %d, expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError()); "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); ret = DialogBoxParamA(GetModuleHandle(NULL), "TEST_EMPTY_DIALOG", 0, TestDefButtonDlgProc, 0);
ok(ret == IDOK, "Expected IDOK\n"); ok(ret == IDOK, "Expected IDOK\n");
} }
......
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