No, you cannot set the position of the carriage at a specific point; instead, you must set the carriage to the position of the character. To do this, you must use the message EM_CHARFROMPOSto extract the closest character to the specified point and then set the value returned to SelStart.
Check out this sample.
procedure TForm1.RichEdit1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
APoint : TPoint;
Index : Integer;
begin
APoint := Point(X, Y);
Index := SendMessage(TRichEdit(Sender).Handle,EM_CHARFROMPOS, 0, Integer(@APoint));
if Index<0 then Exit;
TRichEdit(Sender).SelStart:=Index;
end;
source
share