Scroll to found text after search

  • Hello. I am performing a search for text in WPTools 5. When the text is found I want the RichText to scroll down so that the found text is visible on the screen. Me search code is below.


    I am trying to use TopOffset becuase I am not familiar with another way to "Move to Cursor". If there is a way to do that please let me know. That will save some time.

    But the problem I am havin is that CPLineNr is often returning 0 even when the cursor is not at line 0.

    LN := reMain.CPLineNr;
    if edFinder.Text <> '' then begin
    if reMain.Visible then begin
    with reMain.Finder do begin
    EndAtSpace := False;
    WholeWord := False;
    CaseSensitive := False;
    Next(edFinder.Text);
    SelectText;
    reMain.TopOffset := Round(LN * (reMain.CurrAttr.Size * 1.5));
    end;
    end else begin
    moMacro.FindText(edFinder.Text, [frDown])
    end;
    end;

    Any assistance appreciated. Seems like it shold be a lot simpler than the way I am doing.