C ++ Builder:刷新FireMonkey可视组件 [英] C++ Builder: Refresh FireMonkey Visual Component

查看:351
本文介绍了C ++ Builder:刷新FireMonkey可视组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++ Builder和FireMonkey的问题。我创建一个与Datasnap休息WebService连接的移动应用程序。有些请求有点长,所以我想显示一个等待消息。这是我的代码:

I have a problem with C++ Builder and FireMonkey. I am creating a mobile application connected with a Datasnap Rest WebService. Some requests are a little bit long so I want to display a waiting message. Here is my code:

lbl_testConnexion->Text = "Please Wait...";
lbl_testConnexion->TextSettings->FontColor = TAlphaColorRec::Red;
this->Invalidate();

//Call to the Web Service
list<Colis>* l = WS->getListeColis("00DP0097");

lbl_testConnexion->Text = "Success!";



我试过函数Form-> Invalidate()和Label-> Repaint(),但只有最后一个文本显示。
我可以做什么动态刷新我的函数中的标签?

I tried functions Form->Invalidate() and Label->Repaint() but only the last text is displayed. What can I do to dynamically refresh the Label in my function?

推荐答案

文本的更改必须由主线程处理,被请求阻塞。如果你不想为长请求使用一个单独的线程,你必须调用 Application-> ProcessMessages()

The change of the text has to be handled by the main thread which is blocked by the request. If you don't want to use a seperate thread for long requests you have to call Application->ProcessMessages().

lbl_testConnexion->Text = "Please Wait...";
lbl_testConnexion->TextSettings->FontColor = TAlphaColorRec::Red;
Application->ProcessMessages();

//Call to the Web Service
list<Colis>* l = WS->getListeColis("00DP0097");

lbl_testConnexion->Text = "Success!";

注意

您必须谨慎使用 Application-> ProcessMessages()。你可以在互联网上找到许多文章和讨论。当您使用VCL时,对于类型 TWinControl 的控件存在调用函数<$ c $的方法更新 c> UpdateWindow 。 Firemonkey有一个类似的功能,但仅适用于Windows。

You have to be carefull with Application->ProcessMessages(). You can find many articles and discussions about this in the internet. When you work with the VCL there exists the method Update for controls of Type TWinControl which calls the function UpdateWindow of the WinAPI. Firemonkey does have a similar function, but only for Windows.

包括 FMX.Platform.Win.hpp Application-> ProcessMessages() with UpdateWindow(Platform :: Win :: WindowHandleToPlatform(Handle) - > Wnd)

这篇关于C ++ Builder:刷新FireMonkey可视组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆