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

Rob*_*ank 1 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;
Run Code Online (Sandbox Code Playgroud)

Cra*_*ntz 15

is没改变.TBitBtnTCustomButtonTButton你所说的子类型,而不是.

  • 汤姆,帮助永远不是我寻找这样的东西的地方.我总是直接查阅源代码.按住Ctrl键并单击"TBitBtn"标识符以进入其声明. (5认同)
  • 是的,这确实发生了变化,我想在D2007和D2009之间 (4认同)
  • 去年讨论了这个话题:http://stackoverflow.com/questions/946316/what-happened-to-codegears-tbitbtn-and-tbutton-inheritence-chain (2认同)