• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 603
  • Last Modified:

find dialog onfind event

hi everyone, i've a find dialog and a richedit, below is the code for onfind, this code find the text, marks the text but it doesn;t scroll the richedit, if the found text is out of view (need to scroll to reach) then this code won't do it.

any ideas why? (ActiveRich us a trichedit) thx!

procedure TForm1.FindDialog1Find(Sender: TObject);
var
  FoundAt: longint;
  SearchType: TSearchTypes;
  SearchStart: integer;
begin
    finddialog1.CloseDialog;

with ActiveRich do
  begin

  if frWholeWord in FindDialog1.Options then
    SearchType:=[stWholeWord]
  else
    SearchType:=[];

  if SelLength > 0 then
    SearchStart:=SelStart + SelLength//1
  else
    SearchStart:=SelStart;

  Screen.Cursor:=crHourGlass;
  Application.ProcessMessages;
  FoundAt:=FindText(FindDialog1.FindText, SearchStart,  
                Length(Text)-SearchStart,
                              SearchType);

  Screen.Cursor:=crDefault;
  Application.ProcessMessages;
  if FoundAt < 1 then
    MessageDlg('Unable to find "'+ FindDialog1.FindText +
               '"', mtInformation, [mbOK], 0)
  else
    begin
    SetFocus;
    SelStart:=FoundAt;
    SelLength:=Length(FindDialog1.FindText);

    end;
  end;
end;
0
urif
Asked:
urif
  • 3
  • 3
1 Solution
 
MotazCommented:
Turn HideSelection property of RichEdit to False.
0
 
urifAuthor Commented:
this is the 1st thing i did, still...
0
 
MotazCommented:
But it works here,
did you changed any thing else
I added a new RichEdit, Turing HideSelection to false, and ScroolBar to Both
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
urifAuthor Commented:
nope, the only thing is that i am creating the richedit at run time, but nothing else
0
 
MotazCommented:
I used this code and it works fine:

begin
  if not Assigned(RichEdit1) then
  begin
    RichEdit1:= TRichEdit.Create(nil);
    RichEdit1.Parent:= Self;
    RichEdit1.HideSelection:= False;
  end;
  FindDialog1.Execute;
end;

Motaz
0
 
urifAuthor Commented:
ok, thanks, there must be something weird going on then...

but thanks for the help
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now