Get Memo current line

Posted in Components

Use EM_LINEFROMCHAR message for Memo:

procedure TForm1.Memo1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  LineNum: LongInt;
begin
  if (Key=VK_UP)or(Key=VK_DOWN) then
  begin
    LineNum:=Memo1.Perform(EM_LINEFROMCHAR, Memo1.SelStart, 0);
    Label1.Caption:='Line - '+IntToStr(LineNum+1);
  end;
end;