procedure TForm1.FormCreate(Sender: TObject); begin self.KeyPreview := true; end;procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); var obj:twincontrol; begin obj := self.ActiveControl; if key=13 then selectnext(obj,true,true); end;
if (KeyPreview = true ) and (Key = #13 )then begin Key := #0; perform(WM_NEXTDLGCTL,0,0); end;跳到下一个可以接受焦点的控件上 相当于 Tab 键
回車鍵是點擊的嗎? 不過 if (KeyPreview = true ) and (Key = #13 )then begin Key := #0; perform(WM_NEXTDLGCTL,0,0); end; 這可能是你要的意思吧。
edit1_OnKeyPress事件 if key=#13 then edit2.setfocus控件写了“.”后面能有提示出来就有
procedure TFrm_gsfather.FormKeyPress(Sender: TObject; var Key: Char); begin if (key = #13) or (key = #40) then SelectNext(ActiveControl,true,true);end;
procedure TWinControl.SelectNext(CurControl: TWinControl; GoForward, CheckTabStop: Boolean); begin CurControl := FindNextControl(CurControl, GoForward, CheckTabStop, not CheckTabStop); if CurControl <> nil then CurControl.SetFocus; end;
if Key = #13 then Edit.Setfocus
if Key = #13 then button.Setfocus
最通用的了
procedure TForm1.FormCreate(Sender: TObject);
begin
self.KeyPreview := true;
end;procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
obj:twincontrol;
begin
obj := self.ActiveControl;
if key=13 then selectnext(obj,true,true);
end;
begin
Key := #0;
perform(WM_NEXTDLGCTL,0,0);
end;跳到下一个可以接受焦点的控件上
相当于 Tab 键
不過
if (KeyPreview = true ) and (Key = #13 )then
begin
Key := #0;
perform(WM_NEXTDLGCTL,0,0);
end;
這可能是你要的意思吧。
if key=#13 then edit2.setfocus控件写了“.”后面能有提示出来就有
begin
if (key = #13) or (key = #40) then
SelectNext(ActiveControl,true,true);end;
procedure TWinControl.SelectNext(CurControl: TWinControl;
GoForward, CheckTabStop: Boolean);
begin
CurControl := FindNextControl(CurControl, GoForward,
CheckTabStop, not CheckTabStop);
if CurControl <> nil then CurControl.SetFocus;
end;