Udostępnij za pośrednictwem


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

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

Return Value

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

Remarks

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

Example

// 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 = 50;
ft.lpstrText = _T("wallaby");
long n = m_myRichEditCtrl.FindText(FR_MATCHCASE|FR_WHOLEWORD, &ft);
if (n != -1)
   m_myRichEditCtrl.SetSel(ft.chrgText);

Requirements

Header: afxcmn.h

See Also

Reference

CRichEditCtrl Class

Hierarchy Chart

CRichEditCtrl::SetSel

Other Resources

CRichEditCtrl Members