CRichEditCtrl::FindText

long FindText( DWORD dwFlags, FINDTEXTEX* pFindText ) const;

Return Value

Zero-based character position of the next match;  – 1 if there are no more matches.

Parameters

dwFlags

Flags for the match criteria. Can be zero or more of the following values:

pFindText

Pointer to the FINDTEXTEX structure giving the parameters for the search and returning the range where the match was found.

Remarks

Call this function to find text within the rich edit control. You can search either up or down by setting the proper range parameters in the CHARRANGE structure within the FINDTEXTEX structure.

For more information, see EM_FINDTEXTEX message and FINDTEXTEX structure in the Win32 documentation.

Example

// The pointer to my rich edit control.
extern CRichEditCtrl* pmyRichEditCtrl;
// The string to search for.
extern LPCTSTR lpszmyString;

// Set the selection to be the first occurrence of the 
// string lpszmyString, if it is found.   
FINDTEXTEX ft;
ft.chrg.cpMin = 0;
ft.chrg.cpMax = -1;
ft.lpstrText = (LPSTR) lpszmyString;
long n = pmyRichEditCtrl->FindText(FR_MATCHCASE|FR_WHOLEWORD, &ft);
if (n != -1)
   pmyRichEditCtrl->SetSel(ft.chrgText);

CRichEditCtrl OverviewClass MembersHierarchy Chart

See Also   CRichEditCtrl::SetSel