procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Caption:=Caption+' KeyPress';
if Key = 46 then
ShowMessage('Delete press!');
end;
to: phosphor3000
你自己试过了吗?我试了一下,用OnKeyDown是可行的
procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = 46 then
begin
//想执行什么就写什么
Key := 0; //取消键入,这样TRichEdit就不会删除字符了
end;
end;
procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_DELETE then
begin
Key:=VK_RETURN;
RichEdit1.Text:=copy(RichEdit1.Text,1,RichEdit1.SelStart)+Chr(Key)+copy(RichEdit1.Text,
RichEdit1.SelStart+RichEdit1.SelLength+1,Length(RichEdit1.Text));
end;
end;