Help Center

CRichEditCtx.FindTextExmethod

Finds text within a rich edit control.

Windowsmethoddocumented

Syntax

FUNCTION FindTextEx OVERLOAD (BYVAL fOptions AS DWORD, BYREF ftexw AS FINDTEXTEXW) AS LONG
FUNCTION FindTextEx OVERLOAD (BYVAL fOptions AS DWORD = FR_DOWN, BYVAL cpMin AS LONG = 0, BYVAL cpMax AS LONG = -1, BYREF wszText AS WSTRING) AS CHARRANGE

Parameters

NameDescription
fOptionsSpecifies the parameters of the search operation. This parameter can be one or more of the following values.
FR_DOWN. If set, the operation searches from the end of the current selection to the end of the document. If not set, the operation searches from the end of the current selection to the beginning of the document.
FR_MATCHALEFHAMZA. By default, Arabic and Hebrew alefs with different accents are all matched by the alef character. Set this flag if you want the search to differentiate between alefs with different accents.
FR_MATCHCASE. If set, the search operation is case-sensitive. If not set, the search operation is case-insensitive.
FR_MATCHDIAC. By default, Arabic and Hebrew diacritical marks are ignored. Set this flag if you want the search operation to consider diacritical marks.
FR_MATCHKASHIDA. By default, Arabic and Hebrew kashidas are ignored. Set this flag if you want the search operation to consider kashidas.
FR_WHOLEWORD. If set, the operation searches only for whole words that match the search string. If not set, the operation also searches for word fragments that match the search string.
ftexwA FINDTEXTEXW structure containing information about the find operation.
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range. If the cpMin and cpMax members are equal, the range is empty. The range includes everything if cpMin is 0 and cpMax is –1.
pwszTextA WSTRING containing the text to find.

Return value

First overloaded function: If the target string is found, the return value is the zero-based position of the first character of the match. If the target is not found, the return value is -1.

Second overloaded function: A CHARRANGE structure. The range of characters in which the text was found. If the text was not found, cpMin and cpMax are -1.

Description

Overloaded method to find text within a rich edit control.

Remarks

FindTextEx uses the FINDTEXTEXW structure, while FindTex uses the FINDTEXTW structure. The difference is that FindTextEx reports the range of text that was found.

Examples

DIM dws AS DWSTRING = "box" DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(FR_DOWN, 5, 20, dws) pRichEdit.ExSetSel(chrg.cpMin, chrg.cpMax)

DIM dws AS DWSTRING = "box" DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(FR_DOWN, 0, -1, dws) --or-- DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(FR_DOWN, , , dws) pRichEdit.ExSetSel(chrg.cpMin, chrg.cpMax)

DIM cbStart AS LONG = pRichEdit.GetTextLength DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(0, cbStart, 0, dws) pRichEdit.ExSetSel(chrg.cpMin, chrg.cpMax)

Search in a range: Search in the entire document: Search backwards from the end of the document to the beginning:

Reference

  • Defined in AfxNova/CRichEditCtx.inc:2057
  • Documented in Windows/WIndows Controls/RichEdit/CRichEditCtx Class.md
  • Topic: CRichEditCtx Class