Delphi FindDialog with a RichEdit

Question

How do you get the richedit to scroll to the matching text when that line is not currently displayed.
 

Answer

To scroll a RichEdit to the place where the cursor is, you use:

  RichEdit1.Perform(EM_SCROLLCARET, 0, 0);

By the way, the caret is at position RichEdit1.SelStart. So if you want to scroll to a certain position, first set SelStart and next use the code above. For example, scroll to the first line:

  RichEdit1.SelStart := 0;
  RichEdit1.Perform(EM_SCROLLCARET, 0, 0);