Skip to content

Commit

Permalink
Fix regression of multiple selections in comboboxes of Find dialog
Browse files Browse the repository at this point in the history
The regression was introduced from commit e25e15b

Fix notepad-plus-plus#15583, close notepad-plus-plus#15587
  • Loading branch information
ozone10 authored and donho committed Aug 28, 2024
1 parent 446cc98 commit bdf3cca
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,8 @@ void FindReplaceDlg::resizeDialogElements()
const bool isLessModeOn = NppParameters::getInstance().getNppGUI()._findWindowLessMode;

//elements that need to be resized horizontally (all edit/combo boxes etc.)
const auto resizeWindowIDs = { IDFINDWHAT, IDREPLACEWITH, IDD_FINDINFILES_FILTERS_COMBO, IDD_FINDINFILES_DIR_COMBO };
const std::vector<int> resizeWindowIDs = { IDFINDWHAT, IDREPLACEWITH, IDD_FINDINFILES_FILTERS_COMBO, IDD_FINDINFILES_DIR_COMBO };
const size_t nComboboxes = resizeWindowIDs.size();

//elements that need to be moved
const auto moveCheckIds = {
Expand Down Expand Up @@ -1275,24 +1276,20 @@ void FindReplaceDlg::resizeDialogElements()

getMappedChildRect(hSwapBtn, rcSwapBtn);

nCtrls = resizeWindowIDs.size() + moveLaterIDs.size() + (isLessModeOn ? 0 : moveTransIDs.size()) + 1; // 1 is for tab control
nCtrls = nComboboxes + moveLaterIDs.size() + (isLessModeOn ? 0 : moveTransIDs.size()) + 1; // 1 is for tab control
hdwp = ::BeginDeferWindowPos(static_cast<int>(nCtrls));

for (int id : resizeWindowIDs)
std::vector<DWORD> endSelections(nComboboxes, 0);

for (size_t i = 0; i < nComboboxes; ++i)
{
HWND resizeHwnd = ::GetDlgItem(_hSelf, id);
HWND resizeHwnd = ::GetDlgItem(_hSelf, resizeWindowIDs[i]);
getMappedChildRect(resizeHwnd, rcTmp);

// Combo box for some reasons selects text on resize. So let's check before resize if selection is present and clear it manually after resize.
DWORD endSelection = 0;
::SendMessage(resizeHwnd, CB_GETEDITSEL, 0, reinterpret_cast<LPARAM>(&endSelection));
::SendMessage(resizeHwnd, CB_GETEDITSEL, 0, reinterpret_cast<LPARAM>(&endSelections[i]));

hdwp = setOrDeferWindowPos(hdwp, resizeHwnd, nullptr, 0, 0, rcSwapBtn.left - rcTmp.left - gap, rcTmp.bottom - rcTmp.top, SWP_NOMOVE | flags);

if (endSelection == 0)
{
::SendMessage(resizeHwnd, CB_SETEDITSEL, 0, 0);
}
}

RECT rcFPrevBtn{};
Expand Down Expand Up @@ -1347,6 +1344,15 @@ void FindReplaceDlg::resizeDialogElements()
if (hdwp)
::EndDeferWindowPos(hdwp);

for (size_t i = 0; i < nComboboxes ; ++i)
{
if (endSelections[i] == 0)
{
HWND resizeHwnd = ::GetDlgItem(_hSelf, resizeWindowIDs[i]);
::SendMessage(resizeHwnd, CB_SETEDITSEL, 0, 0);
}
}

::SetWindowPos(::GetDlgItem(_hSelf, IDFINDWHAT), nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED | flags);
}

Expand Down

0 comments on commit bdf3cca

Please sign in to comment.