Jump to content
KMarb

How to force update to label during a loop

Recommended Posts

I'm not intimate with the depths of MSWindows, but I think the TLabel might respond to the "CM_TEXTCHANDED" message, so you can do some checking by redrawing the control (invalidating it and resetting to the new text)

Share this post


Link to post

I was just having this problem and found a nasty explanation (bug)

 

I was calling Main Form via a custom event handler to pass some data I want to monitor but the electric just had to be switched off (highly relevant) so I set my Laptop to being only monitor and suddenly I was seeing numbers changing without any kind of special processing. Electric came back on so I switched back to Laptop + External monitor and it stopped working again (External being main display).

 

Running it again I dragged to form between displays - on Laptop screen numbers change, on External display they don't ...

 

As some will have multiple displays (most these days?) it is likely that some people will think it works and some people wont

 

Note that like the OP I'm also using FMX

Share this post


Link to post
On 3/20/2023 at 12:16 PM, programmerdelphi2k said:

I'm not intimate with the depths of MSWindows, but I think the TLabel might respond to the "CM_TEXTCHANDED" message, so you can do some checking by redrawing the control (invalidating it and resetting to the new text)

CM_TEXTCHANGED is a VCL message, it doesn't exist in FMX.  When the TLabel.Text property is changed in FMX, there is no window message issued back to the TLabel, but there are virtual methods called instead, such as DoChanged() and DoTextChanged().  It should also be mentioned that the Text setter already calls Repaint() after calling the virtual methods.

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×