Re: Simple question

Posted by Jimmy Lee on January 07, 2009

In Reply to Simple question 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?

Tip: if you want a response, better give your post a meaningful subject :-p
Not just "Simple question" but "Label caption not displayed correctly" or something along these lines.

Anyway, 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

Post a Followup

Name:
Password:

Subject:

Comments:

DelphiLand Club members: enter your Membership password.
Guests can get a Forum Guest password by subscribing to the DelphiLand Newsletter.