How to Repaint FMX Android components in Form in C++Builder 10.4?

543 views Asked by At

I wrote a very simple FMX Adroid App, the function is:
Show Form 2 then write something to record(include title and detail text),

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.

the problem is:
when closed Form 2 and in MainForm::OnActivate we can add a new checkbox for the record.
if we checked checkbox then clicked delete, free the pointer of checked checkbox, the checkbox still in main form until I reopen the APP.
I tried:
Invalidate();
Application->ProcessMessages();
BeginUpdate();
EndUpdate();
Still can't work

does anyone know what's going on ? why FMX TForm member has no "Repaint()" or "Update()" "Refresh()" ? just like VCL has.

1

There are 1 answers

0
S. Dabrowski On

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. If you created your control in runtime using new please remember to call 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). But I think it will run properly without calling this function.

Your controls have Repaint() member and it may be better to call them instead, ie. if your checkbox was placed in TPanel*, repainting only this panel is better idea than repainting whole form.