Solved

find dialog onfind event

Posted on 2002-06-23
6
595 Views
Last Modified: 2008-02-01
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
Comment
Question by:urif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 50 total points
ID: 7101548
Turn HideSelection property of RichEdit to False.
0
 

Author Comment

by:urif
ID: 7101550
this is the 1st thing i did, still...
0
 
LVL 7

Expert Comment

by:Motaz
ID: 7101551
But it works here,
did you changed any thing else
I added a new RichEdit, Turing HideSelection to false, and ScroolBar to Both
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:urif
ID: 7101558
nope, the only thing is that i am creating the richedit at run time, but nothing else
0
 
LVL 7

Expert Comment

by:Motaz
ID: 7101560
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
 

Author Comment

by:urif
ID: 7101563
ok, thanks, there must be something weird going on then...

but thanks for the help
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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