现有简单的输入用户名,密码的登陆界面,原来是点击登陆按钮进入下一个界面,但是感到不是很方便
,想做到输入用户名密码后按回车触发动作,delphi有吗?

解决方案 »

  1.   

    ONKEYPREES事件!!if key=#13 then
    .........
      

  2.   

    呵呵,一楼赚了,key=#13 轻轻松松拿分,楼主也分我点,虽然我晚了一步
      

  3.   

    我再补充一点 啊哈哈
    ONKEYPREES事件 是密码输入框的事件
    不是登陆按钮的事件
      

  4.   

    登陆界面的话把'确认'的button的default属性设置为true,然后在button的onclick里写代码
      

  5.   

    或者在窗体的ONFormKeyDown事件中写
    FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if not (ActiveControl is TDBGrid)  then
     case Key of
        VK_ESCAPE: Close;
        VK_RETURN:
          begin
            if Shift = [ssShift] then
              Perform(WM_NEXTDLGCTL, 1, 0)
            else
              Perform(WM_NEXTDLGCTL, 0, 0);
          end;
        VK_F4, VK_DOWN:
          if screen.ActiveControl is TCustomEdit then
            if (Key = VK_F4) or ((Key = VK_DOWN) and (Shift = [ssAlt])) then
              TCustomEdit(screen.ActiveControl).Perform(WM_LBUTTONDBLCLK, 0, 0);
      end;end;
      

  6.   

    设好窗口中控件的TAB顺序,然后将主窗体的keypreview置为trueprocedure TfmProjectInfo.FormKeyPress(Sender: TObject; var Key: Char);
    begin
      if Key = #13 then
      begin
        Key := #0;
        Keybd_event(VK_TAB, 0, 0, 0);
      end;
    end;这样的话,在上一个控件中按回车键就会跳到下一个控件