TMSFMXRichEditor Find and Caret Position

I have a large text document. I use Find (same behavior with FindNext) to locate a specific word.  It finds and highlights the word just fine. However I want to position the found text at the top of the screen. I tried using TMSFMXRichEditor1.XYToCaret but the caret position returns 0,0. I assume there must be a way to do this.


Thanks for any help

If the caret is positioned at the word that is found, the X,Y coordinates of this caret is returned by 

AdvRichEditor.Caret.XY: TPoint;

I checked at TMSFMXRichEditor1.Caret.XY.X and TMSFMXRichEditor1.Caret.XY.Y and both values are 0. Find returns true and if I manually scroll down the document I see my search value highlighted and the caret blinking. I just want to position the document so that highlighted value is at the top so my user does not have to page down several pages. thank you

From where are you checking this? When you perform this check for example from a button click event, the button has taken the focus (and thus the caret) away from the memo already. When doing this for example from a TSpeedButton that does not take the focus away, I cannot see an issue here.

I load the document from the database then I do the following check

var
 j : boolean;
begin
   J := true;  //also tried false
   if (length(starttext) > 0)  and  TMSFMXRichEditor1.Find(starttext) then
     TMSFMXRichEditor1.XYToCaret(TMSFMXRichEditor1.Caret.XY.X,
                                     TMSFMXRichEditor1.Caret.XY.Y,false,J)

but does not move to the location of the text
thanks

nevermind...I found the easy answer


TMSFMXRichEditor1.ScrollToCaret