CRichEditView如何加上检索功能,我是从EDIT升到RICHEDIT的

解决方案 »

  1.   

    CRichEditView::FindText
    BOOL FindText( LPCTSTR lpszFind, BOOL bCase = TRUE, BOOL bWord = TRUE );Return ValueNonzero if the lpszFind text is found; otherwise 0.ParameterslpszFindContains the string to search for.bCaseIndicates if the search is case sensitive.bWordIndicates if the search should match whole words only, not parts of words.ResCall this function to find the specified text and set it to be the current selection. This function displays the wait cursor during the find operation.Examplevoid 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))
       {
          CRichEditView::OnTextNotFound( lpszFind );
          return;
       }   GetRichEditCtrl().HideSelection(TRUE, FALSE);
       m_nNumReplaced = 0;
       do
       {
          GetRichEditCtrl().ReplaceSel(lpszReplace);
          m_nNumReplaced++;  // Record the number of replacements   } while (FindTextSimple(lpszFind));
       GetRichEditCtrl().HideSelection(FALSE, FALSE);
    }