Je ne crois pas qu'il y ait un moyen facile de le faire, je l'ai mis un événement OnKeyPress avant que les tentatives de limiter (je ne sais pas s'il gère coller dans le texte)
procedure AddressMemoOnKeyPressEvent(Sender: TObject; var Key: Char);
var
i, lineCount: Integer;
begin
with Sender as TMemo do
begin
if (Key <> #13) and (Key <> #8) and (Length(Lines[CaretPos.Y]) >= MAX_CHARS_PER_LINE_IN_MEMO) then
Key := #0;
lineCount := 0;
for i := 1 to Length(TMemo(Sender).Lines.Text) do
begin
if (TMemo(Sender).Lines.Text[i] = #13) then
Inc(lineCount);
end;
if (Key = #13) AND (Key <> #8) AND (lineCount >= MAX_LINES_PER_MEMO - 1) then
Key := #0;
// if we got past the last line, no key can be entered...
if (CaretPos.Y >= MAX_LINES_PER_MEMO) then
Key := #0;
end;
end;