Board index » cppbuilder » TFindDialog Code Problem - What am I doing wrong?

TFindDialog Code Problem - What am I doing wrong?

Hello,

I am having trouble with the following code. It is suppose to find text in a
TMemo (Editor). It is executed when the user clicks "Find" in TFindDialog.
(Where "Editor" is a TMemo, and "Find" is a TFindDialog). I know it is
probably something really obvious, but I a truely stumpped! Please help!

-----------------------------------------------

   int i, j, PosReturn, SkipChars;
   for(i=0; i<Editor->Lines->Count; i++) {
       PosReturn = Editor->Lines->Strings[i].Pos(Find->FindText);
       if(PosReturn == 0) {
           SkipChars = 0;
           for(j=0; j<i-1; j++) {
               SkipChars = SkipChars + Editor->Lines->Strings[j].Length();
           }
           SkipChars = SkipChars + (i*2);
           SkipChars = SkipChars + PosReturn - 1;
           Editor->SetFocus();
           Editor->SelStart = SkipChars;
           Editor->SelLength = Find->FindText.Length();
       }
   }

------------------------------------------
Also, this may be the wrong News Group to post to with this question, but
borland.public.cppbuilder.vcl seems to be down.

Thank you in advance,

Aaron Bockover

 

Re:TFindDialog Code Problem - What am I doing wrong?


Thanks a lot... It works (and is much simpler than what I was trying).
-Aaron

"Mark L. Bartlett" <mbart...@sound.net> wrote in message
news:3AA21198.6B339BF9@sound.net...

Quote
>    int PosReturn;

>    PosReturn = Editor->Lines->Text.Pos(Find->FindText);
>    if(PosReturn)
>    {
>        Editor->SetFocus();
>        Editor->SelStart = PosReturn;
>        Editor->SelLength = Find->FindText.Length();
>    }

> --
> Mark L. Bartlett
> http://www.sound.net/~mbartlet
> ** Please don't send NG 'stuff' to my email account. **

Other Threads