Commit 73ee2a8b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

user32: Select text control content while setting dialog focus.

parent 09b14675
......@@ -707,7 +707,11 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
focus = GetNextDlgTabItem( hwnd, 0, FALSE );
if (!focus) focus = GetNextDlgGroupItem( hwnd, 0, FALSE );
if (focus)
{
if (SendMessageW( focus, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL)
SendMessageW( focus, EM_SETSEL, 0, MAXLONG );
SetFocus( focus );
}
}
}
......
......@@ -786,7 +786,8 @@ static INT_PTR CALLBACK focusDlgWinProc (HWND hDlg, UINT uiMsg, WPARAM wParam,
switch (uiMsg)
{
case WM_INITDIALOG:
return TRUE;
SetWindowTextA(GetDlgItem(hDlg, 200), "new caption");
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == 200)
......@@ -958,6 +959,34 @@ static void test_focus(void)
DestroyWindow(hDlg);
}
/* Test 5:
* Select textbox's text on creation */
{
HWND hDlg;
HRSRC hResource;
HANDLE hTemplate;
DLGTEMPLATE* pTemplate;
HWND edit;
DWORD selectionStart = 0xdead, selectionEnd = 0xbeef;
hResource = FindResourceA(g_hinst,"FOCUS_TEST_DIALOG_3", (LPCSTR)RT_DIALOG);
hTemplate = LoadResource(g_hinst, hResource);
pTemplate = LockResource(hTemplate);
hDlg = CreateDialogIndirectParamA(g_hinst, pTemplate, NULL, focusDlgWinProc, 0);
ok(hDlg != 0, "Failed to create test dialog.\n");
edit = GetDlgItem(hDlg, 200);
ok(GetFocus() == edit, "Focus not set to edit, focus=%p, dialog=%p, edit=%p\n",
GetFocus(), hDlg, edit);
SendMessageA(edit, EM_GETSEL, (WPARAM)&selectionStart, (LPARAM)&selectionEnd);
ok(selectionStart == 0 && selectionEnd == 11,
"Text selection after WM_SETFOCUS is [%i, %i) expected [0, 11)\n",
selectionStart, selectionEnd);
DestroyWindow(hDlg);
}
}
static void test_GetDlgItemText(void)
......
......@@ -107,6 +107,14 @@ FONT 8, "MS Shell Dlg"
LTEXT "Hello world", 200,4,4,50,14
}
FOCUS_TEST_DIALOG_3 DIALOG 0, 0, 60, 30
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Test dialog"
FONT 8, "MS Shell Dlg"
{
EDITTEXT 200,4,4,50,14
}
IDD_DIALOG DIALOG 0, 0, 186, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
......
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