举个简单的例子(下面的Edit2也是TEDIT,并且Visible为False不可见,
目的是为了使用剪切板)
这里只说明了1的情况,其它的你自己想吧...在Edit1.OnKeyPress中:
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if Key='1' then
begin
Edit2.Text:='1';
Edit2.SelectAll;
Edit2.CopyToClipboard;
Edit1.PasteFromClipboard;
Key:=#0;
end;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if (key < chr(128) ) and (key>chr(31) )then
begin
postmessage(Handle ,WM_CHAR,163,0);
postmessage(Handle ,WM_CHAR,128+ORD(KEY),0);
KEY:=#0;
end;
end;