Searching Memo Field and bold font text

I want to create a program to do the following:
1. search memo field (how do i advance each line
   in the memo field to do a search line by line?)
2. position the cursor to the text that i was searching for
3. highlight the text in bold

Note: the contents of the memo field may be over 1 viewable
        page, therefore, you have to scroll down if the text
        I'm searching is the the bottom part of the memo field.

Thanks
You experts have been great :)
waipahuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
hi waipahu,

first bold cannot be done in a memo

here a solution with using a finddialog in a richedit,
-the bold remains permanent
-you can repeatly search
-the found Word appears (on the top line)
(richedit used in the uses-clause)

var
  FoundAt : Integer;
  FT : TFindText;
  SB, OldS, OldSL : Integer;


procedure TForm1.Button2Click(Sender: TObject);
begin
  ReplaceDialog1.FindText := RichEdit1.SelText;
  FindDialog1.Execute;
end;

procedure TForm1.FindDialog1Show(Sender: TObject);
begin
  OldS := RichEdit1.SelStart;
  OldSL := RichEdit1.SelLength;
  SB := RichEdit1.SelStart-1;
end;

procedure TForm1.FindDialog1Close(Sender: TObject);
begin
  RichEdit1.SelStart := OldS;
  RichEdit1.SelLength := OldSL;
end;

procedure TForm1.FindDialog1Find(Sender: TObject);
var
  L : Integer;
  MatchC, WholeW : Integer;
  fs : String;
begin
  fs := FindDialog1.FindText;
  FT.chrg.cpMin := SB+1;
  FT.chrg.cpMax := Length(RichEdit1.Text);
  FT.lpstrText := PChar(fs);
  If frWholeWord in FindDialog1.Options then
    WholeW := FT_WHOLEWORD
  else
    WholeW := 0;
  If frMatchCase in FindDialog1.Options then
    MatchC := FT_MATCHCASE
  else
    MatchC := 0;
  FoundAt := RichEdit1.Perform(EM_FindText,MatchC or WholeW,integer(@FT));
  if FoundAt > -1 then
  begin
    RichEdit1.SelStart := FoundAt;
    RichEdit1.SelLength := length(fs);
    RichEdit1.SelAttributes.Style := RichEdit1.SelAttributes.Style + [fsBold];
  end
  else  ShowMessage(fs+' is never found');
  //noramally use this follow line
  //  RichEdit1.Perform(EM_ScrollCaret,0,0);
  //But if this not work uses this
  L := Richedit1.Perform(EM_ExLineFromChar,0,RichEdit1.SelStart);//Get the Line
  Richedit1.Perform(EM_LineScroll,0,-Richedit1.Lines.Count);//Scroll to Begin
  Richedit1.Perform(EM_LineScroll,0,L);                      //Scroll to Line
  //End if this not work
  RichEdit1.SetFocus;
  SB := Richedit1.Selstart;
end;

meikl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IndefreiCommented:
Hi, waipahu,

for a memosearch see

Q_10245031.html

it does everything you want except the bold stuff

Answer is also by meikl kretzschmar

cheers
Indi
0
kretzschmarCommented:
waipahu, are you here?
0
waipahuAuthor Commented:
Thank you krezt..
i got busy doing some christmas
shopping....i will try your code
as soon as i can. I really appreciate
your help!!!! thanks so much..

:)
0
kretzschmarCommented:
huu,
i must also do shopping for christmas

well,
if you further q's about this,
just ask here.

thanks for accepting

meikl
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.