我在 FMX 应用程序中有一个 TPanels
列表,我想在单击它时释放一个面板。
直接在 Onclick 处理程序中释放它们不是正确的方法,因为我遇到了访问冲突。而且我不想使用 windowsmessages
(在 How to free control inside its event handler? 和 Why does my program crash when I destroy a button in its own OnClick handler? 中推荐),因为它是一个 firemonkey 应用程序,我不知道这些消息在 android 和 mac 上如何工作。
还有其他解决办法吗?
最佳答案
使用myObject.Release
:
Marks this TFmxObject object for delayed deletion.
此方法中的立即操作:
- 设置父级= nil
- 将对象插入延迟删除列表
延迟行动:
- 从列表中释放对象 (
vPurgatory
)。
请记住,方法Free
(和过程FreeAndNil
)不会删除移动平台中的对象本身:
// under ARC, this method isn't actually called since the compiler translates // the call to be a mere nil assignment to the instance variable, which then calls _InstClear
关于delphi - 如何在其自身事件中释放控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31785692/