Board index » delphi » Label.caption not updating when changed

Label.caption not updating when changed

I'm trying to display the ongoing progress of processing data from a
file by using   label1.caption := 'progress xxx';

However,  label's caption does not get updated on the form until some
dialog gets activated (such as message OK, or an opendialog).  How can
I force the label's caption to change on the form right away after I
set its value ?

Is there an alternative way to show a few words of text for this
purpose ?    canvas.textout works ok and is updated immediately but
takes more work to position it.

Steve

remove "no_spam_" to respond via email:
spa...@umich.edu

 

Re:Label.caption not updating when changed


Quote
><HTML><PRE>Subject: Label.caption not updating when changed
>From: no_spam_spa...@umich.edu (Steve Parus)
>Date: Fri, May 15, 1998 10:53 EDT
>Message-id: <355c54ce.8626...@news.itd.umich.edu>

>I'm trying to display the ongoing progress of processing data from a
>file by using   label1.caption := 'progress xxx';

>However,  label's caption does not get updated on the form until some
>dialog gets activated (such as message OK, or an opendialog).  How can
>I force the label's caption to change on the form right away after I
>set its value ?

>Is there an alternative way to show a few words of text for this
>purpose ?    canvas.textout works ok and is updated immediately but
>takes more work to position it.

>Steve

>remove "no_spam_" to respond via email:
>spa...@umich.edu
></PRE></HTML>

Try application.processMessages..... right after the caption is changed.

it will handle the repaint operation
BEVERNON

Re:Label.caption not updating when changed


Steve,

The label is not updating because you are not giving Windows an
opportunity to get messages through to the window. Insert
Application.ProcessMessages into your loop. This will allow the Windows
message to update the label to get processed. Note that this will have an
impact on the speed of processing your loop.

regards,

Gerhard Groenewald

Quote
Steve Parus wrote:
> I'm trying to display the ongoing progress of processing data from a
> file by using   label1.caption := 'progress xxx';

> However,  label's caption does not get updated on the form until some
> dialog gets activated (such as message OK, or an opendialog).  How can
> I force the label's caption to change on the form right away after I
> set its value ?

> Is there an alternative way to show a few words of text for this
> purpose ?    canvas.textout works ok and is updated immediately but
> takes more work to position it.

> Steve

> remove "no_spam_" to respond via email:
> spa...@umich.edu

Re:Label.caption not updating when changed


Hello.

You can simply write Label1.Update; after writing to the labels caption.

--
Regards
Kai Inge

Steve Parus <no_spam_spa...@umich.edu> wrote in article
<355c54ce.8626...@news.itd.umich.edu>...

Quote

> However,  label's caption does not get updated on the form until some
> dialog gets activated (such as message OK, or an opendialog).  How can
> I force the label's caption to change on the form right away after I
> set its value ?

> Steve

> remove "no_spam_" to respond via email:
> spa...@umich.edu

Re:Label.caption not updating when changed


Besides Application.ProcessMessages (slow) I would try

label1.Update
 - or -
faster label1.Repaint

.Repaint does only Repaint the label. Let's say your old caption was
'LOOONNG' and the new caption is only 'short', I suppose a .Repaint just
draws the 'short' and does not erase the 'NNG'  ..  got it? :-)

label1.Update is somewhat slower but "precise".

Peter

Delphi Tips at http://www.preview.org/e/help.shtml?n

Quote
Steve Parus wrote in message <355c54ce.8626...@news.itd.umich.edu>...
>I'm trying to display the ongoing progress of processing data from a
>file by using   label1.caption := 'progress xxx';

>However,  label's caption does not get updated on the form until some
>dialog gets activated (such as message OK, or an opendialog).  How can
>I force the label's caption to change on the form right away after I
>set its value ?

>Is there an alternative way to show a few words of text for this
>purpose ?    canvas.textout works ok and is updated immediately but
>takes more work to position it.

>Steve

>remove "no_spam_" to respond via email:
>spa...@umich.edu

Re:Label.caption not updating when changed


Just do

Label1.Update

after changing the caption

Other Threads