Mega Code Archive
How to get the current cursor position in a richedit or memo field
procedure TForm1.Memo1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
x,y:integer; //integer to hold the x,y cordinates of cursor
begin
// gets the y cordinate from memo field
y := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, memo1.Selstart,0);
//calculates the x cordinate from memo field
x:=memo1.Selstart-SendMessage(Memo1.Handle, EM_LINEINDEX, y,0)+1;
//displays information on form's caption bar
Caption:='X:='+IntToStr(x)+' Y:='+intTostr(y);
end;