procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char); const Marge = 10; // à peu près, faut voir... begin case Key of #8 : Exit; // touche retour #13: // touche entrée begin Key := #0; // + traitement éventuel ici end; else if (Canvas.TextWidth(Memo1.Text)) > Memo1.Width - Marge then Key := #0; end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprocedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin Panel1.Caption := Edit1.Text; if Key = #13 then Edit1.Hide; end; procedure TForm1.Panel1Click(Sender: TObject); begin Edit1.Show; Edit1.SetFocus; end;