user32: Select text control content while setting dialog focus.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-02-16 14:49:10 +01:00 committed by Alexandre Julliard
parent 09b1467575
commit 73ee2a8b4f
3 changed files with 42 additions and 1 deletions

View File

@ -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 );
}
}
}

View File

@ -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)

View File

@ -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"