Solved

find dialog onfind event

Posted on 2002-06-23
6
589 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
  • 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now