Author: Jonas Bilinkevicius How to get the current row and column of a cursor in a TRichEdit Answer: 1 procedure TForm1.GetPosition(Sender: TRichEdit); 2 var 3 aX, aY: Integer; 4 TheRichEdit: TRichEdit; 5 begin 6 aX := 0; 7 aY := 0; 8 TheRichEdit := TRichEdit(Sender); 9 aY := SendMessage(TheRichEdit.Handle, EM_LINEFROMCHAR, TheRichEdit.SelStart, 0); 10 aX := TheRichEdit.SelStart - SendMessage(TheRichEdit.Handle, EM_LINEINDEX, aY, 0); 11 Panel1.Caption := IntToStr(aY + 1) + ':' + IntToStr(aX + 1); 12 end; 13 14 procedure TForm1.RichEditMouseDown(Sender: TObject; Button: TMouseButton; 15 Shift: TShiftState; X, Y: Integer); 16 begin 17 GetPosition(RichEdit); 18 end; 19 20 procedure TForm1.RichEditKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 21 begin 22 GetPosition(RichEdit); 23 end;