Board index » delphi » richedit's FindText problem

richedit's FindText problem


2003-09-02 04:46:06 PM
delphi77
Hi all,
I encountered a FindText problem when I am using richedit control.
The case is: there are some 'Enter's in the richedit control, the
result of richedit.FindText('abc', 0, MaxInt,[]) is not accurate.
especially to search the text just after an 'Enter'.
If the there are no 'Enter's in the richedit control, the result will
be always correct.
Anyone encounters such similar problem?
Forgive my poor English.
Regards,
Chunfu.
 
 

Re:richedit's FindText problem

In article <XXXX@XXXXX.COM>, "Tan Chunfu"
<XXXX@XXXXX.COM>writes:
Quote
I encountered a FindText problem when I am using richedit control.
Which one?
The case is: there are some 'Enter's in the richedit control, the
result of richedit.FindText('abc', 0, MaxInt,[]) is not accurate.
It is accurate in that
position:=FindText('abc', 0, MaxInt,[]);
Selstart:=position;
will always put the caret just in front of abc afaik.
.. what are *you* doing with the result?
Quote
especially to search the text just after an 'Enter'.
If the there are no 'Enter's in the richedit control, the result will
be always correct.
Note that with some Richedits,
position:=FindText(#13, 0, MaxInt,[]);
Selstart:=position+1;
- results in selstart=position as the richedit refuses to put the caret
between the #13 and the #10. With others it treats these as a single
character as regards the result of FindText.
Quote

Anyone encounters such similar problem?
Yes, if you are trying to extract a portion of the Text property, (not
usually a good idea anyway, as it is slow), with a richedit that treats CRLF
as single char, you may need to make a copy of text and remove all #10
characters.