Export (0) Print
Expand All
MFC
Expand Minimize

CRichEditCtrl::FindText 

Finds text within the rich edit control.


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

Parameters

dwFlags

For a list of possible values, see wParam in EM_FINDTEXTEXT in the Platform SDK.

pFindText

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

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

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 Platform SDK.

// 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);

Community Additions

ADD
Show:
© 2015 Microsoft