Enhance Ctrl-F to copy to Find What field behaviour

Fix https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16976#issuecomment-3265850195
This commit is contained in:
Don Ho 2025-09-08 16:15:01 +02:00
parent cfc3fb6cf5
commit d4442b9d15

View File

@ -4050,8 +4050,12 @@ void FindReplaceDlg::setSearchText(wchar_t * txt2find)
if (txt2find && txt2find[0]) if (txt2find && txt2find[0])
{ {
// We got a valid search string // We got a valid search string
::SendMessage(hCombo, CB_SETCURSEL, static_cast<WPARAM>(-1), 0); // remove selection - to allow using down arrow to get to last searched word HWND hEdit = GetWindow(hCombo, GW_CHILD);
::SetDlgItemText(_hSelf, IDFINDWHAT, txt2find); if (hEdit)
{
::SendMessage(hEdit, EM_SETSEL, 0, static_cast<WPARAM>(-1));
::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)txt2find);
}
} }
::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit ::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit
} }
@ -4955,7 +4959,7 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM
HWND hEdit = GetWindow(hwndCombo, GW_CHILD); HWND hEdit = GetWindow(hwndCombo, GW_CHILD);
if (hEdit) if (hEdit)
{ {
SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)clipboardText.c_str()); ::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)clipboardText.c_str());
} }
} }
} }