urif
asked on
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(Sen der: 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.ProcessMessage s;
FoundAt:=FindText(FindDial og1.FindTe xt, SearchStart,
Length(Text)-SearchStart,
SearchType);
Screen.Cursor:=crDefault;
Application.ProcessMessage s;
if FoundAt < 1 then
MessageDlg('Unable to find "'+ FindDialog1.FindText +
'"', mtInformation, [mbOK], 0)
else
begin
SetFocus;
SelStart:=FoundAt;
SelLength:=Length(FindDial og1.FindTe xt);
end;
end;
end;
any ideas why? (ActiveRich us a trichedit) thx!
procedure TForm1.FindDialog1Find(Sen
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.ProcessMessage
FoundAt:=FindText(FindDial
Length(Text)-SearchStart,
SearchType);
Screen.Cursor:=crDefault;
Application.ProcessMessage
if FoundAt < 1 then
MessageDlg('Unable to find "'+ FindDialog1.FindText +
'"', mtInformation, [mbOK], 0)
else
begin
SetFocus;
SelStart:=FoundAt;
SelLength:=Length(FindDial
end;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But it works here,
did you changed any thing else
I added a new RichEdit, Turing HideSelection to false, and ScroolBar to Both
did you changed any thing else
I added a new RichEdit, Turing HideSelection to false, and ScroolBar to Both
ASKER
nope, the only thing is that i am creating the richedit at run time, but nothing else
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
begin
if not Assigned(RichEdit1) then
begin
RichEdit1:= TRichEdit.Create(nil);
RichEdit1.Parent:= Self;
RichEdit1.HideSelection:= False;
end;
FindDialog1.Execute;
end;
Motaz
ASKER
ok, thanks, there must be something weird going on then...
but thanks for the help
but thanks for the help
ASKER