Delphi按下回车键使各控件依次获得焦点

来源:互联网 发布:手机淘宝店铺申请流程 编辑:程序博客网 时间:2024/05/19 05:03
procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
var
    i : Integer;
begin
    if Msg.CharCode = VK_RETURN then
    begin
        i := ActiveControl.ComponentIndex + 1;
        if (i = ComponentCount) then
            i := 0;
        TWinControl(Controls[i]).SetFocus;
    end;
    Handled := True;

end;


代码没有考虑含有Parent的情况,根据自己需要改吧