gpt4 book ai didi

delphi - Delphi 2010中的"is"语句的行为与Delphi 7中的不同吗?

转载 作者:行者123 更新时间:2023-12-03 18:53:52 26 4
gpt4 key购买 nike

为什么下面的代码在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;

最佳答案

is不变。声明为TBitBtn is a subtype of TCustomButton,而不是TButton

关于delphi - Delphi 2010中的"is"语句的行为与Delphi 7中的不同吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3000169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com