各位朋友,请帮个忙:我现在一个窗体中有好多输入控件,设好各控件的TABORDER后,我想用按回车也能实现和按TAB一样的功能,自动把焦点转入下一个控件。请问怎么做。
另:请问怎么样动态建一个控件。(给代码最好)

解决方案 »

  1.   

    Form的KeyPreview属性设为True
    在Form的OnKeyPress事件中
      if Key=#13 then
         Begin
           Key:=#0;
           SelectNext(ActiveControl,True,True);
         End;
      

  2.   

    If Key =#13 then
         Begin
             Key := #0;
             Perform(WM_NEXTDLGCTL,0,0);
         End;
      

  3.   

    var     FTimer: TTimer;
    FTimer:= TTimer.Create(nil);
      

  4.   

    procedure DoEnterAsTab(var Msg:TMsg;var Handle:Boolean); 
    begin
      if Msg.message=WM_KEYDOWN then
        if Msg.wParam=VK_Return then
          KeyBD_Event(VK_Tab,0,0,0);
    end;
    procedure TFrm_Main.FormCreate(Sender: TObject);
    begin
      Application.OnMessage:=Frm_DM.DoEnterAsTab;
    end;
    //转贴