Re: Label caption not displayed correctly

Posted by Jimmy Lee on January 07, 2009

In Reply to Label caption not displayed correctly posted by Dave Barrett on January 06, 2009

: Label1.Caption := '1';
: Sleep(1000); // 1 second
: Label1.Caption := '2';
: Sleep(1000);
: Label1.Caption := '3';
: Sleep(1000);
: I expect to see the caption counting up in increments of one second but what it actually does is the label does not change untill the whole process is finished, in this case in 3 seconds the label will display 3, I never see the 1 or 2. How can I get round this please?

The problem is with "sleep", because it blocks all activity, also the updating of the Label1 caption. Better use a custom (self-made) procedure that allows Windows activity, e.g. Pauze(1000) with Application.ProcessMessages in its loop.

Related articles


Follow Ups