Set caret at x,y position

General TRichView support forum. Please post your questions here
Post Reply
Tomazaz
Posts: 24
Joined: Mon Mar 13, 2006 3:32 pm

Set caret at x,y position

Post by Tomazaz »

Hello,

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

Regards,
Tomas
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
Post Reply