As a little light relief for me <g> here is my solution. It's over
commented for your benefit.
function GetRichEditLine(RE : TRichEdit) : string;
{gets text lne of cursor position or of selection start}
var
aSelPos, aSelLength, LineStart, LineEnd : integer;
LinePoint : TPoint;
begin
{stop display updating}
RE.Lines.BeginUpdate;
{get char poition of cursor}
aSelPos := RE.SelStart;
{get current selected length}
aSelLength := RE.SelLength;
RE.Perform(EM_POSFROMCHAR, integer(@LinePoint), aSelPos);
{set X to start of line & set SelStart there}
LinePoint.X := 0;
LineStart := RE.Perform(EM_CHARFROMPOS, 0, integer(@LinePoint));
RE.SelStart := LineStart;
{get char position of end of line}
LinePoint.X := RE.ClientWidth;
LineEnd := RE.Perform(EM_CHARFROMPOS, 0, integer(@LinePoint));
{set selected length}
RE.SelLength := LineEnd - RE.SelStart;
Result := RE.SelText;
{restore cursor position & selected length}
RE.SelStart := aSelPos;
RE.SelLength := aSelLength;
{restore display updating}
RE.Lines.EndUpdate;
end;
Alan Lloyd