Page 1 of 1

Set caret at x,y position

Posted: Mon Mar 13, 2006 3:38 pm
by Tomazaz
Hello,

How to set caret in TRichView at X,Y coordinates position?

Regards,
Tomas

Posted: Mon Mar 13, 2006 4:05 pm
by Sergey Tkachenko

Code: Select all

uses CRVFData;

var pt: TPoint;
     RVData: TCustomRVFormattedData;
     ItemNo, Offs: Integer;

pt := rve.ClientToDocument(Point(X, Y));
if  rve.GetItemAt(pt.X, pt.Y, RVData, ItemNo, Offs, False) then begin
  RVData := TCustomRVFormattedData(RVData.Edit);
  RVData.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);
  rve.TopLevelEditor.Invalidate;
end;