actually, there are a few more flags but they are relevant to non-english languages. lparam == pointer to the findtext structure. findtext struct chrg charrange <> lpstrtext dword ? findtext ends chrg is a charrange structure which is defined as follows: charrange struct cpmin dword ? cpmax dword ? charrange ends cpmin contains the character index of the first character in the character array (range). cpmax contains the character index of the character immediately following the last character in the character array. in essence, to search for a text string, you have to specify the character range in which to search. the meaning of cpmin and cpmax differ according to whether the search is downward or upward. if the search is downward, cpmin specifies the starting character index to search in and cpmax the ending character index. if the search is upward, the reverse is true, ie. cpmin contains the ending character index while cpmax the starting character index. lpstrtext is the pointer to the text string to search for. em_findtext returns the character index of the first character in the matching text string in the richedit control. it returns -1 if no match is found. em_findtextex wparam == the search options. same as those of em_findtext. lparam == pointer to the findtextex structure. findtextex struct chrg charrange <> lpstrtext dword ? chrgtext charrange <> findtextex ends the first two members of findtextex are identical to those of findtext structure. chrgtext is a charrange structure that will be filled with the starting/ending characterindices if a match is found. the return value of em_findtextex is the same as that of em_findtext. the difference between em_findtext and em_findtextex is that the findtextex structure has an additional member, chrgtext, which will be filled with the starting/ending character indices if a match is found. this is convenient if we want to do more text operations on the string.
replace/insert text
richedit control provides em_settextex for replacing/inserting text. this message combines the functionality of wm_settext and em_replacesel. it has the following syntax:
em_settextex wparam == pointer to settextex structure. settextex struct flags dword ? codepage dword ? settextex ends flags can be the combination of the following values:
| st_default | deletes the undo stack, discards rich-text formatting, replaces all text. |
| st_keepundo | keeps the undo stack |
| st_selection | replaces selection and keeps rich-text formatting |