Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backward searching in a RichEdit.

Status
Not open for further replies.

varkhov

Instructor
Jul 25, 2001
4
GR
Greetings ppl,

Another question popped up today. I was wondering if any one of you has ever encountered a case when you needed to perform a backward searching in a RichEdit control. I came up with a very sluggish solution (which does not work anyway). I created another (invisible) RichEdit and then copied to it the lines of the first one in reverse order, actually trying to perform some backward searching, after of course placing the cursor in the equivalent place in the other control (the reversed-text one). Unfortunately it does not work at all!
Do you have any suggestions? Anything you came up with?
Thank you in advance!
 
If you're talking about searching from the end of the text in TRichEdit, why don't you just take the code for search forward and do that bakward? My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Basicly, I have tried something like that so far:

ReverseEdit->Text = "";
for (long i = NormalEdit->Lines.Count; i >= 0; i--)
ReverseEdit->Lines->Add(strrev(NormalEdit->Lines->Strings.c_str()));

and then I tried to place the carret on the ReverseEdit:

ReverseEdit->SelStart = NormalEdit->Text.Length() - NormalEdit->SelStart;

so that I could use ReverseEdit (a newly invisible constructed especially for the purpose RichEdit) with the FindText() method. Unfortunately I have extreme problems with the placing of the SelStart in the ReverseEdit, because of some problem with the Lines (when I add a line, it simply adds a CRLF - and for every line in the original RichEdit, so I come up with more lines in the reversed text. Plus, assuming my ReverseEdit is Word Wrapping, a single sentence becomes two lines, adding up to more CRLFs).
I am now trying to take a new approach, where I will use an AnsiString to take the text of the original control, and then after some deleting, I will start searching for the string I am interested in, having the text and the search text reversed with strrev. Then I will use Pos and hopefully things will go well. I am just wondering why did not Borland try to create a function for backward searching too. If you have anything ready, or you can come up with something, please do a posting. I will e more than grateful.
Thanx in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top