tags:

views:

219

answers:

1

Why does the code below return TRUE in Delphi 7 and FALSE in Delphi 2010? TBitBtn is a descendant of 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;
+12  A: 

is did not change. TBitBtn is a subtype of TCustomButton, not TButton, as you state.

Craig Stuntz
Yes, and that did change, I think between D2007 and D2009
jasonpenny
That's it! Thanks, Craig. I got stung by going back to Delphi 7's help to check it's ancestor! It never occurred to me to check in D2010's help (which I try to avoid when I can...) Thanks, Craig and I voted you, Jason, up too!SO rocks!
Tom1952
Tom, the help is never the place I look for stuff like that. I always consult the source code directly. Ctrl+click on the `TBitBtn` identifier to be taken to its declaration.
Rob Kennedy
This topic was covered last year: http://stackoverflow.com/questions/946316/what-happened-to-codegears-tbitbtn-and-tbutton-inheritence-chain
Remy Lebeau - TeamB