Export (0) Print
Expand All

CRichEditView::FindText 

Call this function to find the specified text and set it to be the current selection.


BOOL FindText(
   LPCTSTR lpszFind,
   BOOL bCase = TRUE,
   BOOL bWord = TRUE,
   BOOL bNext = TRUE
);

Parameters

lpszFind

Contains the string to search for.

bCase

Indicates if the search is case sensitive.

bWord

Indicates if the search should match whole words only, not parts of words.

bNext

Indicates the direction of the search. If TRUE, the search direction is toward the end of the buffer. If FALSE, the search direction is toward the beginning of the buffer.

Nonzero if the lpszFind text is found; otherwise 0.

This function displays the wait cursor during the find operation.

void CMyRichEditView::OnReplaceAll( LPCTSTR lpszFind, 
            LPCTSTR lpszReplace, BOOL bCase, BOOL bWord )
{
   CWaitCursor wait;
   // No selection or different than what we are looking for
   if (!FindText(lpszFind, bCase, bWord))
   {
      // Call the TextNotFound method to reset the internal search
      // state of the control
      TextNotFound(lpszFind);
      return;
   }

   GetRichEditCtrl().HideSelection(TRUE, FALSE);
   m_nNumReplaced = 0;
   do
   {
      GetRichEditCtrl().ReplaceSel(lpszReplace);
      // Record the number of replacements
      m_nNumReplaced++;

   } while (FindTextSimple(lpszFind));
   GetRichEditCtrl().HideSelection(FALSE, FALSE);
}

Community Additions

ADD
Show:
© 2014 Microsoft