Mega Code Archive

 
Categories / Delphi / VCL
 

How to limit memo lines

Title: How to limit memo lines procedure TForm1.Memo1Change(Sender: TObject); const MaxLineCount = 5; begin if Memo1.Lines.Count MaxLineCount then // undo the last change // letze nderung r ckg ngig machen Memo1.Perform(EM_UNDO, 0, 0); // The EM_EMPTYUNDOBUFFER message clears the undo flag, // which means that you can no longer undo your last change // to the edit control. // Die Message EM_EMPTYUNDOBUFFER l scht das UnDo Flag, // damit kann die letzte nderung nicht R ckg ngig gemacht werden. Memo1.Perform(EM_EMPTYUNDOBUFFER, 0, 0); end;