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

来源:互联网 发布:粤语发音翻译软件 编辑:程序博客网 时间:2024/05/19 06:38
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的情况,根据自己需要改吧