jjschwartz
Technical User
I'm trying to 'flash' a statictext label as an alert to the user.
procedure form1.flash;
begin
statictext1.color := clBlack;
statictext1.font.color := clWhite;
beep;
sleep(2000);
end;
(I've left out the restoring of the colors for this thread.)
When this code runs, it beeps, the computer sleeps for 2 seconds, and *then* the statictext changes color.
By trial-and-error, when I added application.processmessages;
after the color change but before the sleep, it worked fine. It's as if the computer puts the color change on its list of things to do but merrily goes to sleep before it's done unless it's forced too.
Can anyone explain this behavior? Why does the sleep procedure even get called before the color change is finished?
TIA,
Jeffrey Schwartz
procedure form1.flash;
begin
statictext1.color := clBlack;
statictext1.font.color := clWhite;
beep;
sleep(2000);
end;
(I've left out the restoring of the colors for this thread.)
When this code runs, it beeps, the computer sleeps for 2 seconds, and *then* the statictext changes color.
By trial-and-error, when I added application.processmessages;
after the color change but before the sleep, it worked fine. It's as if the computer puts the color change on its list of things to do but merrily goes to sleep before it's done unless it's forced too.
Can anyone explain this behavior? Why does the sleep procedure even get called before the color change is finished?
TIA,
Jeffrey Schwartz