unit UntConst;
interface
  uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,Forms,Dialogs;
  procedure MoveNext(var Key: Char);
implementation
  procedure MoveNext(var Key: Char);
  begin
    if key=#13 then
    begin
        key:=#0;
        perform(WM_NEXTDLGCTL,0,0);//出错
    end;
  end;
end.编译的时候,老是在perform(WM_NEXTDLGCTL,0,0);行出错:undeclared identifier "perform".
为什么????在线等待,谢谢

解决方案 »

  1.   

    你是在一个unit里定义的。而perform必须指定一个sender可以改为:
    procedure MoveNext(var Key: Char;sender:Tobject);
    implementationprocedure MoveNext(var Key: Char;sender:Tobject);
    begin
        Tcontrol(sender).perform(WM_NEXTDLGCTL,0,0);//
    end;
      

  2.   

    在uses列表中,加入Controls,就可以了
      

  3.   

    Responds as if the control received a specified Windows message. Delphi syntax:function Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;C++ syntax:int __fastcall Perform(unsigned Msg, int WParam, int LParam);DescriptionCall Perform to bypass the Windows message queue and send a message directly to the control抯 window procedure.Perform fills a message record (of type TMessage) with the message ID passed in the Msg parameter, the message parameters passed in WParam and LParam, and a result field of zero. Perform then passes the message record to the WindowProc method for processing.
      

  4.   

    必须是TWINCONTRL才有PERFORM,同时,你必须uses  Controls
      

  5.   

    unit UntConst;
    interface
      procedure MoveNext(sender:Tobject;var Key: Char);
    implementation
      uses controls;
      procedure MoveNext(sender:Tobject;var Key: Char);
      begin
        if key=#13 then
        begin
            key:=#0;
            Tcontrol(sender).perform(WM_NEXTDLGCTL,0,0);
        end;
      end;
    end.
    上面的方法我都试过了,可是还是有点问题,说"undeclared identifier WM_NEXTDLGCTL",
    我本来是想把键盘响应事件提去出来作为一个函数,写在我的const unit里,然后在别的form里use这个const unit就可以直接调用函数movenext了,可是好象不行啊。
      

  6.   

    不知道是不是要加上uses shellapi;我的理由是:WM_NEXTDLGCTL这个消息在WIN32 的API中定义的!所以,你可能没有调用相应的单元!
      

  7.   

    还是同样的错误提示,我uses controls,shellapi;了,还是认不出WM_NEXTDLGCTL来