//Através do evento onKeyPress do form, pode-se testar:
if (ActiveControl is TCustomEdit) and (Key = #1) then
blablabla;
ou Como no exemplo abaixo:
procedure TForm1.mnuPasteClick(Sender: TObject);
var
CanPaste: Boolean;
Ctrl: TWinControl;
begin
Ctrl := ActiveControl;
if (Assigned(Ctrl) and
Clipboard.HasFormat(CF_TEXT)) then
begin
if (Ctrl is TEdit) then
CanPaste := (not TEdit(Ctrl).ReadOnly)
else if (Ctrl is TMaskEdit) then
CanPaste := (not TMaskEdit(Ctrl).ReadOnly)
else if (Ctrl is TMemo) then
CanPaste := (not TMemo(Ctrl).ReadOnly)
else if (Ctrl is TRichEdit) then
CanPaste := (not TRichEdit(Ctrl).ReadOnly)
else
CanPaste := False;
if (CanPaste) then
TCustomEdit(Ctrl).PasteFromClipboard;
end;
end;
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário