bool EditFind::ReplaceAll(void) { ASSERT(m_findOnly == false); // Does the current selection match? bool currentMatch = false; { CHARRANGE sel = m_edit->GetSelect(); CStringW selText = m_edit->GetTextRange(sel.cpMin,sel.cpMax); if (m_dialog->MatchCase()) { if (selText.Compare(m_dialog->GetFindString()) == 0) currentMatch = true; } else { if (selText.CompareNoCase(m_dialog->GetFindString()) == 0) currentMatch = true; } } if (currentMatch || FindNext(true)) { while (Replace()); return true; } return false; }
bool EditFind::Replace(void) { ASSERT(m_findOnly == false); // Get the text in the current selection CHARRANGE sel = m_edit->GetSelect(); CStringW selText = m_edit->GetTextRange(sel.cpMin,sel.cpMax); // If the current selection matches the text in the dialog, replace it if (m_dialog->MatchCase()) { if (selText.Compare(m_dialog->GetFindString()) == 0) m_edit->ReplaceSelect(m_dialog->GetReplaceString()); } else { if (selText.CompareNoCase(m_dialog->GetFindString()) == 0) m_edit->ReplaceSelect(m_dialog->GetReplaceString()); } // Find the next occurence return FindNext(true); }