我想做一个自定义控件,在panel显示时间,设定闹钟的。下面是参考书上的一点代码:
unit Clock;interfaceuses
  SysUtils, Classes, Controls, ExtCtrls;type
  Clock = class(TPanel)
  private
    { Private declarations }
    Timer1:TTimer;  //时间控件
    Factive:Boolean;  //时钟控件是否处于激活状态
    FBeep:Boolean;  //是否报时
    Fnow:TDateTime;  //存放当前时间
    procedure CheckBeep;
  protected
    { Protected declarations }
    procedure TimeOn(sender:TObject);   //处理的方法程序
  public
    { Public declarations }
    constructor Create(Owner:TComponent);  //构造方法
    destructor destory;override;         //构析方法
  published
    { Published declarations }
    property Active:Boolean read Factive write Factive;  //激活时间
    property Beep:Boolean read Fbeep write FBeep;       //激活闹钟
  end;procedure Register;implementationprocedure Register;
begin
  RegisterComponents('Samples', [Clock]);
end;{ Clock }procedure Clock.CheckBeep;
var h,m,s,ss:word;
begin
  DecodeTime(now,h,m,s,ss);  //用函数decode()取时、分、秒、毫秒
  if (h=0 and m=0 and s=0)or(m=59 and 60>=s+h) then
  begin
    asm mov ax 0e07h
        int 10h;
    end;
  end;
end;constructor Clock.Create(Owner: TComponent);
begin
  inherited Create(owner);         有问题???????
  parent:=Aowner as tWinControl;   有问题???????  
  timer:=TTimer.create(self);      有问题???????end;在上面的代码中:
inherited Create(owner);         有问题???????
parent:=Aowner as tWinControl;   有问题???????  
timer:=TTimer.create(self);      有问题???????
1、前两行是什么意思啊?
2、为什么在输入inherited create然后按ctrl+enter时却没有我create的提示出来?
3、在第二行和第三行也出现ctrl+enter时却没有找一关键字的内容,如time时按ctrl+enter后却没有出现上面定义的timer啊?请高手帮忙上面三个问题。TKS!

解决方案 »

  1.   

    inherited Create(owner);         调用父类的该方法
    parent:=Aowner as tWinControl;   设置他的parent位Aowner,不过好像你写错了吧.
    这个提示不一定都有的,正常.
      

  2.   

    哦,打错了字,上面的owner全部是Aowner
    为什么要用Aowner呢?
      

  3.   

    inherited Create(Aowner);         没有问题
      parent:=Aowner as tWinControl;   去掉!!!
      timer:=TTimer.create(self);      没有问题
      

  4.   

    构造方法里,记得把Timer1.Enabled:=false;
      

  5.   

    constructor Create(Owner:TComponent);  //构造方法 constructor Create(Owner:TComponent);  override//构造方法