简体   繁体   English

如何在 C++Builder 10.4 中重新绘制 FMX Android 组件?

[英]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.

相关问题 如何将文本文件加载到Tmemo(Android,C ++ Builder) - How to load a Text file into Tmemo(Android,C++Builder) C ++ Builder:如何在Android应用程序中显示重音符号? - C++Builder: How to display accent in Android Application? C ++ BUILDER OnVirtualKeyboardShown和OnVirtualKeyboardHidden从另一种形式触发 - C++BUILDER OnVirtualKeyboardShown and OnVirtualKeyboardHidden firing from another form 如何将 UnicodeString 复制到 C++Builder Android 应用程序中的 wchar_t 数组? - How can I copy a UnicodeString to a wchar_t array in a C++Builder Android app? 如何包装列表<int[]>使用 C++Builder 11?</int[]> - How to wrap List<int[]> with C++Builder 11? Delphi 10.4 FMX UnsatisfiedLinkError - Delphi 10.4 FMX UnsatisfiedLinkError 使用几张jpg图片时,c++builder android找不到资源 - Resource not found with c++builder android when using several jpg pictures Embarcadero C++Builder Android 应用程序 SEGV_MAPERR 在特定手机上崩溃 (Galaxy A51) - Embarcadero C++Builder Android Application SEGV_MAPERR Crash on Specific Phones (Galaxy A51) 从Android应用程序(C ++ Builder XE6)启用WIFI和/或移动数据 - Enable WIFI and/or mobile data from Android app (C++Builder XE6) 我可以在Embarcadero C ++ Builder中为Android(* .so)建立共享库吗? - Can I build a shared library for Android (*.so) in Embarcadero C++Builder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM