我在Form的FormKeyPress事件中写入如下代码:
  if (key=#13)  then
    perform(WM_NEXTDLGCTL,0,0);
还要做什么才能实现,Form上的控件,在回车时跳焦点?谢谢?

解决方案 »

  1.   

    在onkeydown 写  if inttostr(key)='13' then { 判断是按执行键}
        if not (ActiveControl is TDbgrid) Then
          Begin { 不是在TDbgrid控件内}
            key:=0;
            perform(WM_NEXTDLGCTL,0,0);{移动到下一个控件}
          end
        else
          if (ActiveControl is TDbgrid) Then{是在 TDbgrid 控件内}
            begin
              With TDbgrid(ActiveControl) Do
                if Selectedindex<(FieldCount-1) then
                  Selectedindex:=Selectedindex+1{ 移动到下一字段}
                else
                  Selectedindex:=0;
            end;
      

  2.   

    Form中声明一个
    procedure CMDialogKey(var Msg:TCMDialogKey);message CM_DIALOGKEY;实现为:
    procedure CMDialogKey(var Msg:TCMDialogKey);
    begin
      if Msg.CharCode = VK_RETURN then
        perform(WM_NEXTDLGCTL,0,0);
    end;
      

  3.   

    以上各位的方法+form1.keypress=true
      

  4.   

    我的问题出在 form1.keypress没有付值,谢谢!