第二个问题,在“OnKeyPress”中加入
 IF Key = #13 then Key := #0;

解决方案 »

  1.   

    Perform只有Windows控件才有,如TForm, TEdit, TPanel, TComboBox, TRadioButton等;
    实际上它是调用了Windows API 函数SendMessage
    LRESULT SendMessage(    HWND hWnd, // handle of destination window
        UINT Msg, // message to send
        WPARAM wParam, // first message parameter
        LPARAM lParam  // second message parameter
       );
    Perform的用法
    Perform(Msg: UINT; wPa: WPARAM; lPa: LPARAM)
      

  2.   

    The following example demonstrates the use of the Perform method to send a windows message. The EM_SCROLLCARET message scrolls the caret in the rich edit into view. The caret position is set to the contents of the mask edit prior to calling Perform.procedure TForm1.Button1Click(Sender: TObject);begin
    with RichEdit1 do
      Begin
        SelStart := StrToInt(MaskEdit1.Text);
        RichEdit1.Perform(EM_SCROLLCARET, 0, 0);
      end;
    end;
      

  3.   

    Perform只有Windows控件才有,如TForm, TEdit, TPanel, TComboBox, TRadioButton等;
    实际上它是调用了Windows API 函数SendMessage
    LRESULT SendMessage(    HWND hWnd, // handle of destination window
        UINT Msg, // message to send
        WPARAM wParam, // first message parameter
        LPARAM lParam  // second message parameter
       );
    Perform的用法
    Perform(Msg: UINT; wPa: WPARAM; lPa: LPARAM);回车键去掉声音可用一个TApplicationEvents控件,在其OnMessage事件中截获WM_CHAR消息,看看是否为回车,如果是则将Handled 设为True, 然后发送一个Tab键的消息.
      

  4.   

    试试看:
    procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
    const
      SC_DragMove = $F012;  
    begin  ReleaseCapture;
      panel1.perform(WM_SysCommand, SC_DragMove, 0);
    end;//执行以后拖panel看看^_^
      

  5.   

    我在窗体上放入两个EDIT,且在窗体的“OnKeyPress”中写入:
    if Key=#13 then
       Key := #0;
       Perform(WM_NEXTDLGCTL,0,0);
    但每按一次回车,还会发出“嘀”的声音,而且回车键没有代替TAB键。请问是何原因?一定给分
      

  6.   

    你不要写在窗体的onkeypress中,要写在具体的编辑框中,Edit中的onkeypress事件不触发
    form的同样事件,
      

  7.   

    Perform函数在Delphi的帮助文件里有,是Tcontrol.perform
      

  8.   

    你让回车键代替的TAB键,应该是在KeyPress事件中实现的吧,发出的声音是因为你没有去除回车键本身的键入!相当于你在按回车键时并不是代替TAB键,而是在回车键的前面加了一个TAB键入!在Key=#13时处理完你的代码结束之前再将Key := #0;
      

  9.   

    将TabStop := True;
    并设好TabOrder
      

  10.   

    TO dbpower(db)老兄:你没看见我的源码吧,我写在那儿了。
    if Key=#13 then
      Key := #0;
      Perform(WM_NEXTDLGCTL,0,0);
    可是就是不行(TabStop全是True,且TabOrder也设得没错。
      

  11.   

    我试过了,不会出现你的问题,是不是你在KeyDown事件处理,而不是在KeyPress事件中处理
    如:
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key = #13 then
      begin
        Key := #0;
        //以下两种方法都可以啊:Perform或者PostMessage
        //Edit1.Perform(WM_NEXTDLGCTL,0,0);
        PostMessage(Edit1.Handle, WM_KEYDOWN, VK_TAB, 0);
        //Then Edit2 得到焦点了
      end;
    end;
      

  12.   

    TO WuHeHai(河海)我已搞定了,不是用你的方法.不过还是谢谢你了
      

  13.   

    在窗体上放入两个EDIT,且在窗体的“OnKeyPress”中写入:
    if Key=#13 then
      Key := #0;
      Perform(WM_NEXTDLGCTL,0,0);