[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Searching Memo Field and bold font text

Posted on 1999-12-10
5
Medium Priority
?
370 Views
Last Modified: 2013-12-03
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 :)
0
Comment
Question by:waipahu
  • 3
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 2272615
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
 
LVL 1

Expert Comment

by:Indefrei
ID: 2272855
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2276126
waipahu, are you here?
0
 

Author Comment

by:waipahu
ID: 2276138
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2276156
huu,
i must also do shopping for christmas

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

thanks for accepting

meikl
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

613 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question