procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if ((Length(Edit1.Text) = 1) and (Key <> #8)) and (Edit1.SelLength <> 1) then Key := #0; end;
uses Clipbrd; procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); const AuthorizedKeys = #1; begin with Edit1 do begin if ((Text '') or (SelLength 1)) and (Key = #22) and Clipboard.HasFormat(CF_TEXT) then begin Text := Clipboard.AsText[1]; SelStart := 1; Key := #0; end else if ((Length(Text) = 1) and not(Key in AuthorizedKeys)) and (SelLength <> 1) then Key := #0; end; end;
if Clipboard.HasFormat(CF_TEXT) then Clipboard.AsText := Clipboard.AsText[1];
uses Clipbrd; procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); const AuthorizedKeys = #1; begin with Edit1 do begin if ((Text '') or (SelLength 1)) and (Key = #22) and Clipboard.HasFormat(CF_TEXT) then begin Text := Clipboard.AsText[1]; SelStart := 1; Key := #0; end else if ((Length(Text) = 1) and not(Key in AuthorizedKeys)) and (SelLength <> 1) then Key := #0; end; end; procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Clipboard.HasFormat(CF_TEXT) then Clipboard.AsText := Clipboard.AsText[1]; end;