简体   繁体   English

Delphi Firemonkey TButton免费

[英]Delphi Firemonkey TButton free

I've found something very strange in Delphi 10.1 Firemonkey. 我在Delphi 10.1 Firemonkey中发现了一些非常奇怪的东西。

procedure TForm1.Button1Click(Sender: TObject);
begin
  Button1.Free;
end;

After this - when I clicked on this button, the form's system icons aren't working! 此后-当我单击此按钮时,表单的系统图标不起作用! It returns to work only when pressed another button or switched to another window and back again. 仅当按下另一个按钮或切换到另一个窗口并再次返回时,它才能恢复工作。 Why? 为什么? I'm confused... 我糊涂了...

The way to solve it is: 解决方法是:

procedure TForm1.Button1Click(Sender: TObject);
begin
  RemoveObject(Button1);
end;

In VCL worked with the .Free, but the FMX works in some different way. 在VCL中,.Free可以使用,但FMX可以以其他不同方式使用。

This is because of the way (horrible way) arc is made under delphi. 这是因为在delphi下创建电弧的方式(可怕的方式)。 Under arc Free do nothing. 在弧光下无所事事。 it's completely stupid but guy at embarcadero seam to like it and after i see people like you who don't understand why their code don't work... 这完全是愚蠢的,但是embarcadero缝上的家伙喜欢它,而在我看到像您这样的人之后,他们不明白为什么他们的代码不起作用...

so instead of doing button1.free you need to do button1.disposeOF ... replace all your free by disposeOF and your code will be less buggy under ARC and say thanks to emb 因此,除了执行button1.free之外,您还需要执行button1.disposeOF ...,将所有的free替换为disposeOF,这样您的代码在ARC下的错误就会更少,并且要感谢emb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM