说明:
当焦点控件为TMemo类,同时按下Shift键和Enter,既可在Memo中回车
对Richedit之类控件,同样加上去既可实现回车.
将Form窗的属性KeyPreView 设置为True;
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if (ActiveControl <> nil) and (Key = VK_RETURN) then
begin
if ssShift in Shift then
begin
if ActiveControl is TMemo then
begin
;
end
else
ActiveControl := FindNextControl(
ActiveControl as TWinControl, False, True,False)
End
else
ActiveControl := FindNextControl(
ActiveControl as TWinControl, True, True, False);
End
end;
procedure TForm1.FormKeyPress(Sender: TObject;
var Key: Char);
begin
if (Key = Char(VK_RETURN)) and (not (ActiveControl is TMemo)) then
Key := #0;
end;