Can’t find text in a Rich Edit, using API
-
Hi, all :) I am experiencing a problem with the Rich Edit box (version 1.0) using regular Win32 API (no MFC). I am trying to write a function that will search through a specified range of content in the control (the text). I am using the SendMessage() function with the EM_FINDTEXTEX flag and the FINDTEXTEX structure. But the problem is that it can’t seem to find any matches. For ex. I have set the control with the text “is there any matches?” and I set the function to search for the word “any” but won’t find any thing. The function has been written to return the number of matches it finds, the following code is the function I have written. Can anyone please help me figure out the problem?
int FindText(HWND hEdit, char *Text, CHARRANGE *Range) {
FINDTEXTEX TextSearch;
int MatchCount = 0;
int MatchFound;TextSearch.chrg = \*Range; TextSearch.lpstrText = Text; TextSearch.chrgText.cpMin = -1; while (1) { MatchFound = SendMessage(hEdit, EM\_FINDTEXTEX, FR\_WHOLEWORD, (LPARAM) &TextSearch); if (TextSearch.chrgText.cpMin != -1) { MatchCount++; if (MatchFound != -1) TextSearch.chrg.cpMin = MatchFound; else break; } else break; } return MatchCount;
}
Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.