[英]How to Repaint FMX Android components in Form in C++Builder 10.4?
I wrote a very simple FMX Adroid App, the function is:我写了一个非常简单的 FMX Adroid App,function 是:
Show Form 2 then write something to record(include title and detail text),显示表格 2 然后写一些东西来记录(包括标题和详细文本),
close Form 2 to Main Form, then make a checkbox in Main Form with the title we just recorded in Form 2. if user check the checkbox, then press "del" buttn then delete the record file and checkbox.将Form 2关闭到Main Form,然后在Main Form中使用我们刚刚记录在Form 2中的标题打一个复选框。如果用户选中该复选框,然后按“del”按钮然后删除记录文件和复选框。
the problem is:问题是:
when closed Form 2 and in MainForm::OnActivate we can add a new checkbox for the record.当关闭 Form 2 和 MainForm::OnActivate 时,我们可以为记录添加一个新复选框。
if we checked checkbox then clicked delete, free the pointer of checked checkbox, the checkbox still in main form until I reopen the APP.如果我们选中复选框然后单击删除,释放选中复选框的指针,复选框仍然在主窗体中,直到我重新打开 APP。
I tried:我试过了:
Invalidate();无效();
Application->ProcessMessages();应用程序->ProcessMessages();
BeginUpdate();开始更新();
EndUpdate();结束更新();
Still can't work仍然无法工作
does anyone know what's going on?有谁知道发生了什么? why FMX TForm member has no "Repaint()" or "Update()" "Refresh()"?为什么 FMX TForm 成员没有“Repaint()”或“Update()”“Refresh()”? just like VCL has.就像 VCL 一样。
If you want your TCheckBox*
(or any other control) disappear from a Form, you need to set its Parent
property to nullptr
before deleting it.如果您希望您的TCheckBox*
(或任何其他控件)从表单中消失,则需要在删除它之前将其Parent
属性设置为nullptr
。 If you created your control in runtime using new
please remember to call delete
.如果您在运行时使用new
创建了控件,请记住调用delete
。
//init
TCheckBox* checkBox = new TCheckBox(Form2);
//delete
checkBox->Parent = nullptr;
delete checkBox;
Answering the second part of your question, you can call Invalidate()
function to repaint your whole Form (but first see first part of this answer).回答问题的第二部分,您可以调用Invalidate()
function 来重新绘制整个表单(但首先请参阅此答案的第一部分)。 But I think it will run properly without calling this function.但我认为它不会调用这个 function 就可以正常运行。
Your controls have Repaint()
member and it may be better to call them instead, ie.您的控件有Repaint()
成员,最好改为调用它们,即。 if your checkbox was placed in TPanel*
, repainting only this panel is better idea than repainting whole form.如果您的复选框放置在TPanel*
中,则仅重新绘制此面板比重新绘制整个表单更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.