Delphi 2010“is”声明的行为与Delphi 7不同?

时间:2010-06-08 18:30:26

标签: delphi

为什么以下代码在Delphi 7中返回TRUE而在Delphi 2010中返回FALSE? TBitBtn是TButton的后裔。

    type
      TForm1 = class(TForm)
        Button1: TButton;
        BitBtn1: TBitBtn;
        procedure Button1Click(Sender: TObject);
      private
      public
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TestControl( aControl: TControl);
    begin
      if (aControl is TButton) then showmessage('TRUE') else showmessage('FALSE');
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      TestControl(BitBtn1);
    end;

1 个答案:

答案 0 :(得分:15)

is没有改变。正如您所述,TBitBtn is a subtype of TCustomButton,而不是TButton