将窗体的KeyPreview属性设为True; 然后在窗体的KeyPress事件里写 if key=char(13) then Perform(CM_Dialogkey,VK_Tab,0);
最好是使用消息的方法: procedure OnAppMessage(var Msg:TMsg;var Handled:Boolean) begin if Msg.Message=WM_KeyDown then begin if Msg.wParam = VK_RETURN then begin if Screen.ActiveForm.ActiveControl is TEdit then begin Msg.wParam := VK_TAB; end; end; end; end;
然后在窗体的KeyPress事件里写
if key=char(13) then
Perform(CM_Dialogkey,VK_Tab,0);
procedure OnAppMessage(var Msg:TMsg;var Handled:Boolean)
begin
if Msg.Message=WM_KeyDown then
begin
if Msg.wParam = VK_RETURN then
begin
if Screen.ActiveForm.ActiveControl is TEdit then
begin
Msg.wParam := VK_TAB;
end;
end;
end;
end;